Can someone explain to me how params[] works?
#1

I have the code, TRYING to print an error message when no parameter is given by the user. But the Pawno compiler doesn't like this. Is there any other work around?
Код:
CMD:v(playerid, params[])
{
	if(!params)
	{
	    SendClientMessage(playerid, RED, "You did not input a parameter");
	}
}
Reply
#2

You can't just do that with the '!' operator, use isnull() if you have sscanf included.
Reply
#3

I think '!' means it thinks its correct, but not sure, Calgoone, Got an answer?
Reply
#4

Quote:
Originally Posted by -Rebel Son-
Посмотреть сообщение
I think '!' means it thinks its correct, but not sure, Calgoone, Got an answer?
! means not.. (at least in every other programming language).

I'm using zcmd, and yes, I'll try that, Calg00ne.
Reply
#5

Quote:
Originally Posted by -Rebel Son-
Посмотреть сообщение
I think '!' means it thinks its correct, but not sure, Calgoone, Got an answer?


It means is NOT, isn't it relatively clear?
Reply
#6

pawn Код:
CMD:v(playerid, params[])
{
        new str[140];
        format(str,sizeof(str),"Your input: %s",params);
        SendClientMessage(playerid, RED, str);
        return 1;
}
Reply
#7

well to me not really, since my brain is alittle on the broken side, but thanks for the word fella
Reply
#8

params[] is a kind of string(also known as array in PAWN) with unknown size(or auto determine).
You can't do !params since it is an array.
Using isnull macro will help you check if the first cell is null or not.
Reply
#9

Thanks leong124 and Calg00n. I got my code to work fine now.
Reply
#10

You can use isnull, but you can also use 'if(!strlen(params)) which may be a slightly faster (or slower, haven't tested it).

For multiple arguments processing use sscanf from ******.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)