17.01.2014, 22:38
Hello everyone, have a nice day!
Let me write something I came up today, and though I could share it, pardon if such thing is already in use and so on, but here it is.
Lets say you use /freeze cmd, usually you would use
new Freezed[MAX_PLAYERS];
and later Freezed[givenplayerid] = 1; and so on, to check if player is freezed or no.
Which would be 500 cells by default, but thing is, you will never freeze all 500 players at once, so here is my solution.
You make new Freezed[30] = { -1, ...}; where 30 is your thoughs how much players could be freezed at once, as I said you will never freeze all 500 at once, even 100 is less then 500.
and make two custom functions
And to keep it tracked at OnPlayerConnect you can add if(IsFreezed(playerid)) { SetFreezed(playerid); } so you reset a slot.
you can also use if(SetFreezed(playerid)) to check if there is any free slot.
This same method you can use for vehicles, to check some stats which won't be used for all cars, such as cargo load for truckers, or Trunk content as bikes doesn't have trunks.
Let me write something I came up today, and though I could share it, pardon if such thing is already in use and so on, but here it is.
Lets say you use /freeze cmd, usually you would use
new Freezed[MAX_PLAYERS];
and later Freezed[givenplayerid] = 1; and so on, to check if player is freezed or no.
Which would be 500 cells by default, but thing is, you will never freeze all 500 players at once, so here is my solution.
You make new Freezed[30] = { -1, ...}; where 30 is your thoughs how much players could be freezed at once, as I said you will never freeze all 500 at once, even 100 is less then 500.
and make two custom functions
pawn Код:
IsFreezed(playerid)
{
for(new i; i < sizeof(Freezed); i++)
{
if(playerid == Freezed[i]) { return 1; } // make a loop to check if player is freezed in any slot
}
return 0; // If Loop doesnt find playerid, means player was never freezed
}
SetFreezed(playerid)
{
for(new i; i < sizeof(Freezed); i++)
{
if(playerid == Freezed[i]) { Freezed[i] = -1; return 0; } //Unfreeze if playerid was ferezed and reset freeze status
else { Freezed[i] = playerid; return 1; } // Else set freezed
}
return 0;
}
you can also use if(SetFreezed(playerid)) to check if there is any free slot.
This same method you can use for vehicles, to check some stats which won't be used for all cars, such as cargo load for truckers, or Trunk content as bikes doesn't have trunks.