SA-MP Forums Archive
Where Have I Gone Wrong? - 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)
+--- Thread: Where Have I Gone Wrong? (/showthread.php?tid=352439)



Where Have I Gone Wrong? - Montell - 19.06.2012

I'm rather new to scripting, and when I compile I get errors.
Here's the command I am trying to add.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue 5) == 0)
    {
        
SetPlayerHealth(playerid0.0);
        return 
1;
    }
    return 
0
Here are the Errors I am getting when I try to compile.
PHP код:
C:\Users\Montell\Desktop\montytest.pwn(150) : error 001expected token","but found "-integer value-"
C:\Users\Montell\Desktop\montytest.pwn(150) : warning 215expression has no effect
C
:\Users\Montell\Desktop\montytest.pwn(150) : error 001expected token";"but found ")"
C:\Users\Montell\Desktop\montytest.pwn(150) : error 029invalid expressionassumed zero
C
:\Users\Montell\Desktop\montytest.pwn(150) : fatal error 107too many 
Could someone tell me where I have gone wrong?

NOTE: This is Line 150: if (strcmp("/kill", cmdtext, true 5) == 0)


Re: Where Have I Gone Wrong? - tiernantheman - 19.06.2012

Quote:
Originally Posted by Montell
Посмотреть сообщение
I'm rather new to scripting, and when I compile I get errors.
Here's the command I am trying to add.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue 5) == 0)
    {
        
SetPlayerHealth(playerid0.0);
        return 
1;
    }
    return 
0
Here are the Errors I am getting when I try to compile.
PHP код:
C:\Users\Montell\Desktop\montytest.pwn(150) : error 001expected token","but found "-integer value-"
C:\Users\Montell\Desktop\montytest.pwn(150) : warning 215expression has no effect
C
:\Users\Montell\Desktop\montytest.pwn(150) : error 001expected token";"but found ")"
C:\Users\Montell\Desktop\montytest.pwn(150) : error 029invalid expressionassumed zero
C
:\Users\Montell\Desktop\montytest.pwn(150) : fatal error 107too many 
Could someone tell me where I have gone wrong?

NOTE: This is Line 150: if (strcmp("/kill", cmdtext, true 5) == 0)
pawn Код:
if(strcmp(cmd, "/kill", true) == 0



Re: Where Have I Gone Wrong? - Mimic - 20.06.2012

I'd strongly suggest you switch command processor and use ZCMD or YCMD for much easier, more efficient scripting.


Re: Where Have I Gone Wrong? - [MM]RoXoR[FS] - 20.06.2012

Quote:
Originally Posted by Montell
Посмотреть сообщение
I'm rather new to scripting, and when I compile I get errors.
Here's the command I am trying to add.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue 5) == 0)
    {
        
SetPlayerHealth(playerid0.0);
        return 
1;
    }
    return 
0
Here are the Errors I am getting when I try to compile.
PHP код:
C:\Users\Montell\Desktop\montytest.pwn(150) : error 001expected token","but found "-integer value-"
C:\Users\Montell\Desktop\montytest.pwn(150) : warning 215expression has no effect
C
:\Users\Montell\Desktop\montytest.pwn(150) : error 001expected token";"but found ")"
C:\Users\Montell\Desktop\montytest.pwn(150) : error 029invalid expressionassumed zero
C
:\Users\Montell\Desktop\montytest.pwn(150) : fatal error 107too many 
Could someone tell me where I have gone wrong?

NOTE: This is Line 150: if (strcmp("/kill", cmdtext, true 5) == 0)
You forgot the comma ","
pawn Код:
(strcmp("/kill", cmdtext, true, 5) == 0)



Re: Where Have I Gone Wrong? - Mimic - 20.06.2012

pawn Код:
error 001: expected token: ",", but found "-integer value-"
It's very rare for PAWNO's compiler not to tell you the truth you know. People don't realize but the problem is right in front of them. expected token "," but found a number? oh no. lol. Read the error properly, maybe read over it again and again then you'll realize the problem. There are some cases where the compiler doesn't give you an accurate reading, normally when you've placed a bracket wrong or somewhere it shouldn't be at all.


Re: Where Have I Gone Wrong? - Skaizo - 20.06.2012

missing it " ,"
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/kill", cmdtext, true, 5) == 0)
    {
        SetPlayerHealth(playerid, 0);
    }
    return 1;
}