Array Check - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Array Check (
/showthread.php?tid=165733)
Array Check -
Nonameman - 05.08.2010
Hey!
I have an array full with checkpoints, how can I check if I enter a CP that is in the array?
(Without a 'for cycle', because it's under OnPlayerEnterDynamicCP and may crash the server if sb do it again and again in a short period of time..)
Thanks
Nonameman
Re: Array Check -
PotH3Ad - 06.08.2010
Here are some examples, hope they help you...
pawn Код:
new ExCPS[6];
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
for(new x=0; x<sizeof(ExCPS)-1, x++)
{
if(checkpointid == ExCPS[x])
{
new str[40];
format(str, sizeof(str), "You entered CP ID %d", x);
SendClientMessage(playerid, 0xFAFAFAFA, str);
break;
}
}
return 1;
}
pawn Код:
new ExCPS[6];
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == ExCPS[0])
{
SendClientMessage(playerid, 0xFAFAFAFA, "You entered a checkpoint");
}
else if(checkpointid == ExCPS[1])
{
SendClientMessage(playerid, 0xFAFAFAFA, "You entered a checkpoint");
}
else if(checkpointid == ExCPS[2])
{
SendClientMessage(playerid, 0xFAFAFAFA, "You entered a checkpoint");
}
else if(checkpointid == ExCPS[3])
{
SendClientMessage(playerid, 0xFAFAFAFA, "You entered a checkpoint");
}
//And so on...
return 1;
}
Re: Array Check -
Nonameman - 06.08.2010
Okey, Thanks.
So no other way to do it
Re: Array Check -
PotH3Ad - 06.08.2010
No problem. Not that I can think of at least. :P