SA-MP Forums Archive
sscanf - error type mismatch - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf - error type mismatch (/showthread.php?tid=470700)



sscanf - error type mismatch - PrivatioBoni - 19.10.2013

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.


Re: sscanf - error type mismatch - Patrick - 19.10.2013

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)



Re: sscanf - error type mismatch - PrivatioBoni - 19.10.2013

Just to clarify, playerb is the targetid.


Re: sscanf - error type mismatch - Patrick - 19.10.2013

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


Re: sscanf - error type mismatch - PrivatioBoni - 19.10.2013

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.


Re: sscanf - error type mismatch - Misiur - 19.10.2013

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]");



Re: sscanf - error type mismatch - DanishHaq - 19.10.2013

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.


Re: sscanf - error type mismatch - Patrick - 19.10.2013

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!


Re: sscanf - error type mismatch - PrivatioBoni - 19.10.2013

Thank you gentlemen. It now functions correctly.