06.10.2014, 02:24
(
Последний раз редактировалось lnasc256; 06.10.2014 в 03:17.
Причина: operador
)
Eu gostaria de saber se isso que eu fiz poderia otimizar loops que vгo a todos os players online
Й assim: se eu tenho 5 players online que as IDs vгo de 0 a 4, ele vai fazer o loop sу de 0 a 4
Exemplo de uso:
PHP код:
//lnasc256
new max_players;
public OnPlayerConnect(playerid){
if(playerid>max_players)
max_players=playerid;
return 1;
}
public OnPlayerDisconnect(playerid,reason){
if(max_players&&playerid==max_players){
new current_max_player;
for(new i;i!=GetMaxPlayers();++i)
if(IsPlayerConnected(i)&&max_players>i>current_max_player)max_players=i;
}return 1;
}
public OnGameModeExit(){
max_players=0;
return 1;
}
Exemplo de uso:
PHP код:
forward SendMessageToAllEx(color,string[]);
public SendMessageToAllEx(color,string[]){
for(new i;i<=max_players;++i)
if(IsPlayerConnected(i))
SendClientMessage(i,color,string);
return 1;
}