Error with some admins commands
#1

Hello i am making some admin commands for my script when i try them ingame nothing happens:

PHP код:
CMD:slapall(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            if(!
PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
            {
                
SetPlayerHealth(i,0);
                
SendClientMessage(playerid, -1,"You have successfuly killed all players");
            }
        }
    }
    return 
1;
}
CMD:muteall(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            if(!
PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
            {
                new 
string[100];
                
Jailed[i] = 1;
                
SetPlayerPos(i197.6661,173.8179,1003.0234);
                
SetPlayerInterior(i3);
                
format(string,sizeof(string),"Administrator %s (%d) has jailed all players.",GetPlayerNameEx(playerid), playerid);
                
SendClientMessageToAll( -1,string);
            }
        }
    }
    return 
1;
}
CMD:unjailall(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
iPlayer)
        {
            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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >=|| IsPlayerAdmin(playerid))
    {
        foreach(new 
Player)
        {
            if(!
PlayerInfo[i][pAdmin] && IsPlayerAdmin(i))
            {
                new 
Float:x,Float:y,Float:z;
                
GetPlayerPos(playerid,x,y,z);
                
SetPlayerInterior(iGetPlayerInterior(playerid));
                
SetPlayerVirtualWorld(iGetPlayerVirtualWorld(playerid));
                
SetPlayerPos(ix+2yz);
            }
        }
    }
    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
Reply
#2

I never used foreach but I guess you need to change:
foreach(new i : Player)

to

foreach(new i : playerid)
Reply
#3

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...
Reply
#4

CMDlapall(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4 || IsPlayerAdmin(playerid))
{
foreach(new i: Player)
{
if(!PlayerInfo[i][pAdmin] && !IsPlayerAdmin(i))
{
new Float,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.
Reply


Forum Jump:


Users browsing this thread: