Loop & Enumerators - 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: Loop & Enumerators (
/showthread.php?tid=468168)
Loop & Enumerators - Patrick - 06.10.2013
Hello guys, I'm trying to use loop to shorten my code so it would be much more shorter and it would save some space, I'm try to loop my enumarator Robbing, check the code below for more information
My Enum
pawn Код:
enum robbingshop
{
RobbingTatoo
}
new Robbing[MAX_PLAYERS][robbingshop];
OnPlayerLeaveDynamicCP Callback
pawn Код:
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
for(new i = 0; i < sizeof(rCheckpoints); i++)
{
if(checkpointid == rCheckpoints[i])
{
for(new s = 0; s < sizeof(Robbing); s++)
{
if(Robbing[playerid][s] >= 1)
{
SendClientMessage(playerid, COLOR_DARKYELLOW, "[ROBBERY FAILED]"COL_WHITE": You left the checkpoint while robbing the store!");
Robbing[playerid][s] =0;
}
}
}
}
return 1;
}
Warning/Error Code
pawn Код:
: warning 213: tag mismatch
Re: Loop & Enumerators -
DanishHaq - 06.10.2013
Which line are you getting this error on?
Re: Loop & Enumerators - Patrick - 06.10.2013
This Line
pawn Код:
if(Robbing[playerid][s] >= 1)
And
This Line
Re: Loop & Enumerators -
Dragonsaurus - 06.10.2013
sizeof(robbingshop)
Or
_:robbingshop
At the for(blabla) loop, replace the sizeof(Robbing) with one of these.
Also at the error lines replace the "s" with "robbingshop : s"
Edit: Forget about sizeof, use _:robbingshop and the above line's advice may work.
Edit2: You are welcome
Re: Loop & Enumerators - Patrick - 06.10.2013
Quote:
Originally Posted by Dragonsaurus
sizeof(robbingshop)
Or
_:robbingshop
At the for(blabla) loop, replace the sizeof(Robbing) with one of these.
Also at the error lines replace the "s" with "robbingshop : s"
Edit: Forget about sizeof, use _:robbingshop and the above line's advice may work.
|
Cheers, bro. much appreciated, I just learnt something new :P