[HELP] /givecash [SOLVED]
#1

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 = strval(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;
    }
Here is code I use for /givecash command....
It should work like this...

If Player wants to give some of his cash to another player, he uses /givecash ID amount, if he doesnt have enough money - returns him message "Invalid transaction", if it was wrong ID then "ID is not an active player"... It it was successful then send cash to another player and remove cash from sender...

Why this commands works for ID 0 only??

Whatever ID I use, it always gives money to ID 0 :S
Reply


Messages In This Thread
[HELP] /givecash [SOLVED] - by leapfish - 22.02.2010, 23:12
Re: [HELP] /givecash - by leapfish - 23.02.2010, 11:02
Re: [HELP] /givecash - by Torran - 23.02.2010, 11:03
Re: [HELP] /givecash - by GaGlets(R) - 23.02.2010, 11:12
Re: [HELP] /givecash - by Razvann - 23.02.2010, 11:13
Re: [HELP] /givecash - by GaGlets(R) - 23.02.2010, 11:18
Re: [HELP] /givecash - by leapfish - 23.02.2010, 11:23

Forum Jump:


Users browsing this thread: 1 Guest(s)