Fast help
#1

I got this error:

error 001: expected token: ",", but found ";"

On this code:

pawn Код:
public RandomMessages()
{
    new Rand = random(sizeof(RandMessages));
    TextDrawSetString(RandMsgTxd, RandMessages[random(sizeof(RandMessages))];
    SCMTA(-1, RandMessages[Rand]);
}
Error line:

pawn Код:
TextDrawSetString(RandMsgTxd, RandMessages[random(sizeof(RandMessages))];
Im trying to show random messages in chat and at same time as textdraw, whats wrong?
Reply
#2

Try this if it compiles
pawn Код:
TextDrawSetString(RandMsgTxd, RandMessages[Rand]);
PS i just did the same on what you did on SCM

EDIT

Quote:
Originally Posted by Vince
Посмотреть сообщение
Rather obvious missed closing bracket ). Still I wonder why you're calling random() again after you've just assigned its value to a variable.
i agree. after i saw the whole code. how in the world. you didn't do the same what you did on your SendClientMessage
Reply
#3

First of all, it's "))]", that's why. It's missing the last ")".
Why don't you just use
pawn Код:
TextDrawSetString(RandMsgTxd, RandMessages[Rand]);
instead of
pawn Код:
TextDrawSetString(RandMsgTxd, RandMessages[random(sizeof(RandMessages))]);



Quote:
Originally Posted by pds2012
Посмотреть сообщение
fixing my code.
Reply
#4

You need something like this:

pawn Код:
public RandomMessages()
{
    new Rand = random(sizeof(RandMessages));
    TextDrawSetString(RandMsgTxd, "RandMessages[random(sizeof(RandMessages"))]);
    SCMTA(-1, RandMessages[Rand]);
}
BTW you forgot ")" at the end of second line in random
Reply
#5

Rather obvious missed closing bracket ). Still I wonder why you're calling random() again after you've just assigned its value to a variable.
Reply
#6

Thanks guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)