Help with this command please?
#1

I'm trying to make it, so if a person does /loan then the target they did /loan on would have to "/take loan" In order to receive it. How would I add it to this?

pawn Код:
CMD:loan(playerid, params[])
{
    new Target, Amount;
    if( !sscanf(params, "ui", Target, Amount) )
    {
        if( Amount < 5000 ) return SendClientMessage(playerid, -1, "You can only pay a minimum ammount of 5000");
        if( Target == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "That person is Offline");
        if( Target == playerid ) return SendClientMessage(playerid, -1, "You can not give a loan to yourself!");
        if( GetPlayerMoney(playerid) < Amount ) return SendClientMessage(playerid, -1, "You don't have enough cash.");
        GivePlayerMoney(playerid, -Amount);
        GivePlayerMoney(Target, Amount);

    } else return SendClientMessage(playerid, -1, "Usage: /loan [playerid] [amount]");
    return 1;
}
Thanks for your help.
Reply
#2

You need to create a variable like

pawn Код:
new LoanBy[MAX_PLAYERS];
Then when someone executes /loan, Make LoanBy[target] = playerid.
In the /take command, create a loan parameter then check if LoanBy[playerid] is an actual player.

To make it more secure you could also add a LoanTo[MAX_PLAYERS], then when someone offers a Loan, make the LoanTo of that player to the person he offered a loan to. Then check whether the Loan was issued by a player to a player by using LoanTo[LoanBy[playerid]] = playerid in the /loan take command.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)