Showing Error Message On Using Commands
#1

There Are Some Commands In My Script That Shows The Error Message On Using Them

Ex
PHP код:
COMMAND:setarmour(playerid,params[])
{
        if(
PlayerInfo[playerid][pSpawned] == 1)
        {
        if(
PlayerInfo[playerid][pAdminLevel] > 0)
        {
        new 
TargetIDFloat:Armourstring[128];
        if(
sscanf(params,"uf"TargetIDArmour))
        {
        
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /setarmour [playerid] [Armour]");
        return 
1;
        }
        if(!
IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
        {
        
SendClientMessage(playeridCOLOR_ERROR"That Player Is Not Connected.");
        return 
1;
        }
        if(
Armour || Armour 100)
        {
        
SendClientMessage(playeridCOLOR_ERROR"Armour Can't Be Less Than 0 or More Than 100.");
        return 
1;
        }
        
SetPlayerArmour(TargetID,Armour);
        
GameTextForPlayer(TargetID,"~r~Armour Set By Admin"30003);
        
format(string,sizeof(string),"***ARMOUR: %s (%d) (ADMIN SETARMOUR) Has Been Set."PlayerInfo[TargetID][pName], TargetID);
        
SendClientMessageToAll(COLOR_ADMINstring);
        }else{
        
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command While You're Dead.");
        }
        return 
1;

When I Use This Commad I get The Error Message "You Cannot Use This Command While You're Dead"
Reply
#2

Try this.

PHP код:
COMMAND:setarmour(playerid,params[]) 

    if(
PlayerInfo[playerid][pSpawned] != 1
    { 
        if(
PlayerInfo[playerid][pAdminLevel] > 0
        { 
            new 
TargetIDFloat:Armourstring[128]; 
            if(
sscanf(params,"uf"TargetIDArmour)) 
            { 
                
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /setarmour [playerid] [Armour]"); 
            }
            return 
1
        } 

        if(!
IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID
        { 
            
SendClientMessage(playeridCOLOR_ERROR"That Player Is Not Connected."); 
            return 
1
        }     

        if(
Armour || Armour 100
        { 
            
SendClientMessage(playeridCOLOR_ERROR"Armour Can't Be Less Than 0 or More Than 100."); 
            return 
1
        } 

        
SetPlayerArmour(TargetID,Armour); 
        
GameTextForPlayer(TargetID,"~r~Armour Set By Admin"30003); 

        
format(string,sizeof(string),"***ARMOUR: %s (%d) (ADMIN SETARMOUR) Has Been Set."PlayerInfo[TargetID][pName], TargetID); 
        
SendClientMessageToAll(COLOR_ADMINstring); 
    }
    else
    { 
        
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command While You're Dead."); 
    } 
    return 
1

Reply
#3

As rappy93 said,it is a {} problem,because you are lacking of using them,try to sort them better next time,so it become easier for the script to read it.
Reply
#4

pawn Код:
COMMAND:setarmour(playerid,params[])
{
        if(PlayerInfo[playerid][pSpawned] == 1)
        {
            if(PlayerInfo[playerid][pAdminLevel] > 0)
            {
                new TargetID, Float:Armour, string[128];

                if(sscanf(params,"uf", TargetID, Armour))
                {
                SendClientMessage(playerid,COLOR_ERROR,"USAGE: /setarmour [playerid] [Armour]");
                return 1;
                }

                if(!IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
                {
                SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
                return 1;
                }

                if(Armour < 0 || Armour > 100)
                {
                SendClientMessage(playerid, COLOR_ERROR, "Armour Can't Be Less Than 0 or More Than 100.");
                return 1;
                }

                SetPlayerArmour(TargetID,Armour);
                GameTextForPlayer(TargetID,"~r~Armour Set By Admin", 3000, 3);

                format(string,sizeof(string),"***ARMOUR: %s (%d) (ADMIN SETARMOUR) Has Been Set.", PlayerInfo[TargetID][pName], TargetID);
                SendClientMessageToAll(COLOR_ADMIN, string);
            }
        }
        else{
        SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command While You're Dead.");
        }
        return 1;
}
Some bracket's is missing :P
Reply
#5

Thanks To All For Help
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)