help else.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help else.. (
/showthread.php?tid=495772)
help else.. -
Slicebook - 18.02.2014
Help please!
gamemodes\modRPG.pwn(9450) : error 029: invalid expression, assumed zero
gamemodes\modRPG.pwn(9451) : error 029: invalid expression, assumed zero
Код:
new string[75];
new Float:pancel;
GetPlayerArmour(damagedid, pancel);
if(PlayerInfo[damagedid][pSWATTag] != 0 && pancel > 50.0) return 1;
Msg(damagedid,"Meglőttek!");
new loves = random(2)+1;
new lovesname[20];
if(loves == 1) { lovesname = "gyomrбba"; }
else { lovesname = "mбjбba"; }
else { lovesname ="tьdejйbe"; } <<<error
else { lovesname ="beleibe"; } <<<error
format(string, sizeof(string), "*Valaki golyуt kapott a %s.", lovesname);
ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
Re: help else.. -
Babul - 18.02.2014
there are two "else"'s too much, the if-conditional accepts one "else" only. which values are assigned to the variable loves? if its ranging from 1 to 4, then you can use a switch/case, if its a wider range, then you need to add the exact condition. here's an example for the if / else if / else if / else:
Код:
if(loves == 1) { lovesname = "gyomrбba"; }
else if (loves == 2) { lovesname = "mбjбba"; } //on both of those lines...
else if (loves == 3) { lovesname ="tьdejйbe"; } //...the exact conditional check is required.
else { lovesname ="beleibe"; } //here you can ommit the "if", since its the last.
you can do it like this, too:
Код:
if(loves == 1) { lovesname = "gyomrбba"; }
else if (loves >1 & loves =<10) { lovesname = "mбjбba"; } // bigger than 1 and smaller/equal to 10
else if (loves >10 & loves <51) { lovesname ="tьdejйbe"; } // bigger than 10 upto (not including) 51. so from 11 to 50
else { lovesname ="beleibe"; } // not 1, not from 2 to 10, not 11 to 50, therefore any value. it could be negative, too!
Re: help else.. -
Slicebook - 19.02.2014
thanks Babul! ++