You can do it using OnPlayerKeyStateChange.
When you press the FIRE key, start a timer that only runs once.
Also, set the player TogglePlayerControllable to false (don't allow the player to move).
Inside the timer function, set TogglePlayerControllable back to true (allow him to move again) when you have finished all code in there.
TogglePlayerControllable blocks the player's keys.
When control is returned to the player, the key-states change automatically if the player is holding a key, so OnPlayerKeyStateChange is called again.
Someone sent me this code:
pawn Код:
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (HOLDING( KEY_SUBMISSION ))
{
if (GetPlayerVehicleSeat(playerid) == 0)
{
for (new i; i < sizeof(ARefuelPickups); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 6.5, ARefuelPickups[i][pux], ARefuelPickups[i][puy], ARefuelPickups[i][puz]))
{
TogglePlayerControllable(playerid, 0);
SetTimerEx("RefuelingVehicle", 100, false, "i", playerid);
switch (GetPlayerLanguage(playerid))
{
case 1,2,3: GameTextForPlayer(playerid, TXT_Refuelling, 1000, 4);
case 0,4: GameTextForPlayer(playerid, ENG_Refuelling, 1000, 4);
}
break;
}
}
}
}
}
public RefuelingVehicle(playerid)
{
new vID = GetPlayerVehicleID(playerid);
TogglePlayerControllable(playerid, 1);
if (AVehicleData[vID][Fuel] < MaxFuel-15)
{
new Amount = AVehicleData[vID][Fuel]+15 - AVehicleData[vID][Fuel];
new RefuelPrice = (Amount * RefuelMaxPrice) / MaxFuel;
if (APlayerData[playerid][PlayerMoney] >= RefuelPrice)
{
AVehicleData[vID][Fuel] = AVehicleData[vID][Fuel]+15;
RewardPlayer(playerid, -RefuelPrice, 0);
}
else
SendMessage(playerid, 0xFFFFFFFF, TXT_CannotRefuelVehicle, ENG_CannotRefuelVehicle);
}
else
{
switch (GetPlayerLanguage(playerid))
{
case 1,2,3: GameTextForPlayer(playerid, "Vozilo je puno!", 1000, 4);
case 0,4: GameTextForPlayer(playerid, "Vehicle is full!", 1000, 4);
}
}
return 1;
}
This worked fine for him.