sscanf - error type mismatch
#1

Hello,

I can't quite get the argument right, I've tried many combinations. Some combinations don't give compile errors yet don't work correctly in-game.

Error:

pawn Код:
error 035: argument type mismatch (argument 2)
Line which the error is referring to:

pawn Код:
if(sscanf(params, playerb, "d", skinid, params)) return SendClientMessage(playerid, COLOR_ERROR, "SYNTAX: /skin [playerid] [skinid]");
Basically, it's an admin command which allows the admin to set a player's skin. I can't get it quite right despite trying for about fifteen minutes. I don't think I need to show the whole command, but if I do, I'll gladly paste it here.

Thanks.
Reply
#2

It should look something like this

pawn Код:
new
    skinid,
    targetid
;

if(sscanf(params, "ui", targetid, skinid)) return SendClientMessage(playerid, COLOR_ERROR, "SYNTAX: /skin [playerid] [skinid]");
SetPlayerSkin(targetid, skinid)
Reply
#3

Just to clarify, playerb is the targetid.
Reply
#4

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
Just to clarify, playerb is the targetid.
You can just change it, since I showed you an example, how to use sscanf
Reply
#5

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
You can just change it, since I showed you an example, how to use sscanf
Yes, but you had playerb and targetid in the same string..

Anyway, I'll sort this out myself. Thanks anyway.
Reply
#6

pawn Код:
native sscanf(const data[], const format[], {Float,_}:...);
Parameters order matters.

pawn Код:
if(sscanf(params, "ui", playerb, skinid)) return SendClientMessage(playerid, COLOR_ERROR, "SYNTAX: /skin [playerid] [skinid]");
Reply
#7

That's how sscanf works, it's the format. I.e.:

pawn Код:
new targetid, skin;
if(sscanf(params, "ud", targetid, skin)) return ...; // is correct
if(sscanf(params, targetid, "d", skin)) return ...; // is incorrect
Read the sscanf topic before using it.
Reply
#8

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
Yes, but you had playerb and targetid in the same string..

Anyway, I'll sort this out myself. Thanks anyway.
Sorry, I made some mistake on my code, I forgot to remove the playerb

pawn Код:
if(sscanf(params, /*playerb - forgot to remove this*/ "ui", targetid, skinid)) return SendClientMessage(playerid, -1, "Syntax: /setskin [Player Name/ID] [Skin ID]");
EDIT: silly me!
Reply
#9

Thank you gentlemen. It now functions correctly.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)