sscanf "u" specifier +rep :)
#1

hi,

first: im using the newest sscanf version

The problem is when i use the "u" specifier in my dcmd commands it sometimes shows "Server: Unknown command".
I have anohter message defined that is shown when there is not the cmd available that u entered.

The problem is the commands using sscanf exists and it also works fine
BUT:
If i enter an ID or a part of a name of a player that is not online on the server it shows this default server error message.
How to prevent that.
How could i do it like there is a message returned saying smth. like: This player has not been found?

Example cmd:
pawn Код:
dcmd_spectate(playerid,params[])
{
    new id;
    if(sscanf(params,"u",id))return SendClientMessage(playerid,0xFF0000FF,"Usage: /spec[ID]");
    if(Spieler[id][eingeloggt] == 0)return SendClientMessage(playerid,0xFF0000FF,"This Player is not logged in!");
    if(id == playerid)return SendClientMessage(playerid,0xFF0000FF,"You can't spectate yourself!");
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid,0xFF0000FF,"Invalid PlayerID!");
    new string[128],name[24]; GetPlayerName(id,name,24);
    SetPlayerInterior(playerid,GetPlayerInterior(id));
    TogglePlayerSpectating(playerid,true);
    PlayerSpectatePlayer(playerid,id);
    return 1;
}
thx
Reply
#2

You alrady have it
pawn Код:
if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid,0xFF0000FF,"Invalid PlayerID!");
Reply
#3

ye, and thats why im asking.
It worked great using the "d" or "i" specifier. (then it showed my message with invalid playerid)
But as soon as i used the "u" specifier it kinda skips my message and it returns the default server unknown command message.

It really annoys me, would be happy about help
Reply
#4

You cannot use "d" or "i" for a player.
Only "u" or "r"
pawn Код:
u -> User name/id (bots and players)
r -> Player name/id
Reply
#5

https://sampwiki.blast.hk/wiki/IsPlayerConnected
Reply
#6

ok thx, i assume the IsPlayerConnected check should do it...
Reply
#7

another question:

What would happen if following players are on the server:

Benny
Ben
Benjamin
Lucy

Now if i use the "u" specifier with the input 'ben', what would happen?
On what player this cmd would be used?
On the lowest id?

And how to prevent this?
Lets say send a message like "error: multiple player names found"?

thx in advance
Reply
#8

if you type for example
pawn Код:
/spectate 1
// ID 1 = Ben
You will spectate Ben.
That's it!
Reply
#9

please dont post if you dont have a clue how to use sscanf!

First, you can use the "d" specifier! No problem with it.
Second, the "u" specifier is smth. special.
You can enter the playerid, the player name or only a part of a players name!!
In case you enter a part of a name found multiple times on the server it could cause problems so im asking here.
How to detect if there are multiple players online? (outgoing from my input)
Reply
#10

Quote:
Originally Posted by PawnoQ
Посмотреть сообщение
please dont post if you dont have a clue how to use sscanf!

First, you can use the "d" specifier! No problem with it.
Second, the "u" specifier is smth. special.
You can enter the playerid, the player name or only a part of a players name!!
In case you enter a part of a name found multiple times on the server it could cause problems so im asking here.
How to detect if there are multiple players online? (outgoing from my input)
First, I am using sscanf more time than you and I have a clue about it. I didn't understand it on your post.
"d" or "i" are for numbers but we use on ID/Part Of Name "u" or "r"
Now I see you meant
pawn Код:
/spectate Ben
You will spec the first ID which fine the part of name "ben".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)