how to fix this cmd its generating lots of errors
#1

hi guys i have this cmd to crash a player but i need to fix it its not working right can someone help me please here is the code:
pawn Код:
CMD:Crash(playerid, params[])
{
    new string[128];
    if(pInfo[playerid][AdminLevel] >=4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED,"ERROR: You need to be administrator to use this command!");
    {
        if(sscanf(params, "us[128]", params[0], params[1])) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Crash [playerid] [reason]");
       
        if ( IsPlayerConnected( params[ 0 ] ) && params[ 0 ] != INVALID_PLAYER_ID && params[ 0 ] != playerid )
        {
            if(!strlen(params[1]))
            {
                            format(string, sizeof(string),"%s Has been crashed by Admin %s [no reason given]!",PlayerName2(params[0]),PlayerName2(playerid));
                            SendClientMessageToAll(ABLUE, string);
                            GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
                    GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
                    GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
                    GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
                    GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
                    GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
                    GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
            } else {
           
                format(string, sizeof(string),"%s has been crashed by Admin %s [Reason: %s]", PlayerName2(params[0]), PlayerName2(playerid), params[1]);
                SendClientMessageToAll(ABLUE, string);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
                GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
            } else {

                SendClientMessage(playerid, RED,"ERROR Player Specified Not Online!");
            }
            return 1;
        }
        return 1;
    }
}
Errors:
pawn Код:
C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(266) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
i dont know what the problem is line 266 is:
pawn Код:
) else (
can someone plz help me
Reply
#2

PHP код:
CMD:Crash(playeridparams[])
{
    new 
string[128];
    if(
pInfo[playerid][AdminLevel] >=|| !IsPlayerAdmin(playerid)) return SendClientMessage(playeridRED,"ERROR: You need to be administrator to use this command!");
    {
        if(
sscanf(params"us[128]"params[0], params[1])) return SendClientMessage(playeridRED,"USAGE: {FFFF00}/Crash [playerid] [reason]");
       
        if ( 
IsPlayerConnectedparams] ) && params] != INVALID_PLAYER_ID && params] != playerid )
        {
            if(!
strlen(params[1]))
            {
                            
format(stringsizeof(string),"%s Has been crashed by Admin %s [no reason given]!",PlayerName2(params[0]),PlayerName2(playerid));
                            
SendClientMessageToAll(ABLUEstring);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"10000);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"20001);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"30002);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"40003);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"50004);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"60005);
                            
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"70006);
                            } 
                            else
                            {
           
                
format(stringsizeof(string),"%s has been crashed by Admin %s [Reason: %s]"PlayerName2(params[0]), PlayerName2(playerid), params[1]);
                
SendClientMessageToAll(ABLUEstring);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"10000);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"20001);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"30002);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"40003);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"50004);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"60005);
                
GameTextForPlayer(params[0], "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/"70006);
                } 
                else 
                {
                
SendClientMessage(playeridRED,"ERROR Player Specified Not Online!");
            }
            return 
1;
        }
        return 
1;
    }

Try it like this
Reply
#3

same error
Reply
#4

pawn Код:
CMD:Crash(playerid, params[])
{
    new string[128], id, reason[50];
    if(pInfo[playerid][AdminLevel] < 4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED,"ERROR: You need to be administrator to use this command!");
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Crash [playerid] [reason]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
    if(id == playerid) return SendClientMessage(playerid, RED,"You can't crash yourself"); // Optional
    if(!strlen(reason))
    {
        format(string, sizeof(string),"%s Has been crashed by Admin %s [no reason given]!",PlayerName2(id),PlayerName2(playerid));
        SendClientMessageToAll(ABLUE, string);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
    }
    else
    {        
        format(string, sizeof(string),"%s has been crashed by Admin %s [Reason: %s]", PlayerName2(id), PlayerName2(playerid), reason);
        SendClientMessageToAll(ABLUE, string);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
        GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
    }
    return 1;
}
Reply
#5

thx it works fine now
Reply
#6

Everyone in his right mind would see that
pawn Код:
if{}
else{}
else{}
wouldn't work ...

Other than that, use variables! Using params[0] makes your code look messy.
Reply
#7

its fixed now anyway Vince lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)