/kill bug
#1

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
Reply
#2

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!
Reply
#3

Still same errors
Reply
#4

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;
}
Reply
#5

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

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

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.
Reply
#8

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

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.
Reply
#10

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!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)