PDA

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


Mosslah
31/12/2011, 10: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!

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

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

Mosslah
31/12/2011, 10: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?

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

edit: I would really appreciate a rep :)

Mosslah
31/12/2011, 11:33 PM
Yeah, I know, thanks.

+Rep! :)