Command not working?
#1

Hello SA-MP Community, Today i just made a ZCMD command, it doesn't work for some reason, when i do /crashplayer it says you are not logged in rcon and that's good because im not logged in,
when i log in it says Usage : /crashplayer <playerid> and that's good

But when i try to crash myself, it says player not found. and when i try other player IDS it says Player not found also? what is the problem! Please help!

pawn Код:
CMD:crashplayer(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_RED, "You need to be an admin to use this command!");
    new targetid;
    if(sscanf( params, "u", targetid))
        return SendClientMessage(playerid, COLOR_RED, "Usage: /crashplayer <playerid>");
    else if( playerid == targetid)
        return SendClientMessage(playerid, COLOR_RED, "You can't crash yourself!");
    else if(targetid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "Player not found.");
    new
        pName[24],
        str[128];
    GetPlayerName(targetid, pName, 24);
    format(str, 128, "You crashed %s", pName);
    SendClientMessage(playerid, COLOR_ORANGE, str);
    CrashClient(targetid);
    return 1;
}
The stock CrashClient:

pawn Код:
stock CrashClient(playerid)
{
    if(!IsPlayerConnected(playerid)) return false;
    return GameTextForPlayer(playerid, "~~~~~~~~~~~~~~~~~", 1000, 5);
}
Reply
#2

hello, Try the following

PHP код:
CMD:crashplayer(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return  SendClientMessage(playeridCOLOR_RED"You need to be an admin to use this command!");
    
    new 
targetid;
    if(
sscanfparams"u"targetid)) SendClientMessage(playeridCOLOR_RED"Usage: /crashplayer <playerid>");
    else if( 
playerid == targetidSendClientMessage(playeridCOLOR_RED"You can't crash yourself!");
    else if(
targetid == INVALID_PLAYER_ID)   SendClientMessage(playeridCOLOR_RED"Player not found.");
    new
        
pName[24],
        
str[128];
    
GetPlayerName(targetidpName24);
    
format(str128"You crashed %s"pName);
    
SendClientMessage(playeridCOLOR_ORANGEstr);
    
CrashClient(targetid);
    return 
1;

Reply
#3

pawn Код:
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,"(...)");
Reply
#4

Quote:
Originally Posted by yusei
Посмотреть сообщение
hello, Try the following

PHP код:
CMD:crashplayer(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return  SendClientMessage(playeridCOLOR_RED"You need to be an admin to use this command!");
    
    new 
targetid;
    if(
sscanfparams"u"targetid)) SendClientMessage(playeridCOLOR_RED"Usage: /crashplayer <playerid>");
    else if( 
playerid == targetidSendClientMessage(playeridCOLOR_RED"You can't crash yourself!");
    else if(
targetid == INVALID_PLAYER_ID)   SendClientMessage(playeridCOLOR_RED"Player not found.");
    new
        
pName[24],
        
str[128];
    
GetPlayerName(targetidpName24);
    
format(str128"You crashed %s"pName);
    
SendClientMessage(playeridCOLOR_ORANGEstr);
    
CrashClient(targetid);
    return 
1;

Now when i log in rcon and try /crashplayer, it crashes me without typing any ID!

Edit : Adtyza's code is not working, it says Player not found when i try to crash myself, and when i try to crash my friend it says player not found too?

here is my code now :

pawn Код:
CMD:crashplayer(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_RED, "You need to be an admin to use this command!");
    new targetid;
    if(sscanf( params, "u", targetid))
        return SendClientMessage(playerid, COLOR_RED, "Usage: /crashplayer <playerid>");
    else if( playerid == targetid)
        return SendClientMessage(playerid, COLOR_RED, "You can't crash yourself!");
    else if(!IsPlayerConnected(targetid))
        return SendClientMessage(playerid, COLOR_RED,"Player not found!");
    new
        pName[24],
        str[128];
    GetPlayerName(targetid, pName, 24);
    format(str, 128, "You crashed %s", pName);
    SendClientMessage(playerid, COLOR_ORANGE, str);
    CrashClient(targetid);
    return 1;
}
Reply
#5

Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
Now when i log in rcon and try /crashplayer, it crashes me without typing any ID!
Because he didn't put return so the command kept going.
Try replacing what you have with what i gave you.. never tried INVALID_PLAYER_ID and also i saw many people have problems with INVALID_PLAYER_ID or had problems..
Reply
#6

Quote:

Now when i log in rcon and try /crashplayer, it crashes me without typing any ID!

Looool

this 'is the best WAY

PHP код:
CMD:crashplayer(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return  SendClientMessage(playeridCOLOR_RED"You need to be an admin to use this command!");
    new 
targetid;
    if(
sscanfparams"u"targetid))
    {
        
SendClientMessage(playeridCOLOR_RED"Usage: /crashplayer <playerid>");
        return 
true;
    }
    else if( 
playerid == targetid)
    {
        
SendClientMessage(playeridCOLOR_RED"You can't crash yourself!");
        return 
true;
    }
    else if(!
IsPlayerConnected(targetid))
    {
        
SendClientMessage(playeridCOLOR_RED"Player not found.");
        return 
true;
    }
    new
        
pName[24],
        
str[128];
    
GetPlayerName(targetidpName24);
    
format(str128"You crashed %s"pName);
    
SendClientMessage(playeridCOLOR_ORANGEstr);
    
CrashClient(targetid);
    return 
1;

Reply
#7

Quote:
Originally Posted by psychopathe
Посмотреть сообщение
Looool

this 'is the best WAY

PHP код:
CMD:crashplayer(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) return  SendClientMessage(playeridCOLOR_RED"You need to be an admin to use this command!");
    new 
targetid;
    if(
sscanfparams"u"targetid))
    {
        
SendClientMessage(playeridCOLOR_RED"Usage: /crashplayer <playerid>");
        return 
true;
    }
    else if( 
playerid == targetid)
    {
        
SendClientMessage(playeridCOLOR_RED"You can't crash yourself!");
        return 
true;
    }
    else if(!
IsPlayerConnected(targetid))
    {
        
SendClientMessage(playeridCOLOR_RED"Player not found.");
        return 
true;
    }
    new
        
pName[24],
        
str[128];
    
GetPlayerName(targetidpName24);
    
format(str128"You crashed %s"pName);
    
SendClientMessage(playeridCOLOR_ORANGEstr);
    
CrashClient(targetid);
    return 
1;

When i try this code it says Player not found. in my ID and the other players ID..
Reply
#8

Try this if this works. i hope it does

pawn Код:
CMD:crashplayer(playerid, params[])
{
    new
        pName[24],
        str[128],
        targetid
    ;
    GetPlayerName(targetid, pName, 24);
    //
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_RED, "You need to be an admin to use this command!");
    if(sscanf( params, "u", targetid))
        return SendClientMessage(playerid, COLOR_RED, "Usage: /crashplayer <playerid>");
    if( playerid == targetid)
        return SendClientMessage(playerid, COLOR_RED, "You can't crash yourself!");
    if(targetid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "Player not found.");
    format(str, sizeof(str), "You crashed %s", pName);
    SendClientMessage(playerid, COLOR_ORANGE, str);
    if(IsPlayerConnected(player1) && targetid!= INVALID_PLAYER_ID)
    {
        GetPlayerPos(player1,X,Y,Z);
        new CObject = CreatePlayerObject(targetid,888888889999999,X,Y,Z,0,0,0);
        DestroyObject(CObject );
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by pds2012
Посмотреть сообщение
Try this if this works. i hope it does

pawn Код:
CMD:crashplayer(playerid, params[])
{
    new
        pName[24],
        str[128],
        targetid
    ;
    GetPlayerName(targetid, pName, 24);
    //
    if(!IsPlayerAdmin(playerid))
        return SendClientMessage(playerid, COLOR_RED, "You need to be an admin to use this command!");
    if(sscanf( params, "u", targetid))
        return SendClientMessage(playerid, COLOR_RED, "Usage: /crashplayer <playerid>");
    if( playerid == targetid)
        return SendClientMessage(playerid, COLOR_RED, "You can't crash yourself!");
    if(targetid == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "Player not found.");
    format(str, sizeof(str), "You crashed %s", pName);
    SendClientMessage(playerid, COLOR_ORANGE, str);
    //crashes the player || thanks Jafet_Macario for this
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
    GameTextForPlayer(targetid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
    return 1;
}
Didn't work it says player not found.
Reply
#10

Try my command again. i edited it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)