SSCANF 'u' ,playerid WORNG - 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: SSCANF 'u' ,playerid WORNG (
/showthread.php?tid=315535)
SSCANF 'u' ,playerid WORNG -
Shabi RoxX - 03.02.2012
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.......
Re: SSCANF 'u' ,playerid WORNG -
milanosie - 03.02.2012
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
Re: SSCANF 'u' ,playerid WORNG -
Shabi RoxX - 03.02.2012
If I use "i" instead of "u" its working allright

??
Re: SSCANF 'u' ,playerid WORNG -
Macluawn - 03.02.2012
update your sscanf plugin.
Re: SSCANF 'u' ,playerid WORNG -
Konstantinos - 03.02.2012
@ 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!