SSCANF 'u' ,playerid WORNG
#1

Hy guys am using zcmd and sscanf2 to create cmd...

Code
Код:
CMD:test(playerid,params[])
{
	new giveid,G_Name[12],str[64];
    if(sscanf(params,"u",giveid))
	return SendClientMessage(playerid, C_GREY, "Format: /Test [playerid]");
	else
	GetPlayerName(playerid,G_Name,sizeof(G_Name));
	format(str,sizeof(str),"ID = %d ,Name = %s",giveid,G_Name);
	SendClientMessage(playerid,C_RED,str);
	return 1;
}
I put playerid = 0 , but its shows me "ID=172" and name is right.......
Reply
#2

first of all, make G_Name size 24 and not 12

Secondly, make str 128, and try !sscanf not sscanf

the !sscanf is most important, now it checks if u literally wrote U and not an id
Reply
#3

If I use "i" instead of "u" its working allright ??
Reply
#4

update your sscanf plugin.
Reply
#5

@ milanosie
I will agree about the name, you need to change it to 20 as this it's the Name Length in Sa-MP.
Also, it doesn't need str to be 128 for an id (max:3) and a name (max:20). 64 is enough, because it's just waste of memory (256 bytes). Also,
pawn Код:
if( !sscanf( params, "u", giveid ) )
{
     // Code
}
else return SendClientMessage( .. )
It's same as
pawn Код:
if( sscanf( params, "u", giveid ) ) return SendClientMessage( .. )
// Code
@Shabi RoxX
Update the sscanf to the latest version!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)