Help with /kill command !
#1

Hi everyone,

I've made this simple command:
pawn Код:
if(strcmp(cmdtext,"/kill",true)==0)
{
if(DM[playerid] == 1)
{
SendClientMessage(playerid, RED, "ERROR: You're in DM.");
return 0;
}
if(AFK[playerid] == 1)
{
SendClientMessage(playerid, RED, "ERROR: You're AFK.");
return 0;
}
SetPlayerHealth(playerid,0.0);
return 1;
}
But, if I'm in DM or AFK I can use /kill without any problems !
I hope you will help me
Reply
#2

Try this:

pawn Код:
if(strcmp(cmd, "/kill" true) == 0)
    {
        if(DM[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_RED, " ERROR: This command cannot be used inside the DM area!");
            return 1;
        }
        if(AFK[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_RED, " ERROR: You cant use this command while being AFK!");
            return 1;
        }
        else
        {
            SetPlayerHealth(playerid, 0);
            return 1;
            }
        }
Let me know if it works or not.
Reply
#3

Well, are you sure there isn't another /kill command somewhere in any of the scripts running on the server? Are you also sure that those variables are actually set to one for the playerid when they are actually in a DM or AFK?

Also you could do with slightly cleaner code plus indentation:

pawn Код:
if(strcmp(cmdtext,"/kill",true) == 0)
{
    if(DM[playerid] == 1) return SendClientMessage(playerid, RED, "ERROR: You're in DM.");
    if(AFK[playerid] == 1) return SendClientMessage(playerid, RED, "ERROR: You're AFK.");
    SetPlayerHealth(playerid,0.0);
    return 1;
}
Anyway you're going to have to check those things I mentioned. As the command should work as intended the way it is, assuming everything else in the script is up to scratch.
Reply
#4

My code works, also your one works, I've found the /kill cmd in admin FS
Thanks very Much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)