First time scripting help
#1

Well im a newbie mapper, so i decided to begin scripting so this is what i did.

Код:
#include a_samp

#define Filterscript

#define COLOR_GREEN 0x008000FF
#define COLOR_BLUE 0x0000FFFF
#define COLOR_BRIGHTRED 0xFF000AAA
#define COLOR_AQUA 0x00FFFFAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_BEIGE 0xFFF8DCAA
#define COLOR_BLACK 0x000000AA
#define COLOR_LIGHTERBLUE 0x00BFFFAA
#define COLOR_BLUELIGHT 0x1E90FFAA
#define COLOR_BLUEMEDIUM 0x0000CDAA
#define COLOR_BLUEDARK 0x00008BAA
#define COLOR_PINK 0xFF1493AA
#define COLOR_PINKDARK 0xFF00FFAA
#define COLOR_GREENLIGHT 0x00FF00AA
#define COLOR_GREENDARK 0x006400AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OKER 0x808000AA
#define COLOR_ORANGE 0xFF4500AA
#define COLOR_ORANGELIGHT 0xFF8C00AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_VIOLETDARK 0x9400D3AA
#define COLOR_INDIGO 0xAB0082AA
#define COLOR_RED 0xFF0000AA
#define COLOR_SAND 0xFFDEADAA
#define COLOR_SILVER 0xC0C0C0AA
#define COLOR_TEAL 0x008080AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GOLD 0xFFD700AA
#define COLOR_BROWN 0x8B4513AA
#define COLOR_BROWNLIGHT 0xA0522DAA
#define COLOR_GRAY 0xA9A9A9AA
#define COLOR_GRAYDARK 0x696969AA
#define COLOR_INVISIBLE 0xFFFFFF00

public OnPlayerCommand
 if (strcmp("/healhelp", cmdtext, true, 10) == 0)
 {
  SendClientMessage(playerid,COLOR_RED,"If you want to heal yourself use /healme, wich will cost 500 and for armour /armour wich will be 1000.");
  return 1;
 }
  if (strcmp("/healme", cmdtext, true, 10) == 0)
 {
  SetPlayerHealth(playerid,100);
  GivePlayerMoney(playerid,-500);
  SendClientMessage(playerid,COLOR_GREEN,"You have reafilled your health.");
  SendClientMessage(playerid,COLOR_BLUE,"Make sure to /healhelp for more information!");
  return 1;
 }
  if (strcmp("/armour", cmdtext, true, 10) == 0)
 {
 SetPlayerArmor(playerid,100);
 SendClientMessage(playerid,COLOR_RED,"You have refilled your armour.");
 SendClientMessage(playerid,COLOR_BLUE,"Make sure to /healhelp for more information!");
 
  return 1;
 }
So after that i decided to compile and run so i got these errors.

Код:
C:\Users\Juan\Desktop\TEST V1.pwn(41) : error 001: expected token: ";", but found "if"
C:\Users\DJ\Desktop\TEST V1.pwn(44) : error 010: invalid function or declaration
C:\Users\DJ\Desktop\TEST V1.pwn(46) : error 010: invalid function or declaration
C:\Users\DJ\Desktop\TEST V1.pwn(52) : error 010: invalid function or declaration
C:\Users\DJ\Desktop\TEST V1.pwn(54) : error 010: invalid function or declaration
C:\Users\DJ\Desktop\TEST V1.pwn(57) : error 021: symbol already defined: "SendClientMessage"
C:\Users\DJ\Desktop\TEST V1.pwn(60) : error 010: invalid function or declaration
C:\Users\DJ\Desktop\TEST V1.pwn(62) : warning 203: symbol is never used: "OnPlayerCommand"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
PS: I'm planning on editing the script further, so i made all those defines so when i need more colors i dont need to go up and define or get the codes again.
Reply
#2

pawn Код:
#include <a_samp>

#if defined FILTERSCRIPT
#define Filterscript
if u made this as your gm , remove that.
Reply
#3

I made this as a filterscript.
Reply
#4

nvm,
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if (strcmp("/healhelp", cmdtext, true, 9) == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"If you want to heal yourself use /healme, wich will cost 500 and for armour /armour wich will be 1000.");
        return 1;
    }
    if (strcmp("/healme", cmdtext, true, 7) == 0)
    {
        SetPlayerHealth(playerid,100);
        GivePlayerMoney(playerid,-500);
        SendClientMessage(playerid,COLOR_GREEN,"You have reafilled your health.");
        SendClientMessage(playerid,COLOR_BLUE,"Make sure to /healhelp for more information!");
        return 1;
    }
    if (strcmp("/armour", cmdtext, true, 7) == 0)
    {
        SetPlayerArmor(playerid,100);
        SendClientMessage(playerid,COLOR_RED,"You have refilled your armour.");
        SendClientMessage(playerid,COLOR_BLUE,"Make sure to /healhelp for more information!");
        return 1;
    }
    return 0;
}
bro check this https://sampwiki.blast.hk/wiki/OnPlayerCommandText
Also , adding 10 as a constant was wrong..
Just count how many characters including the slash , and add the length there
Reply
#6

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/helphelp", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"If you want to heal yourself use /healme, wich will cost 500 and for armour /armour wich will be 1000.");
        return 1;
    }
    if (strcmp("/healme", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid,100);
        GivePlayerMoney(playerid,-500);
        SendClientMessage(playerid,COLOR_GREEN,"You have reafilled your health.");
        SendClientMessage(playerid,COLOR_BLUE,"Make sure to /healhelp for more information!");
        return 1;
    }
    if (strcmp("/armourme", cmdtext, true, 10) == 0)
    {
        SetPlayerArmour(playerid,100);
        SendClientMessage(playerid,COLOR_RED,"You have refilled your armour.");
        SendClientMessage(playerid,COLOR_BLUE,"Make sure to /healhelp for more information!");
        return 1;
    }
    return 1;
}
Edit: lol , late a little bit xD, i didnt check his code and when i scroll down i see there's a problem with his commands callbacks :P

Second Edit:
pawn Код:
SetPlayerArmor(playerid,100);
check it carefully.
pawn Код:
SetPlayerArmour(playerid,100);
Reply
#7

PS: Can someone fix it and make it as a FilterScript? I will check the errors and try to understand them.. As i can't fix it.
Reply
#8

Anyone? :P
Reply
#9

Just add the commands and colour defines to the GM script.
Reply
#10

Here is your solution

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/healhelp", cmdtext, true, 10) == 0)
 {
  SendClientMessage(playerid,COLOR_RED, "If you want to heal yourself use /healme, wich will cost 500 and for armour /armour wich will be 1000.");
  return 1;
 }
  if (strcmp("/healme", cmdtext, true, 10) == 0)
 {
  SetPlayerHealth(playerid,100);
  GivePlayerMoney(playerid,-500);
  SendClientMessage(playerid,COLOR_GREEN, "You have reafilled your health.");
  SendClientMessage(playerid,COLOR_BLUE, "Make sure to /healhelp for more information!");
  return 1;
 }
  if (strcmp("/armour", cmdtext, true, 10) == 0)
 {
 SetPlayerArmour(playerid,100);
 SendClientMessage(playerid,COLOR_RED, "You have refilled your armour.");
 SendClientMessage(playerid,COLOR_BLUE, "Make sure to /healhelp for more information!");
 return 1;
}
 return 0;
}
Common Errors / Mistakes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)