how to pay other players
#3

pawn Код:
if(strcmp(cmd, "/givecash", true) == 0) {
      new string[256];
      new playermoney;
      new sendername[MAX_PLAYER_NAME];
      new giveplayer[MAX_PLAYER_NAME];
      new giveplayerid, moneys, idxx;
      new tmp[256];
        tmp = strtok(cmdtext, idxx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = ReturnUser(tmp);

        tmp = strtok(cmdtext, idxx);
        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(%d), $%d.", giveplayer,giveplayerid, moneys);
                SendClientMessage(playerid, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(%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;
    }
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: 1 Guest(s)