SA-MP Forums Archive
/kill bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /kill bug (/showthread.php?tid=90329)



/kill bug - Antonio [G-RP] - 07.08.2009

I get errors on my /kill command. Line 287 is defining what that type of spawn is, so when they spawn after death it says "blah blah blah"

pawn Код:
if (strcmp(cmd, "/kill", true) == 0) //line 281
{ //line 282
if(IsPlayerConnected(playerid))//line 282
{//line 283
if (gPlayerLogged[playerid] != 0)//line 284
{//line 285
SendClientMessage(playerid, COLOR_RED, "You have fallen unconscious due to servere wounds!");//line 286
InjuredSpawn[playerid] = 1;//line 287
}//line 289
else//line 290
{ //line 291
SendClientMessage(playerid, COLOR_GRAY, "[!] You are not logged in!"); //line 292
return 1; //line 293
} //line 294
ERRORS:

Код:
C:\Users\Lachlan\Desktop\Random Pawno\AntonioRP.pwn(281) : error 010: invalid function or declaration
C:\Users\Lachlan\Desktop\Random Pawno\AntonioRP.pwn(283) : error 010: invalid function or declaration
C:\Users\Lachlan\Desktop\Random Pawno\AntonioRP.pwn(285) : error 010: invalid function or declaration
C:\Users\Lachlan\Desktop\Random Pawno\AntonioRP.pwn(290) : error 010: invalid function or declaration
C:\Users\Lachlan\Desktop\Random Pawno\AntonioRP.pwn(293) : error 010: invalid function or declaration



Re: /kill bug - Djiango - 07.08.2009

You're missing 2 brackets.
You're opening 4 brackets, but only closing 2 of 'em.

pawn Код:
if (strcmp(cmd, "/kill", true) == 0)
{
    if(IsPlayerConnected(playerid))// Actually there's no need to check if the player is connected. He can't type the cmd without being online.
    {
        if (gPlayerLogged[playerid] != 0)
        {
            SendClientMessage(playerid, COLOR_RED, "You have fallen unconscious due to servere wounds!");
            InjuredSpawn[playerid] = 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_GRAY, "[!] You are not logged in!"); //line 292
        }
    }//You forgot this bracket
    return 1;//moved this.
}//And you forgot this bracket!



Re: /kill bug - Antonio [G-RP] - 07.08.2009

Still same errors


Re: /kill bug - Djiango - 07.08.2009

Do you have -
pawn Код:
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
Under your "OnPlayerCommandText(playerid, cmdtext[])" callback?

If you're not using strtok, try changing the
pawn Код:
if (strcmp(cmd, "/kill", true) == 0)
to
pawn Код:
if (strcmp(cmdtext, "/kill", true) == 0)
I would set it up like this.
pawn Код:
if(strcmp(cmdtext, "/kill", true) == 0)
{
    if(gPlayerLogged[playerid] != 1) return SendClientMessage(playerid, COLOR_GRAY, "[!] You are not logged in!");
    SendClientMessage(playerid, COLOR_RED, "You have fallen unconscious due to servere wounds!");
    InjuredSpawn[playerid] = 1;
    return 1;
}



Re: /kill bug - Antonio [G-RP] - 07.08.2009

I'm current not using strtok, is it better?


Re: /kill bug - Antonio [G-RP] - 07.08.2009

EDIT: Yes, I currently am using strtok, but even with ur code I get those 4 errors


Re: /kill bug - Djiango - 07.08.2009

Are you sure you're placing the code in the right place?
Inside the "OnPlayerCommandText" callback!

strtok is slow, but quite good for some functions.
You don't need strtok for this kind of command.


Re: /kill bug - Sergei - 07.08.2009

Isn't dcmd known as the best solution for commands?


Re: /kill bug - Djiango - 07.08.2009

Yep, I wasn't talking about commands.
I personally don't use strtok myself, but knows a few friends that use it for some functions.


Re: /kill bug - Antonio [G-RP] - 07.08.2009

Quote:
Originally Posted by |∞|-Рцппσĵσ-|∞|
Are you sure you're placing the code in the right place?
Inside the "OnPlayerCommandText" callback!

strtok is slow, but quite good for some functions.
You don't need strtok for this kind of command.
YES YES YES!!