DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • May 25, 2013, 10:04:13 PM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: Problem with race based on CMJ Improbable races pack  (Read 599 times)
0 Members and 1 Guest are viewing this topic.
ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« on: June 23, 2011, 02:23:15 PM »

hello everyone i was trying to edit human race by CMJ to make my own custom elf race and this error popped out

i cant find any syntax error can someone help me

Thanks in Advance


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRI NG, expecting ')' in /home/talesoftwilight/public_html/modules/raceelf.php on line 7
Quote
<?php

function raceelf_getmoduleinfo(){
   $info= array(
        "name"=>"Race - Elf with magic",
       "version"=> 1.1
       "author"=>"Eric Stevens, modifications and enhancements by Dan Hall small edits by chesire "
       "category"=>"Races",
       "download"=>"fix_this",
       "settings"=>array(
       "Elf Race Settings,title",
         "villagename"=>"Name for the Elf village|Crytsal Forest",
         "minedeathchance"=>"Chance for elfs to die in the mine,range,0,100,1|90",
         "bonus"=>"How many extra forest fights for elfs?,range,1,3,1|2",
      ),
      "prefs" => array(
         "Specialty - Elf Blessings User Prefs,title",
         "skill"=>"Points in Elf Blessings,int|0",
         "earth"=>"Earth blessings,int|0",
         "wind"=>"Wind Blessings,int|0",
         "water"=>"Water Blessings,int|0"
         "fire"=>"Fire Blessings,int|0",
      ),
      );
   return $info;
« Last Edit: June 23, 2011, 02:34:56 PM by ChesireCat » Logged

Kira
Militia
**
Offline Offline

Posts: 22


View Profile
« Reply #1 on: June 23, 2011, 02:30:25 PM »

Code:
"author"=>"Eric Stevens, modifications and enhancements by Dan Hall "

I think your comma you added after Eric Stevens may be causing the parse error.  Everything looks right except for that.
Logged

I like 0.9.7+jt
ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« Reply #2 on: June 23, 2011, 02:34:00 PM »

i deleted the comma and the error its still there T.T

PS :Wait i think i forgot a comma in the end
Logged

Kira
Militia
**
Offline Offline

Posts: 22


View Profile
« Reply #3 on: June 23, 2011, 02:35:27 PM »

  You are showing the whole function or part?  If that's the entire function it must be closed with a } after return.

Yes you did Tongue

You also forgot a comma after the version which should work without any "" around it but you should probably use them anyways.  It has many errors.  You just need to go back through and make sure all the values have commas after them, every () and {} is closed, and ""are used properly.
« Last Edit: June 23, 2011, 02:44:16 PM by Kira » Logged

I like 0.9.7+jt
ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« Reply #4 on: June 23, 2011, 02:41:33 PM »

Its fixed now the error was was with the spaces

now this showed up

Not installable    raceelf.php (Invalid Module! Contact Author or check file!)   

here is the full code now

Quote
<?php

function raceelf_getmoduleinfo(){
   $info = array(
      "name"=>"Race - Elfs with magic",
      "version"=>"1.0",
        "author"=>"Eric Stevens, modifications and enhancements by Dan Hall minor Edits by Chesire",
      "category"=>"Races",
      "download"=>"fix_this",
      "settings"=>array(
       "Elf Race Settings,title",
         "villagename"=>"Name for the Elf village|Crytsal Forest",
         "minedeathchance"=>"Chance for elfs to die in the mine,range,0,100,1|90",
         "bonus"=>"How many extra forest fights for elfs?,range,1,3,1|2",
      ),
      "prefs" => array(
         "Specialty - Elf Blessings User Prefs,title",
         "skill"=>"Points in Elf Blessings,int|0",
         "earth"=>"Earth blessings,int|0",
         "wind"=>"Wind Blessings,int|0",
         "water"=>"Water Blessings,int|0",
         "fire"=>"Fire Blessings,int|0"
      ),
   );
   return $info;
}

function raceelf_install(){
   module_addhook("chooserace");
   module_addhook("setrace");
   module_addhook("newday");
   module_addhook("villagetext");
   module_addhook("stabletext");
   module_addhook("travel");
   module_addhook("validlocation");
   module_addhook("validforestloc");
   module_addhook("moderate");
   module_addhook("changesetting");
   module_addhook("raceminedeath");
   module_addhook("stablelocs");
   module_addhook("racenames");
   module_addhook("fightnav-specialties");
   module_addhook("apply-specialties");
   return true;
}

function raceelf_uninstall(){
   global $session;
   $vname = getsetting("villagename", LOCATION_FIELDS);
   $gname = get_module_setting("villagename");
   $sql = "UPDATE " . db_prefix("accounts") . " SET location='$vname' WHERE location = '$gname'";
   db_query($sql);
   if ($session['user']['location'] == $gname)
      $session['user']['location'] = $vname;
   // Force anyone who was an elf to rechoose race
   $sql = "UPDATE  " . db_prefix("accounts") . " SET race='" . RACE_UNKNOWN . "' WHERE race='elf'";
   db_query($sql);
   if ($session['user']['race'] == 'Elf')
      $session['user']['race'] = RACE_UNKNOWN;
   return true;
}

function raceelf_dohook($hookname,$args){
   //yeah, the $resline thing is a hack.  Sorry, not sure of a better way
   // to handle this.
   // Pass it as an arg?
   global $session,$resline;
   $city = get_module_setting("villagename");
   $race = "Elf";
   switch($hookname){
   case "racenames":
      $args[$race] = $race;
      break;
   case "raceminedeath":
      if ($session['user']['race'] == $race) {
         $args['chance'] = get_module_setting("minedeathchance");
      }
      break;
   case "changesetting":
      // Ignore anything other than villagename setting changes
      if ($args['setting'] == "villagename" && $args['module']=="raceelf") {
         if ($session['user']['location'] == $args['old'])
            $session['user']['location'] = $args['new'];
         $sql = "UPDATE " . db_prefix("accounts") .
            " SET location='" . addslashes($args['new']) .
            "' WHERE location='" . addslashes($args['old']) . "'";
         db_query($sql);
         if (is_module_active("cities")) {
            $sql = "UPDATE " . db_prefix("module_userprefs") .
               " SET value='" . addslashes($args['new']) .
               "' WHERE modulename='cities' AND setting='homecity'" .
               "AND value='" . addslashes($args['old']) . "'";
            db_query($sql);
             }
         }
      break;
   case "chooserace":
      output("`0<a href='newday.php?setrace=$race$resline'>You  were born a magical creature</a> Always Surrounded by magic and spiritual creatures you have a natural affinity for magic.", true);
      addnav("`@Elf`0","newday.php?setrace=$race$resline");
      addnav("","newday.php?setrace=$race$resline");
      break;
   case "setrace":
      if ($session['user']['race']==$race){
         $bonus = get_module_setting("bonus");
         $one = translate_inline("an");
         $two = translate_inline("two");
         $three = translate_inline("three");
         $word = $bonus==1?$one:$bonus==2?$two:$three;
         $fight = translate_inline("fight");
         $fights = translate_inline("fights");
         output("`@ You were born with outsanding physical conditons besides your beauty and magic affinity`n`^You gain %s extra forest %s each day!", $word, $bonus==1?$fight:$fights);
         if (is_module_active("cities")) {
            if ($session['user']['dragonkills']==0 &&
                  $session['user']['age']==0){
               //new farmthing, set them to wandering around this city.
               set_module_setting("newest-$city",
                     $session['user']['acctid'],"cities");
            }
            set_module_pref("homecity",$city,"cities");
            if ($session['user']['age'] == 0)
               $session['user']['location']=$city;
         }
      }
      break;
   case "newday":
      if ($session['user']['race']==$race){
         raceelf_checkcity();

         $bonus = get_module_setting("bonus");
         $one = translate_inline("an");
         $two = translate_inline("two");
         $three = translate_inline("three");
         $word = $bonus==1?$one:$bonus==2?$two:$three;
         $fight = translate_inline("fight");
         $fights = translate_inline("fights");

         $args['turnstoday'] .= ", Race (elf): $bonus";
         $session['user']['turns']+=$bonus;
         $fight = translate_inline("fight");
         $fights = translate_inline("fights");
         output("`n`&Because you are an Elf, you gain `^%s extra`& forest fights for today!`n`0", $word, $bonus==1?$fight:$fights);

         output("`nYou have been blessed by the almighty four elementals!`n");
         set_module_pref("earth", 1);
         set_module_pref("wind", 1);
         set_module_pref("water", 1);
         set_module_pref("fire", 1);
      }
      break;
      
   case "fightnav-specialties":
      if ($session['user']['race'] == $race) {
         $earth = get_module_pref("earth");
         $wind= get_module_pref("wind");
         $water = get_module_pref("water");
         $fire= get_module_pref("fire");
         $script = $args['script'];
         if ($earth>=1 || $wind>=1 || $water>=1)|| $fire>=1) {
            addnav(array("Blessings`0"),"");
            }
         if ($earth>=1){
            addnav(array("`q Earth `JBlessing`7`0", 1),
                  $script."op=fight&skill=$spec&l=1", true);
            }
         if ($wind>=1){
            addnav(array("`J Wind Blessing`7`0", 1),
                  $script."op=fight&skill=$spec&l=2", true);
            }
         if ($water>=1){
            addnav(array("`lWater `JBlessing`7`0", 1),
                  $script."op=fight&skill=$spec&l=3", true);
            }
            if ($fire>=1){
            addnav(array("`4f`Qi`4r`4e `JBlessing`7`0", 1),
                  $script."op=fight&skill=$spec&l=4", true);
            }
      }
      break;
      
   case "apply-specialties":
      if ($session['user']['race'] == $race) {
         $skill = httpget('skill');
         $l = httpget('l');
         if ($skill==$spec){
            if (get_module_pref("bang") >= 1){
               switch($l){
               case 1:
                  apply_buff('hm1', array(
                     "startmsg"=>"`qYou Call Upon the spirits of earth. Out of nowhere gnomes start popping out of the floor!",
                     "name"=>"`qEarth Blessing",
                     "rounds"=>-1,
                     "minioncount"=>1,
                     "minbadguydamage"=>"round(<attack>*0.1,0);",
                     "maxbadguydamage"=>"round(<attack>*1.5,0);",
                     "expireafterfight"=>1,
                     "effectmsg"=>"`q the army of Gnomes lunges at {badguy} qith rocks`q hitting him for`^{damage}`q damage!",
                     "schema"=>"module-raceelf"
                  ));
                  set_module_pref("earth", get_module_pref("earth") - $l);
                  break;
               }
            }
            if (get_module_pref("wind") >= 1){
               switch($l){
               case 2:
                  apply_buff('hm2', array(
                     "startmsg"=>"`JYou call upon the spirits of the Wind. And a massive number of sylphs appears  !",
                     "name"=>"`JWind Blessing",
                     "rounds"=>e_rand(1,5),
                     "badguyatkmod"=>0.3,
                     "badguydefmod"=>0.3,
                     "effectmsg"=>"`J {badguy} is surrounded by the sylphs that blast them with gusts of wind restricting {badguy} movement",
                     "expireafterfight"=>1,
                     "wearoff"=>"{badguy} someway somehhow blows the sylphs away and , and lunges at you!`n",
                     "schema"=>"module-raceelf"
                  ));
                  set_module_pref("wind", get_module_pref("wind") - $l);
                  break;
               }
            }
            if (get_module_pref("water") >= 1){
               switch($l){
               case 3:
                  apply_buff('hm3', array(
                     "startmsg"=>"`LYou call upon the spirits of water and two Undines are summoned by your side",
                     "name"=>"`L Water Blessing",
                     "rounds"=>-1,
                     "regen"=>$session['user']['level']
                     "effectmsg"=>"`LThe Undines start singing in choir moving water around you that heals you for `^{damage} `Lpointd`n",                     
                     "expireafterfight"=>1,
                     "schema"=>"module-raceelf"
                  ));
                  set_module_pref("water", get_module_pref("water") - $l);
                  break;
                  }
            }
            if (get_module_pref("fire") >= 1){
               switch($l){
               case 3:
                  apply_buff('hm4', array(
                     "startmsg"=>"`LYou call upon the spirits of fire and a Huge Salamander appears by your side",
                     "name"=>"`$ Fire Blessing",
                     "rounds"=>1,
                     "minion"=>1,
                     "minbadguydamage"=>"round(<attack>*10.0,0);",
                     "maxbadguydamage"=>"round(<attack>*20.0,0);",
                     "mingoodguydamage"=>"round(<attack>*0.2,0);"
                     "maxgoodguydamage"=>"round(<attack>*0.2,0);"
                     "wearoff"=>"The Salamander disapears in a burst of flanes hitting you with a little flame",
                     "effectmsg"=>"`4The Salamander spits a huge fireball at {badguy} that roasts him completely for`^{damage} `Lpointsd`n",                     
                     "expireafterfight"=>1,
                     "schema"=>"module-raceelf"
                  ));
                  set_module_pref("fire", get_module_pref("fire") - $l);
                  break;
               }
            }
         }
      }
break;
   case "validforestloc":
   case "validlocation":
      if (is_module_active("cities"))
         $args[$city]="village-$race";
      break;
   case "moderate":
      if (is_module_active("cities")) {
         tlschema("commentary");
         $args["village-$race"]=sprintf_translate("City of %s", $city);
         tlschema();
      }
      break;
   case "travel":
      $capital = getsetting("villagename", LOCATION_FIELDS);
      $hotkey = substr($city, 0, 1);
      $ccity = urlencode($city);
      tlschema("module-cities");
      if ($session['user']['location']==$capital){
         addnav("Safer Travel");
         addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity");
      }elseif ($session['user']['location']!=$city){
         addnav("More Dangerous Travel");
         addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&d=1");
      }
      if ($session['user']['superuser'] & SU_EDIT_USERS){
         addnav("Superuser");
         addnav(array("%s?Go to %s", $hotkey, $city),"runmodule.php?module=cities&op=travel&city=$ccity&su=1");
      }
      tlschema();
      break;
   case "villagetext":
      raceelf_checkcity();
      if ($session['user']['location'] == $city){
         $args['text']=array("`&`c`b%s, City of Magic`b`c`n`7You are standing in the heart of %s.  Though called a city, this forest is feeled with magical creaturs that live in awkard deformed trees filled with magical creatures surrounded by auras .  The city is protected by the four elementals that cast a barrier around everything the city has a thrill leading to a Dark Forest where dark creatures reside  Some residents are engaged in conversation around the Huge tree with Crystalized leafs in the village square.`n", $city, $city);
         $args['schemas']['text'] = "module-raceelf";
         $args['clock']="`n`7The great Tree in the Center of the city says `&%s`7.`n";
         $args['schemas']['clock'] = "module-raceelf";
         if (is_module_active("calendar")) {
            $args['calendar'] = "`n`7A smalle Rock next to it reads `&%s`7, `&%s %s %s`7.`n";
            $args['schemas']['calendar'] = "module-raceelf";
         }
         $args['title']=array("%s, Magical Citys of Elfs", $city);
         $args['schemas']['title'] = "module-raceelf";
         $args['sayline']="says";
         $args['schemas']['sayline'] = "module-raceelf";
         $args['talk']="`n`&Nearby some villagers talk:`n";
         $args['schemas']['talk'] = "module-raceelf";
         $new = get_module_setting("newest-$city", "cities");
         if ($new != 0) {
            $sql =  "SELECT name FROM " . db_prefix("accounts") .
               " WHERE acctid='$new'";
            $result = db_query_cached($sql, "newest-$city");
            $row = db_fetch_assoc($result);
            $args['newestplayer'] = $row['name'];
            $args['newestid']=$new;
         } else {
            $args['newestplayer'] = $new;
            $args['newestid']="";
         }
         if ($new == $session['user']['acctid']) {
            $args['newest']="`n`7As you wander your new home, you feel your jaw dropping at the wonders around you.";
         } else {
            $args['newest']="`n`7Wandering the village, jaw agape, is `&%s`7.";
         }
         $args['schemas']['newest'] = "module-raceelf";
         $args['section']="village-$race";
         $args['gatenav']="Village Gates";
         $args['schemas']['gatenav'] = "module-raceelf";
      }
      break;

   }
   return $args;
}

function raceelf_checkcity(){
   global $session;
   $race="Elf";
   $city=get_module_setting("villagename");

   if ($session['user']['race']==$race && is_module_active("cities")){
      //if they're this race and their home city isn't right, set it up.
      if (get_module_pref("homecity","cities")!=$city){ //home city is wrong
         set_module_pref("homecity",$city,"cities");
      }
   }
   return true;
}

function raceelf_run(){

}
?>
« Last Edit: June 23, 2011, 05:31:54 PM by ChesireCat » Logged

Kira
Militia
**
Offline Offline

Posts: 22


View Profile
« Reply #5 on: June 23, 2011, 02:57:58 PM »

  I'm not really into 1.x.x code but if I were you I'd go back through the changes made and check for mistakes like the ones mentioned above or conflicting names of things since it is a core module that's just more or less "hacked" to be slightly different.
Logged

I like 0.9.7+jt
ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« Reply #6 on: June 23, 2011, 04:51:36 PM »

I've been the last few hours comparing the code to the original and cant find nothing wrong someone help please
Logged

CavemanJoe
Mod God
*****
Offline Offline

Posts: 555


Opener of WormCans


View Profile WWW
« Reply #7 on: June 23, 2011, 05:13:12 PM »

Top of the file, change:
Code:
function function raceelf_getmoduleinfo(){
to:
Code:
function raceelf_getmoduleinfo(){
Logged

ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« Reply #8 on: June 23, 2011, 05:21:19 PM »

oh i forgot to update what i already did so that code was the first one
Now i got this error here

Parse error: syntax error, unexpected T_BOOLEAN_OR in /home/talesoft/public_html/modules/raceelf.php on line 158
« Last Edit: June 23, 2011, 05:36:18 PM by ChesireCat » Logged

CavemanJoe
Mod God
*****
Offline Offline

Posts: 555


Opener of WormCans


View Profile WWW
« Reply #9 on: June 23, 2011, 05:37:45 PM »

Check line 158 - you're missing a bracket.
Logged

Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #10 on: June 23, 2011, 05:42:03 PM »

And do yourself a big favour -- get a syntax-colouring editor for your PHP.  It would have helped you pick up many of these errors without needing to wait for a response on this forum.
Logged
ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« Reply #11 on: June 23, 2011, 05:47:27 PM »

I am using crimson editor it does color

and even though i have this account for like 4 years this is the first time I'm actually looking into the code and not just looking for output tags
Code:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/talesoft/public_html/modules/raceelf.php on line 228


Quote
                     "effectmsg"=>"`LThe Undines start singing in choir moving water around you that heals you for `^{damage} `Lpoints",
the line in question
« Last Edit: June 23, 2011, 05:50:36 PM by ChesireCat » Logged

Kira
Militia
**
Offline Offline

Posts: 22


View Profile
« Reply #12 on: June 23, 2011, 06:09:17 PM »

I am using crimson editor it does color

and even though i have this account for like 4 years this is the first time I'm actually looking into the code and not just looking for output tags
Code:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/talesoft/public_html/modules/raceelf.php on line 228


Quote
                     "effectmsg"=>"`LThe Undines start singing in choir moving water around you that heals you for `^{damage} `Lpoints",
the line in question

Anytime you see the words parse, syntax, or unexpected it means something you wrote in php is not closed or used properly.

If you see something like {empty} it means there's a value missing somewhere and what should've been returned as a value is coming back as nothing.
Logged

I like 0.9.7+jt
ChesireCat
Militia
**
Offline Offline

Posts: 87


View Profile WWW
« Reply #13 on: June 23, 2011, 06:25:44 PM »

"party" i did it Thanks alot Kira and CMJ ^^

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
30 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search