else if(strcmp(cmdtext, "/giveallcash", true) == 0) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}"); new var, string[128]; for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { PlayerPlaySound(i,1057,0.0,0.0,0.0); GivePlayerMoney(i,var); } } format(string,sizeof(string)," Administrator \"%s\" has given all Players '$%d'."); return SendClientMessageToAll(COLOR_BLUE, string); }
else if(strcmp(cmdtext, "/kickall", true) == 0) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && (i != playerid))} { PlayerPlaySound(i,1057,0.0,0.0,0.0); Kick(i); } new string[128]; format(string,sizeof(string),"[ Administrator \"%s\" has Kicked all players. ]"); return 1; }
else if(strcmp(cmdtext, "/killall", true) == 0) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SetPlayerHealth(i, 0); } SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have killed all players"); } return 1; }
else if(strcmp(cmdtext, "/getall", true) == 0) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}"); new Float:x,Float:y,Float:z, interior = GetPlayerInterior(playerid); GetPlayerPos(playerid,x,y,z); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && (i != playerid)) PlayerPlaySound(i,1057,0.0,0.0,0.0); SetPlayerPos(i,x+(playerid/4)+1,y+(playerid/4),z); SetPlayerInterior(i,interior); } SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have got all players to your self"); new string[128]; format(string,sizeof(string)," Administrator \"%s\" has Teleported all players."); return 1; }
else if(strcmp(cmdtext, "/kickall", true) == 0) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && (i != playerid))} { PlayerPlaySound(i,1057,0.0,0.0,0.0); Kick(i); } new string[128]; format(string,sizeof(string),"[ Administrator \"%s\" has Kicked all players. ]"); return 1; }
for(new i = 0; i < GetMaxPlayers();i++)
Btw I suggest you to do loops like this
pawn Код:
|
new m = GetMaxPlayers(); for(new i = 0; i < m; i++)
That still calls a function each iteration how about.
Код:
new m = GetMaxPlayers(); for(new i = 0; i < m; i++) |
new
Float:x,
Float:y,
Float:z;
GetPlayerPos(playerid, x, y, z);
new
maxPlayerId = GetPlayerPoolSize(),
Float:angleIncrement = 360.0 / float(maxPlayerId);
static const Float:cDistance = 2.0; // distance from originating player
for(new i, Float:a = 0.0; i <= maxPlayerId; i++, a += angleIncrement)
{
if(IsPlayerConnected(i) && i != playerid)
{
SetPlayerPos
(
i,
x + (cDistance * floatsin(-a, degrees)),
y + (cDistance * floatcos(-a, degrees)),
z + 0.25
);
}
}
else if(strcmp(cmdtext, "/kickall", true) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && i != playerid)
{
PlayerPlaySound(i,1057,0.0,0.0,0.0);
Kick(i);
}
}
new string[128],pname[MAX_PLAYER_NAME+1]; GetPlayerName(playerid,pname,sizeof pname);
format(string,sizeof(string),"[ Administrator \"%s\" has Kicked all players. ]",pname);
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
return 1;
}
else if(strcmp(cmdtext, "/killall", true) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && i != playerid) { SetPlayerHealth(i, 0); }
}
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have killed all players");
return 1;
}
else if(strcmp(cmdtext, "/getall", true) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be rcon admin use /rcon login {pass}");
new Float:x,Float:y,Float:z, interior = GetPlayerInterior(playerid);
GetPlayerPos(playerid,x,y,z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) && i != playerid) {
PlayerPlaySound(i,1057,0.0,0.0,0.0);
SetPlayerPos(i,x+(playerid/4)+1,y+(playerid/4),z);
SetPlayerInterior(i,interior);
}
}
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have got all players to your self");
new string[128],pname[MAX_PLAYER_NAME+1]; GetPlayerName(playerid,pname,sizeof pname);
format(string,sizeof(string)," Administrator \"%s\" has Teleported all players.",pname);
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
return 1;
}