View Full Version : Putting sscanf into a parameter(?)

31/12/2011, 11:44 PM
I'm working on a script currently, but I want to know how it's possible to get it to work?

Obviously the "pay" is part of a bigger "loan" command which has a ton of parameters, however I'm not entirely sure if I can get this one too work. TargetID and Cash are both defined.

if(szOption, "pay", true))
if(!sscanf(params, "di", TargetID, Cash)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /loan pay [Cash]");
if(GetPlayerMoney(playerid) < Cash) return SendClientMessage(playerid, COLOR_WHITE, "You do not have that much money.");
if(GetPlayerMoney(playerid) > Cash)
GivePlayerMoney(playerid, -Cash);
GivePlayerMoney(TargetID, Cash);
return 1;

So, would this work? Or is there a better way of doing it? Thank you!

31/12/2011, 11:46 PM
Change i to Cash.

and also, as a bonus, you can change "d" to "u" for playerid/partofname.

31/12/2011, 11:47 PM
Ah yeah, thanks - forgot about that. Anyhow; that would work, right? I'll obviously add the == INVALID_PLAYER_ID part later on, but without it, it should still work?

31/12/2011, 11:56 PM
You need if(!IsPlayerConnected(TargetID)) return send the message here.
either way

edit: I would really appreciate a rep :)

01/01/2012, 12:33 AM
Yeah, I know, thanks.

+Rep! :)