[HELP] /givemoney
#1

pawn Код:
CMD:givemoney(playerid, params[])
{
    new
        Destination,
        Ammount,
        PlayerName[24],
        DestName[24],
        iString[128];
    if (sscanf(params, "ui", Destination, Ammount))
        return SendClientMessage(playerid, RED, "USAGE: /givemoney <playerid> <amount>");

    if (!IsPlayerConnected(Destination))
        return SendClientMessage(playerid, RED, "ERROR: Player is not connected.");

    if (GetPlayerMoney(playerid) < Ammount)
        return SendClientMessage(playerid, RED, "ERROR: Insufficent funds.");

    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerName(Destination, DestName, 24);
    format(iString, 128, "{FFFFFF}%s {BABABA}(ID: %d) has sent you {2DA725}%d $", PlayerName, playerid, Ammount);
    SendClientMessage(Destination, -1, iString);
    format(iString, 128, "{BABABA}You've sent {2DA725}%d $ {BABABA}to {FFFFFF}%s {BABABA}(ID: %d)", Ammount, DestName, Destination);
    SendClientMessage(playerid, -1, iString);

    GivePlayerMoney(Destination, Ammount);
    GivePlayerMoney(playerid, -Ammount);
    return 1;
}
I can give money to myself, what should i add for players not to give money themselves?

HELP ME PLS it urgent
Reply
#2

Here's the code that should do what you want.
pawn Код:
CMD:givemoney(playerid, params[])
{
    new
        Destination,
        Ammount,
        PlayerName[24],
        DestName[24],
        iString[128];
    if (sscanf(params, "ui", Destination, Ammount))
        return SendClientMessage(playerid, RED, "USAGE: /givemoney <playerid> <amount>");

    if (!IsPlayerConnected(Destination))
        return SendClientMessage(playerid, RED, "ERROR: Player is not connected.");

    if (GetPlayerMoney(playerid) < Ammount)
        return SendClientMessage(playerid, RED, "ERROR: Insufficent funds.");
       
    if(Destination == playerid) // This should fix your problem.
        return SendClientMessage(playerid, RED, "ERROR: You cannot give money to yourself.");

    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerName(Destination, DestName, 24);
    format(iString, 128, "{FFFFFF}%s {BABABA}(ID: %d) has sent you {2DA725}%d $", PlayerName, playerid, Ammount);
    SendClientMessage(Destination, -1, iString);
    format(iString, 128, "{BABABA}You've sent {2DA725}%d $ {BABABA}to {FFFFFF}%s {BABABA}(ID: %d)", Ammount, DestName, Destination);
    SendClientMessage(playerid, -1, iString);

    GivePlayerMoney(Destination, Ammount);
    GivePlayerMoney(playerid, -Ammount);
    return 1;
}
Reply
#3

thnx allot!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)