isnull problem
#1

Код:
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!?
Reply
#2

Why not use sscanf instead?
Reply
#3

Yea i recommand using sscanf too mate.
Reply
#4

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

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
Reply
#6

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
Reply
#7

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.
Reply
#8

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

Shoe your sendnearmessage function as well as your current /n command
Reply
#10

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:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)