Annoying sscanf id 0 debug
#1

I'm facing that annoying and stupid sscanf id 0 bug.

I'm online, i'm id 0, i type a command on me, result: Player not connected.

Or happens too when someone quits and another one joins replacing his id.

I have the latest sscanf plugin/include, what i have to do to fix this problem once for all?
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
A minimal repro would help:

https://stackoverflow.com/help/mcve
If you're asking for an example code, i'm sorry to say you that this happens to ALL commands which has "u" or "d"...
Reply
#3

Here is, an example command:

pawn Код:
CMD:spawn(playerid, params[])
{
    if (Player[playerid][AccountLevel] < 1) return 0;

    new targetid;
    if (sscanf(params, "u", targetid)) return SCM(playerid, COLOR_RED, "* [USAGE]: /spawn [playerid/name]");

    if (! IsPlayerConnected(targetid)) return SCM(playerid, COLOR_RED, "* The specified player is not connected.");
    if (Player[playerid][AccountLevel] < Player[targetid][AccountLevel]) return SCM(playerid, COLOR_RED, "* You cannot use this command on higher level admin.");
    if (GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)  TogglePlayerSpectating(targetid, false);

    SpawnPlayer(targetid);
    PlayerPlaySound(targetid, 1057, 0.0, 0.0, 0.0);
    PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);

    new buf[128];
    format(buf, sizeof(buf), "* %s %s has respawned you.", AdminLevelName(playerid),ReturnName(playerid, 0));
    SCM(targetid, COLOR_RED, buf);
    format(buf, sizeof(buf), "* You have respawned %s.", ReturnName(targetid, 0));
    SCM(playerid, COLOR_RED, buf);
    return 1;
}
Reply
#4

https://pastebin.com/WitzLdmA

Try like this
Reply
#5

LOL guys I got the same error before 2 3 weeks ago it's about a PM command, I pmed my self just for checking but it says that it's an invalid playerid
Reply
#6

I am aware of only 1 issue with sscanf so far (no sure if its an issue actually), using the identifier "u" does not identify an NPC. so for example if userid is an NPC and i use the following code:
PHP код:
//code above
new userid;
if(
sscanf(params"u"userid)) return 0;
if(!
IsPlayerConnected(userid)) return SendClientMessage(playerid, -1"player not connected");
//rest of code 
the output would be
Quote:

player not connected.

Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
A minimal repro would help:

https://stackoverflow.com/help/mcve

For reference, no-one else has reported a bug like that in sscanf (only of the top three plugins in SA:MP) in like 8 years… Just saying.
I've found this issue too. Player connected with ID 0, and I'm ID 1. Whenever I tried to kick/ban/freeze/etc it said the player is not connected.

Код:
new targetid = INVALID_PLAYER_ID;
if(sscanf(params,"r", targetid))
	return Msg(playerid, "/freeze [Player]");

if(IsPlayerLogged(targetid))
	FreezePlayer(targetid);
else
	Msg(playerid, "Player is not connected.");
This command worke whenever I tried to freeze myself and worked too whenever the other player is on another ID

I'm using crashdetect mysql sscanf streamer audio MapAndreas profiler plugins and smartcmd command processor
Reply
#8

Quote:
Originally Posted by ShihabSoft
Посмотреть сообщение
Did you try sscanf2 include? It's working for me without a glitch.
I'm using sscanf2.

Quote:
Originally Posted by ******
Посмотреть сообщение
I can't compile that. I have no idea how `Player`, `SCM`, and more are defined. Thus, anything I do to get it to compile might hide the apparent but. This is exactly why I gave you that link.
Replace SCM with SendClientMessage (it's just a macro), and remove Player checks.
Reply
#9

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Replace SCM with SendClientMessage (it's just a macro), and remove Player checks.
The problem is that how other things are defined can impact the code provided.

Simply debug it. Add a debug message after you call sscanf and before checking if the target is connected to verify the value
Код:
printf("Player ID: %i | Target ID: %i", playerid, targetid);
Reply
#10

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
I'm using sscanf2
What about sscanf3 is it giving the same error??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)