Question About Loop - 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: Question About Loop (
/showthread.php?tid=468460)
Question About Loop - Patrick - 08.10.2013
Hello guys, I'm currently developing a Cops and Robbers server which is located in San Fierro,
I'm currently making a robbery system I'm just going to ask if this method will freeze/lag the server? I know this is the shortest method,
but someone it can cause lag, so that's why I will ask you guys if this method will lag the server if there's about 15-20 players daily.
pawn Код:
for(new i = 0; i < sizeof(rCheckpoints); i++)
{
if(checkpointid == rCheckpoints[i])
{
for(new s; robbingshop:s < robbingshop; s++)
{
if(Robbing[playerid][robbingshop:s] >= 1)
{
SendClientMessage(playerid, -1, "Robbery Failed: You left the checkpoint while robbing a shop");
}
}
}
break; //making sure the loop is stopped.
}
Re: Question About Loop -
Misiur - 08.10.2013
First of all. Break on first loop iteration makes no sense. Did you mean to put it in the "if" conditional? You can put the break inside your inner conditional as well - one message per player is enough. I don't know the size of your rCheckpoints, but if not all of them are enabled, you can gain a lot using y_iterate creating a custom iterator.
Re: Question About Loop - Patrick - 08.10.2013
rCheckpoints size is currently
48
robbingshop size is currently
2
I did put 'if so I could check if the player is inside that checkpoint, so when he leave the checkpoint, it will show the message, hide the textdraw and reset the robbingshop to 0
Re: Question About Loop -
-Prodigy- - 08.10.2013
What the hell are you trying to do with
?
Also, the break there will only stop in the first iterator. It should be after the SendClientMessage.
Re: Question About Loop - Patrick - 08.10.2013
Quote:
Originally Posted by -Prodigy-
What the hell are you trying to do with ?
Also, the break there will only stop in the first iterator. It should be after the SendClientMessage.
|
I fixed the break;, I already did that, I'm trying to make a simpler and shorted code instead of typing like
pawn Код:
if(checkpointid == rCheckpoints[0])
{
Robbing[playerid][RobbingTatoo] =0;
}
else if(checkpointid == rCheckpoints[1])
{
Robbing[playerid][RobbingTatoo1] =0;
}
//and so on.
Re: Question About Loop - Patrick - 09.10.2013
I bumped, because I'm concered about it.