I have a small question
#1

What is the difference between

playerid and i

Example:

pawn Код:
SetPlayerInterior(i, 0);
And...

pawn Код:
SetPlayerInterior(playerid, 0);
I know it's simple, they both do the same thing, but what does it change?
Reply
#2

"i" is a variable in loop (for) so, its affect all player i think.
Reply
#3

Yes, but if you do for loop with any other word or a sign it will work just fine...
eg.
pawn Код:
for(new e = 0; e < MAX_PLAYERS; e++)
{
SetPlayerInterior(e, 0);
}
So this will set all the players interior to 0.
Reply
#4

pawn Код:
SetPlayerInterior(i, 0);
Will not work unless you define "i".

"i", is usually used with a loop, for example:
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
    if(!IsPlayerConnected(i)) continue;
    SetPlayerInterior(i, 0);
}
Let me explain, this is a loop, it loops through the maximum amount of players your server can hold, and for every person that is connected it will set there interior to 0.

I used "continue", just over preference, "continue", along with putting "!" before the function, checks if the player is not online(note that's why I put a "!" before the function), and then will continue with the loop.

playerid returns the ID of the player executing the function, where as "i", as shown in the loop above returns the ID of everybody connected.
Reply
#5

Oh alright, I understand now..

Thanks all!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)