SA-MP Forums Archive
Help! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help! (/showthread.php?tid=273771)



Help! - Syntax - 03.08.2011

if (strcmp(cmd, "/heal", true) ==0)
{
SetPlayerHealth(playerid, 100);
}

Can someone tell me what is wrong in this command because when I'm trying to compile it i've got the following error:

D:\random server\gamemodes\hts.pwn(235) : error 010: invalid function or declaration


Re: Help! - Cameltoe - 03.08.2011

Use zcmd alot easier to use.

pawn Код:
command(heal, playerid, params[])
{
     SetPlayerHealth(playerid, 100);
     return 1;
}
Though :

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/heal", true, 5))
    {
        SetPlayerHealth(playerid, 100);
    }
    return 1;
}
Compiles here!


Re: Help! - dr.pepper - 03.08.2011

Quote:
Originally Posted by Syntax
Посмотреть сообщение
if (strcmp(cmd, "/heal", true) ==0)
{
SetPlayerHealth(playerid, 100);
}

Can someone tell me what is wrong in this command because when I'm trying to compile it i've got the following error:

D:\random server\gamemodes\hts.pwn(235) : error 010: invalid function or declaration
pawn Код:
if (strcmp(cmd, "/heal", true) ==0)
{
     SetPlayerHealth(playerid, 100);
     return 1;
}



Re: Help! - Syntax - 03.08.2011

Ok, let me give a try.

EDIT: I've got two errors now with strcmp, but with zcmd none.


Re: Help! - Syntax - 03.08.2011

I have just checked out the previous posts, also I'd like to know why the length is set to 3.

Quote:

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/heal", true, 3))
{
SetPlayerHealth(playerid, 100);
}
return 1;
}




Re: Help! - dr.pepper - 03.08.2011

He probably set a random length array. As some people actually put in random numbers.


Re: Help! - Cameltoe - 03.08.2011

Quote:
Originally Posted by dr.pepper
Посмотреть сообщение
He probably set a random length array. As some people actually put in random numbers.
Yes, its an random length, though heal + / should be 5. My bad.


Re: Help! - Calgon - 03.08.2011

Quote:
Originally Posted by Syntax
Посмотреть сообщение
Ok, let me give a try.

EDIT: I've got two errors now with strcmp, but with zcmd none.
Try change the rest of your commands to zcmd, if you're unable to, post the error code lines with the error messages.

Quote:
Originally Posted by dr.pepper
Посмотреть сообщение
He probably set a random length array. As some people actually put in random numbers.
Parameter 4 in strcmp is the length of a string, not a 'length array' or anything relative of an array. I think you're confusing arrays as strings, a string is used to hold a set of alphanumerical characters (well, symbols too), and arrays are used to hold data that require more than 1 dimension.


Re: Help! - Syntax - 03.08.2011

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/heal", true, 3))
    {
        SetPlayerHealth(playerid, 100);
    }
    return 1;
}
This actually works and I'm able to compile it in pawn compiler but when I'm getting in-game the command doesn't exist. What should I do in order to make it work? I would really appreciate that.


Re: Help! - Syntax - 03.08.2011

Uh seems like I really have a new errror:
D:\random server\gamemodes\hts.pwn(236) : error 021: symbol already defined: "OnPlayerCommandText"