Putting sscanf into a parameter(?)
#1

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.

pawn Код:
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!
Reply
#2

Change i to Cash.

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

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?
Reply
#4

You need
pawn Код:
if(!IsPlayerConnected(TargetID)) return send the message here.
either way

edit: I would really appreciate a rep
Reply
#5

Yeah, I know, thanks.

+Rep!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)