10.03.2009, 01:27
i am making it so on my server every half second every player gets $2 but whats the script to give all players money?
i have checked wiki too, it is not there.
i have checked wiki too, it is not there.
SetTimer("GiveAllCash", 500, 1);
forward GiveAllCash(); public GiveAllCash() { for(new i; i<MAX_PLAYERS; i++) { GivePlayerMoney(i, 2); } }
#define MAX_PLAYERS (200) |
for(new i; i<200; i++)
forward GiveAllCash(amount); public GiveAllCash(amount) { for(new i; i<MAX_PLAYERS; i++) { GivePlayerMoney(i, amount); } }
Originally Posted by Drift_04
oh i see!!! MAX PLAYERS = all players huh?? thanks!
and yeah i am using a loop. =P i just didnt know how to use max players. thanks a lot!!!! =) |
Originally Posted by =>Sandra<=
Use a loop:
//OnGameModeInit() Код:
SetTimer("GiveAllCash", 500, 1); Код:
forward GiveAllCash(); public GiveAllCash() { for(new i; i<MAX_PLAYERS; i++) { GivePlayerMoney(i, 2); } } |
SetTimer("GiveAllCash", 2000, 1);
Originally Posted by saiberfun
Код:
SetTimer("GiveAllCash", 2000, 1); 2000 = 2000milliseconds = 2secs |
every half second every player gets $2 |
Originally Posted by JeNkStAX
Check if they are connected first, Try to give cash to 200 non existant players mightcause a problem
|
Originally Posted by ******
Kick, and in fact all player functions, has an internal IsPlayerConnected check, so if you're only running one function in a loop it's more efficient to NOT call IsPlayerConnected and just call the function direct. If the player is connected you've saved a function call, if they're not connected you've not lost anything as the only code that's been executed is the same as if you called IsPlayerConnected.
|