How to check money
#3

This is my ransom command. Right now the person who is kidnapped can give a player as much cash as he wants too and the kidnapper could decide to release him or not.


Can you help me edit it to the random thing I'm trying to do?



So here is the command:


pawn Код:
if(strcmp(cmd, "/ransom", true) == 0)
{
    if(IsSpawned[playerid] == 0) {
        SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
        return 1;
    }
    if(cuffed[playerid] == 1) {
        SendClientMessage(playerid,COLOR_ERROR,"You are handcuffed. You cannot use this command");
        return 1;
    }
    if(isKidnapped[playerid] == 0) {
        SendClientMessage(playerid,COLOR_ERROR,"Only players who are kidnapped can use this command!");
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ransom (id) (amount)");
        return 1;
    }
    if(!IsNumeric(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ransom(id) (amount) ID Must be a number");
        return 1;
    }
    if(strval(tmp) == playerid) {
        SendClientMessage(playerid, COLOR_ERROR, "You cannot send cash to yourself");
        return 1;
    }
    giveplayerid = strval(tmp);
    if(!IsPlayerConnected(giveplayerid)) {
        format(szstring, sizeof(szstring), "ID (%d) is not an active player", giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
        return 1;
    }
    new sendername[24];
    new receivername[24];
    GetPlayerName(playerid,sendername, 24);
    GetPlayerName(giveplayerid,receivername, 24);
    if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 8) {
        format(szstring, sizeof(szstring), "%s(%d) Is not close enough. You cannot give cash to that player",receivername,giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ransom (id) (amount)");
        return 1;
    }
    if(!IsNumeric(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /ransom(id) (amount) Amount must be a number");
        return 1;
    }
    new cashsend = strval(tmp);
    if(cashsend <= 0 || cashsend >= 100001) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: Minimum $1 / Maximum $100000");
        return 1;
    }
    if(GetPlayerMoney(giveplayerid) + cashsend >= 2000001) {
        SendClientMessage(playerid, 0xA9A9A9AA, "|_Cash Send Failed_|");
        format(szstring, sizeof(szstring), "%s(%d) Does not have enough pockets to carry that ammount of cash ",receivername,giveplayerid);
        SendClientMessage(playerid, 0x00C7FFAA, szstring);
        return 1;
    }
    if(GetPlayerMoney(playerid) >= cashsend) {
        GivePlayerMoney(playerid,-cashsend);
        GivePlayerMoney(giveplayerid,cashsend);
        SendClientMessage(playerid, 0xA9A9A9AA, "|_Cash Sent_|");
        format(szstring, sizeof(szstring), "You have sent $%d to %s(%d)",cashsend,receivername,giveplayerid);
        SendClientMessage(playerid, 0x00C7FFAA, szstring);
        SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_Cash Received_|");
        SendClientMessage(giveplayerid, 0xA9A9A9AA, "You can now choose to release the player, or keep him kidnapped!");
        format(szstring, sizeof(szstring), "%s(%d) Has sent you $%d",sendername,playerid,cashsend);
        SendClientMessage(giveplayerid, 0x00C7FFAA, szstring);
        format(szstring, sizeof(szstring), "Sender %s(%d) Has sent $%d to receiver %s(%d)",sendername,playerid,cashsend,receivername,giveplayerid);
        printf("%s",szstring);
    }
    else
    if(GetPlayerMoney(playerid) < cashsend) {
        SendClientMessage(playerid, 0xA9A9A9AA, "|_Cash Send Failed_|");
        format(szstring, sizeof(szstring), "You cannot afford to send $%d",cashsend);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
    }
    return 1;
}
Reply


Messages In This Thread
How to check money - by MWF2 - 05.08.2010, 19:25
Re: How to check money - by jonrb - 05.08.2010, 19:31
Re: How to check money - by MWF2 - 05.08.2010, 21:33
Re: How to check money - by MWF2 - 06.08.2010, 01:40
Re: How to check money - by Kar - 06.08.2010, 04:28
Re: How to check money - by MWF2 - 06.08.2010, 14:35
Re: How to check money - by Kar - 06.08.2010, 14:45
Re: How to check money - by MWF2 - 06.08.2010, 14:51
Re: How to check money - by MWF2 - 06.08.2010, 20:00
Re: How to check money - by Kar - 06.08.2010, 20:16
Re: How to check money - by MWF2 - 06.08.2010, 22:00
Re: How to check money - by Kar - 06.08.2010, 22:03
Re: How to check money - by MWF2 - 06.08.2010, 22:11
Re: How to check money - by westre - 06.08.2010, 22:25
Re: How to check money - by Kar - 06.08.2010, 23:50

Forum Jump:


Users browsing this thread: 1 Guest(s)