Question About Loop
#1

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.
}
Reply
#2

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.
Reply
#3

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
Reply
#4

What the hell are you trying to do with
pawn Код:
robbingshop:s
?

Also, the break there will only stop in the first iterator. It should be after the SendClientMessage.
Reply
#5

Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
What the hell are you trying to do with
pawn Код:
robbingshop:s
?

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.
Reply
#6

I bumped, because I'm concered about it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)