PDA

View Full Version : Error with some admins commands


SalmaN97
28/04/2015, 04:45 PM
Hello i am making some admin commands for my script when i try them ingame nothing happens:

CMD:slapall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new Float:x,Float:y,Float:z;
new string[100];
PlayerPlaySound(i,1190,0.0,0.0,0.0);
GetPlayerPos(i,x,y,z);
SetPlayerPos(i,x,y,z+4);
format(string,sizeof(string),"Administrator %s (%d) has slapped all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:explodeall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new Float:x,Float:y,Float:z;
new string[100];
GetPlayerPos(i,x,y,z);
CreateExplosion(x,y,z,6,50.0);
format(string,sizeof(string),"Administrator %s (%d) has exploded all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:killall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
SetPlayerHealth(i,0);
SendClientMessage(playerid, -1,"You have successfuly killed all players");
}
}
}
return 1;
}

CMD:muteall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new string[100];
Mute[i] = 1;
format(string,sizeof(string),"Administrator %s (%d) has muted all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:unmuteall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new string[100];
Mute[i] = 0;
format(string,sizeof(string),"Administrator %s (%d) has unmuted all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:freezeall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new string[100];
TogglePlayerControllable(i,0);
format(string,sizeof(string),"Administrator %s (%d) has frozen all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:unfreezeall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new string[100];
TogglePlayerControllable(i,1);
format(string,sizeof(string),"Administrator %s (%d) has unfrozen all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:jailall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new string[100];
Jailed[i] = 1;
SetPlayerPos(i, 197.6661,173.8179,1003.0234);
SetPlayerInterior(i, 3);
format(string,sizeof(string),"Administrator %s (%d) has jailed all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:unjailall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new string[100];
Jailed[i] = 0;
SpawnPlayer(i);
format(string,sizeof(string),"Administrator %s (%d) has unjailed all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

CMD:getall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i : Player)
{
if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerInterior(i, GetPlayerInterior(playerid));
SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(playerid));
SetPlayerPos(i, x+2, y, z);
}
}
}
return 1;
}

P.S. all commands works when i try them normaly like /slap /explode /jail etc... all command same but the different is that i added foreach in /slapall /explodeall etc... ones

$Marco$
28/04/2015, 04:47 PM
I never used foreach but I guess you need to change:
foreach(new i : Player)

to

foreach(new i : playerid)

Kimossab
28/04/2015, 04:54 PM
why do you have this:

if(!PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
{

inside the foreach loop? with that those cmds will only affect rcon admins that are not admins ig if you know what I mean...

Shaktimaan
28/04/2015, 04:56 PM
CMD:slapall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && !IsPlayerAdmin(i))
{
new Float:x,Float:y,Float:z;
new string[100];
PlayerPlaySound(i,1190,0.0,0.0,0.0);
GetPlayerPos(i,x,y,z);
SetPlayerPos(i,x,y,z+4);
format(string,sizeof(string),"Administrator %s (%d) has slapped all players.",GetPlayerNameEx(playerid), playerid);
SendClientMessageToAll( -1,string);
}
}
}
return 1;
}

place that red thing in front of that in your all codes. And let see what happens.