Posts: 716
Threads: 92
Joined: May 2018
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?
Posts: 716
Threads: 92
Joined: May 2018
Quote:
Originally Posted by ******
|
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"...
Posts: 716
Threads: 92
Joined: May 2018
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;
}
Posts: 118
Threads: 6
Joined: Jul 2018
Posts: 716
Threads: 92
Joined: May 2018
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.