SA-MP Forums Archive
Can someone explain to me how params[] works? - 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: Can someone explain to me how params[] works? (/showthread.php?tid=244682)



Can someone explain to me how params[] works? - Placebo - 28.03.2011

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



Re: Can someone explain to me how params[] works? - Calgon - 28.03.2011

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


Re: Can someone explain to me how params[] works? - -Rebel Son- - 28.03.2011

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


Re: Can someone explain to me how params[] works? - Placebo - 28.03.2011

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.


Re: Can someone explain to me how params[] works? - Calgon - 28.03.2011

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?


Re: Can someone explain to me how params[] works? - mrcoolballs - 28.03.2011

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



Re: Can someone explain to me how params[] works? - -Rebel Son- - 28.03.2011

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


Re: Can someone explain to me how params[] works? - leong124 - 28.03.2011

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.


Re: Can someone explain to me how params[] works? - Placebo - 28.03.2011

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


Re: Can someone explain to me how params[] works? - Jochemd - 28.03.2011

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 ******.