SA-MP Forums Archive
[HELP] /givemoney - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] /givemoney (/showthread.php?tid=415851)



[HELP] /givemoney - MiGu3X - 15.02.2013

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


Re: [HELP] /givemoney - JJB562 - 15.02.2013

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;
}



Respuesta: [HELP] /givemoney - MiGu3X - 15.02.2013

thnx allot!