Problem with Hold key to refuel.
#1

I am trying to make the refuel system like when player is holding down the 'Fire' key, it will increase the fuel slowly and TogglePlayerControllable to 0 and if they release the button, it will take the refuel price from player then TogglePlayerControllable to 1. Its also taking money from players repeatedly.

My problem is, when they are holding the button, its spamming the chat with the successful refuel message and gametext + Toggling player controllable 0 and 1 every seconds. What is the problem here? Can anyone explain?

pawn Код:
#define HOLDING(%0) \
    ((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
pawn Код:
if (IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0)
    {
        for (new i; i < sizeof(RefuelPickups); i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.5, RefuelPickups[i][pux], RefuelPickups[i][puy], RefuelPickups[i][puz]))
            {
                if(HOLDING(KEY_FIRE))
                {
                    if(pInfo[playerid][PlayerMoney] <= RefuelPrice) return SendClientMessage(playerid, RED, "You don't have enough money to refuel!");
                    TogglePlayerControllable(playerid, 0);
                    VehicleInfo[vehicleid][Fuel]++;
                    GameTextForPlayer(playerid, "~g~Refuelling your vehicle...", 3000, 5);
                    break;
                }
            }
        }
    }
    if(RELEASED(KEY_FIRE))
    {
        RewardPlayer(playerid, -RefuelPrice, 0);
        TogglePlayerControllable(playerid, 1);
        format(RefuelMsg, 128, "Vehicle refuelled! Refuel cost: $%i", RefuelPrice);
        SendClientMessage(playerid, BLUE, RefuelMsg);
    }
Fuel is increasing in fine way like i wanted. Only problem is that the TogglePlayerControllable, RewardPlayer and ClientMessage is executing everytime.
Reply


Messages In This Thread
Problem with Hold key to refuel. - by iOxide - 15.06.2014, 18:26
Re : Problem with Hold key to refuel. - by S4t3K - 15.06.2014, 18:45
Re: Problem with Hold key to refuel. - by iOxide - 15.06.2014, 18:50
Re : Problem with Hold key to refuel. - by Chipardeur - 15.06.2014, 18:52
Re: Problem with Hold key to refuel. - by iOxide - 15.06.2014, 18:59
Re: Problem with Hold key to refuel. - by Lidor124 - 15.06.2014, 19:10
Re: Problem with Hold key to refuel. - by iOxide - 15.06.2014, 19:24
Re: Problem with Hold key to refuel. - by Konstantinos - 15.06.2014, 19:34
Re: Problem with Hold key to refuel. - by iOxide - 15.06.2014, 19:45
Re: Problem with Hold key to refuel. - by Vince - 15.06.2014, 19:47

Forum Jump:


Users browsing this thread: 1 Guest(s)