[Tutorial] Fixing sscanf2 invalid id problem
#1

Hello,

I saw alot of people experiencing this issue

So, i made a tutorial for this (Sorry if it is not explained fully as it is my first tutorial)

First, if you have something like this in your script and you are using sscanf 2:

pawn Code:
new idvariable, something[60]; // Defines new idvariable for the id and something for the string (text) and something's size is 60.
if(sscanf(params, "us[60]", idvariable, something)) // This checks if the player didn't type the command fully, like the player typed /command 0 it will show him this cause he didn't type the text after 0 (id).
And then you check if the id is connected like this :

pawn Code:
if(!IsPlayerConnected(idvariable)) return SendClientMessage(playerid, -1, "Invalid Player ID"); // If the id is not connected it will return him a message in the chat with the white color (-1) Invalid Player ID.
It will return Invalid Player ID even if the id is connected.

Now i will tell you how to fix this.

Change the u (Username) in the sscanf param line to d (Integer) (That means we will change the u (Username) param to d (Integer). Example :

pawn Code:
if(sscanf(params, "ds[60]", idvariable, something))
Notes:

d = Integer
i = Integer
c = Character
u = User ID or name
s = String
h = Hex number
x = Hex number
f = Float
z = Optional string
When you fix this problem, you will be able to only use IDs for players, not names.

This is my first tutorial, i'm sorry if i didn't explain it fully!

Thank you for reading this.
Reply


Messages In This Thread
Fixing sscanf2 invalid id problem - by SilverKiller - 19.06.2013, 20:05
Re: Fixing sscanf2 invalid id problem - by Biess - 19.06.2013, 20:18
Re: Fixing sscanf2 invalid id problem - by SilverKiller - 19.06.2013, 20:23
Re: Fixing sscanf2 invalid id problem - by iHaze. - 20.06.2013, 01:07
Re: Fixing sscanf2 invalid id problem - by xFirex - 20.06.2013, 13:42
AW: Fixing sscanf2 invalid id problem - by HurtLocker - 20.06.2013, 13:54
Re: Fixing sscanf2 invalid id problem - by xFirex - 20.06.2013, 14:54
Re: Fixing sscanf2 invalid id problem - by SilverKiller - 20.06.2013, 15:23

Forum Jump:


Users browsing this thread: 1 Guest(s)