Help with my first command.
#1

Well, not trying to copy and paste everything, and I'm a beginner at this language started learning yesterday.

I get the following errors


PHP код:
C:\Users\Jeannette\Desktop\Windows-Server\pawno\Joks.pwn(101) : error 017undefined symbol "SCM"
C:\Users\Jeannette\Desktop\Windows-Server\pawno\Joks.pwn(103) : warning 217loose indentation
C
:\Users\Jeannette\Desktop\Windows-Server\pawno\Joks.pwn(106) : warning 209: function "zcmd_OnPlayerCommandText" should return a value
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

The command that I'm making is this.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/healme"cmdtexttrue10) == 0)
    {
    
SetPlayerArmour(150);
    
SetPlayerHealth(150);
    
SCM(playeridCOLOR_PINK"You've refilled your Armour, and health. Goodluck!");
        return 
1;
    } 
Errors that I'm making so I can look back at them and fix them in the future.

If you didn't get a good look at them, or need more information.

Link: http://gyazo.com/e228c4035b72339f1f3526180915dda6
Reply
#2

First of all, SCM is not a actual function, you need to define it first.
pawn Код:
#define SCM "SendClientMessage(%1, %2, %3);"
Don't quote me on the define, I never did it like that, I always use SendClientMessage(playerid, COLOR, Message); because I'm not lazy.

Loose identation means that you're not identing corrently (tabbing your code)
http://en.wikipedia.org/wiki/Indentation

pawn Код:
if( value == 1 ) {
    SendClientMessage(playerid, -1, "hi");
}
else {
    SendClientMessage(playerid, -1, "bye");
}
Reply
#3

Try this!

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/healme", cmdtext, true, 10) == 0)
    {
        SetPlayerArmour(playerid, 50);
        SetPlayerHealth(playerid, 50);
        SendClientMessage(playerid, COLOR_PINK, "You've refilled your Armour, and health. Goodluck!");
        return 1;
    }
    return 1;
}
Reply
#4

Thanks, it worked. I was trying to know the difference between my broken one and your working one. Thanks!
Reply
#5

Analyze mine and your and maybe you'll spot the difference! If you can't find, PM me and i will explain it to you!
Reply
#6

Sorry for double posting, but it's saying it's a Unknown Command.
Reply
#7

Well your command is not working or,your command is working+Unknown command message comes?
Reply
#8

Quote:
Originally Posted by Goru
Посмотреть сообщение
Sorry for double posting, but it's saying it's a Unknown Command.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/healme", cmdtext, true, 7) == 0) // string count for /healme is 7 not 10
    {
        SetPlayerArmour(playerid, 50);
        SetPlayerHealth(playerid, 50);
        SendClientMessage(playerid, COLOR_PINK, "You've refilled your Armour, and health. Goodluck!");
        return 1;
    }
    return 1;
}
Don't put that 10 blindly, it stands for number of strings to be compared to process the command further, if the number the strings don't match the number in the your command, you'd get "Unknown Command". For /healme, it would be 7 including "/".
Reply
#9

Quote:
Originally Posted by Xtreme_playa
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/healme", cmdtext, true, 7) == 0) // string count for /healme is 7 not 10
    {
        SetPlayerArmour(playerid, 50);
        SetPlayerHealth(playerid, 50);
        SendClientMessage(playerid, COLOR_PINK, "You've refilled your Armour, and health. Goodluck!");
        return 1;
    }
    return 1;
}
Don't put that 10 blindly, it stands for number of strings to be compared to process the command further, if the number the strings don't match the number in the your command, you'd get "Unknown Command". For /healme, it would be 7 including "/".
I just copied his command and get rid off warnings, didn't remove or add code cuz i don't want to screw something else in his script!
Reply
#10

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
I just copied his command and get rid off warnings, didn't remove or add code cuz i don't want to screw something else in his script!
Well, don't simply copy everything, edit where changes are felt necessary.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)