Any two commands
#1

Hi, I know this is probably going to be the most obvious question you guys have ever had to answer, but I'm really quite new to scripting but want to learn.

I'm using strcmp and if I try and do 2 commands in my script then it will say:


error 021: symbol already defined: "OnPlayerCommandText"

If I remove the line it doesn't like, then it says:

error 055: start of function body without function header


Can anyone show me how to do 2 commands together without it spewing errors all over the place?

[AFOREMENTIONED PROBLEM RESOLVED]

I have another question, how do I code 1 string which has 2 different colours?

For example:

pawn Код:
SendClientMessage(playerid, COLOR_LIGHTBLUE, "xxxxxxxxxx:" COLOR_RED, "xxxxxxxxx");
Would bring up errors:

Код:
error 001: expected token: "-string end-", but found "-identifier-"
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    if (strcmp("/mycommand2", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 1;
}
Reply
#3

It works, thank you Noob.
Reply
#4

@Da_Noob
You have to return 0 at the end if you use OnPlayerCommandText.
Reply
#5

@Mr_DjoLE

It seems to work anyway. Not 100% sure what return 0; does though, but the commands I have seem fully functional (I know have 4 commands)

I have another question, how do I code 1 string which has 2 different colours?

For example:

pawn Код:
SendClientMessage(playerid, COLOR_LIGHTBLUE, "xxxxxxxxxx:" COLOR_RED, "xxxxxxxxx");
Would bring up errors:

Код:
error 001: expected token: "-string end-", but found "-identifier-"
warning 215: expression has no effect
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)