Nyft_

Reparar Veículo & Timer ~Nyft

Jun 5th, 2021 (edited)
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.36 KB | None | 0 0
  1. #include a_samp
  2. #include sscanf2
  3. #include pawn.cmd
  4.  
  5. static const TIMER_REPAIR = 30;
  6.  
  7. static bool:Repairing[MAX_PLAYERS];
  8. static RepairCount[MAX_PLAYERS];
  9. static RepairTimer[MAX_PLAYERS];
  10.  
  11. main(){}
  12.  
  13. CMD:reparar(playerid, params[])
  14. {
  15.     if(!IsPlayerInAnyVehicle(playerid))
  16.         return SendClientMessage(playerid, -1, "* Você não está conduzindo um veículo.");
  17.  
  18.     if(Repairing[playerid])
  19.         return SendClientMessage(playerid, -1, "* Você já está reparando seu veículo.");
  20.  
  21.     Repairing[playerid] = true;
  22.     RepairCount[playerid] = 0;
  23.     RepairTimer[playerid] = SetTimerEx("OnRepairVehicleUpdate", 1000, true, "i", playerid);
  24.     SendClientMessage(playerid, -1, "* Você começou a reparar seu veículo.");
  25.     return 1;
  26. }
  27.  
  28. forward OnRepairVehicleUpdate(playerid);
  29. public OnRepairVehicleUpdate(playerid)
  30. {
  31.     if(Repairing[playerid])
  32.     {
  33.         if(RepairCount[playerid] >= TIMER_REPAIR)
  34.         {
  35.             KillTimer(RepairTimer[playerid]);
  36.             RepairCount[playerid] = 0;
  37.             Repairing[playerid] = false;
  38.             RepairVehicle(GetPlayerVehicleID(playerid));
  39.             SendClientMessage(playerid, -1, "* Veículo reparado com sucesso.");
  40.         }
  41.         else
  42.         {
  43.             new string[64];
  44.             format(string, sizeof(string), "~r~REPARANDO VEICULO...~n~~w~%i/%i", RepairCount[playerid], TIMER_REPAIR);
  45.             GameTextForPlayer(playerid, string, 1000, 4);
  46.             RepairCount[playerid]++;
  47.         }
  48.     }
  49.     return 1;
  50. }
Add Comment
Please, Sign In to add comment