how to pay other players
#7

Quote:
Originally Posted by sjvt
Посмотреть сообщение
pawn Код:
new string[256];
    new playermoney;
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new giveplayerid, moneys, idx;

if(strcmp(cmd, "/givecash", true) == 0) {
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = strval(tmp);
       
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        moneys = strval(tmp);
       
        //printf("givecash_command: %d %d",giveplayerid,moneys);

       
        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            playermoney = GetPlayerMoney(playerid);
            if (moneys > 0 && playermoney >= moneys) {
                GivePlayerMoney(playerid, (0 - moneys));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
if i try any commands in my GM it says "usage: /givecash playerid amount" lol and when i try that it says "invalid transaction amount"
Reply


Messages In This Thread
how to pay other players - by xXitsgodzillaXx - 20.04.2012, 21:42
Re: how to pay other players - by Mauzen - 20.04.2012, 21:44
Re: how to pay other players - by WarriorEd22 - 20.04.2012, 22:08
Re: how to pay other players - by xXitsgodzillaXx - 20.04.2012, 22:37
Re: how to pay other players - by xXitsgodzillaXx - 20.04.2012, 22:39
Re: how to pay other players - by sjvt - 20.04.2012, 22:43
Re: how to pay other players - by xXitsgodzillaXx - 20.04.2012, 22:53
Re: how to pay other players - by Face9000 - 20.04.2012, 23:58
Re: how to pay other players - by xXitsgodzillaXx - 21.04.2012, 17:27
Re: how to pay other players - by xXitsgodzillaXx - 22.04.2012, 03:32

Forum Jump:


Users browsing this thread: 2 Guest(s)