SA-MP Forums Archive
Help with my first command. - 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: Help with my first command. (/showthread.php?tid=358714)



Help with my first command. - Goru - 11.07.2012

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


Re: Help with my first command. - Revo - 11.07.2012

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");
}



Re: Help with my first command. - RedJohn - 11.07.2012

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;
}



Re: Help with my first command. - Goru - 11.07.2012

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


Re: Help with my first command. - RedJohn - 11.07.2012

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!


Re: Help with my first command. - Goru - 11.07.2012

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


Re: Help with my first command. - Lordzy - 11.07.2012

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


Re: Help with my first command. - Mark™ - 11.07.2012

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 "/".


Re: Help with my first command. - RedJohn - 11.07.2012

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!


Re: Help with my first command. - Mark™ - 11.07.2012

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.