#1

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

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

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;
}
Reply
#4

Ok, let me give a try.

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

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

Reply
#6

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

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

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

Код:
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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 3 Guest(s)