Where Have I Gone Wrong?
#1

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

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

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

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)
Reply
#5

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)