SA-MP Forums Archive
isnull problem - 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)
+--- Thread: isnull problem (/showthread.php?tid=657163)



isnull problem - xRadical3 - 02.08.2018

Код:
CMD:n(playerid, params[])
{
	new string[172];//The string...
	if(isnull(params)) return SendClientMessage(playerid, lightblue, " /n [Text]"); //If the player only send '/admin'.
	new PlayerName[MAX_PLAYER_NAME+1]; //The string to store the name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); //We get the player name.
	format(string, sizeof(string), "[Near Messages]%s: %s", PlayerName, params); //The final message...
	SendNearMessage( playerid, COLOR_WHITE, string, 15.0 );
	return 1;
}
my isnull codes:
Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
i when enter the /n command not show me /n [Text] but
send the " [Near Messages]%s: /1 "
How to fix it!?


Re: isnull problem - Rufio - 02.08.2018

Why not use sscanf instead?


Re: isnull problem - Akeem - 02.08.2018

Yea i recommand using sscanf too mate.


Re: isnull problem - Dayrion - 02.08.2018

Na, you don't have to use sscanf in that case.
You should debug your code, print part by part your code.


Re: isnull problem - xRadical3 - 02.08.2018

Quote:
Originally Posted by Rufio
Посмотреть сообщение
Why not use sscanf instead?
A lot of my commands are written with isnull and a little with sscanf
Ok, I'll use this.
Thanks


Re: isnull problem - xRadical3 - 02.08.2018

Does not work with scanf
But it shows me the following errors:
Код:
 sscanf warning: Strings without a length are deprecated, please add a destination size.
 sscanf warning: Format specifier does not match parameter count.
 sscanf warning: Strings without a length are deprecated, please add a destination size.
 sscanf warning: Format specifier does not match parameter count.
Код:
CMD:n(playerid, params[])
{
	new string[128],msg[128],pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid,pname,sizeof(pname));
	if(sscanf(params,"sz",msg)) return SendClientMessage(playerid,COLOR_RED, " /n <Text>"); 

	format(string,sizeof(string),"[Near Players Messages]%s: %s",pname,msg);
	SendNearMessage( playerid, COLOR_WHITE, string, 15.0 );
	
	return 1;
}
what should I do


Re: isnull problem - Rufio - 02.08.2018

Change your sscanf parameter to "s[128]" instead of sz.

You have to tell sscanf the size of a string as well.

Also, there is no reason not to use sscanf. I know it's a single parameter and sscanf is not "needed" but I'd not use isNull in 2018. Especially not as a macro.


Re: isnull problem - xRadical3 - 02.08.2018

sscanf warnings solved but this not solved
[Near Players Messages]%s: /1
Pic:



Re: isnull problem - Rufio - 02.08.2018

Shoe your sendnearmessage function as well as your current /n command


Re: isnull problem - xRadical3 - 02.08.2018

Quote:
Originally Posted by Rufio
Посмотреть сообщение
Shoe your sendnearmessage function as well as your current /n command
Код:
stock SendNearMessage(playerid, color, string[], Float:radius)
{
	new Float:Position[3];
	GetPlayerPos(playerid,Position[0],Position[1],Position[2]);

	for(new i; i <= MAX_PLAYERS; i++)
	{
		if(!IsPlayerConnected(playerid)) continue;
		if(IsPlayerInRangeOfPoint(i,radius, Position[0],Position[1],Position[2])) SendClientMessage(i, color, string);
	}
	return 1;
}
There are no problems with this code.

I have even a few cmd problems with this!
I also used sscanf, but it has problem again.

ex:
Код:
CMD:v(playerid,params[]) {
	if(PlayerInfo[playerid][dRank] >= 1) {
 		if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /v [text] - vip chat");
		new string[128];
		format(string, sizeof(string), "{FF00FF}Vip %s: %s", PlayerName2(playerid), params[0] );
        for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if(PlayerInfo[i][dRank] >= 1)
		    {
		        SendClientMessage(i,-1,string);
		    }
		}
		return 1;
	} else return SendClientMessage(playerid,red,"ERROR: You need to be vip level 1 to use this command");
}
not show the " USAGE: /v [text] - vip chat "
send: