Guest User

OnVehicleRepair

a guest
May 26th, 2015
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.96 KB | None | 0 0
  1. #if defined _pnscallback_included
  2.     #endinput
  3. #endif
  4. #define _pnscallback_included
  5.  
  6. #tryinclude <a_samp>
  7.  
  8. // Variables
  9.  
  10. new Float:_pns_vehicleHealth[MAX_VEHICLES] = {1000.0,...};
  11.  
  12. new _pns_t;
  13.  
  14. forward OnVehicleRepair(playerid, vehicleid);
  15.  
  16. public OnGameModeInit()
  17. {
  18.     _pns_t = SetTimer("@_pns_Timer", 100, true);
  19.     print("\n======================================\n");
  20.     print("<-> PNS Callback by HydranT_ geladen");
  21.     print("\n======================================\n");
  22.     return CallLocalFunction("_OnGameModeInit", "");
  23. }
  24.  
  25. #if defined _OnGameModeInit
  26.     forward _OnGameModeInit();
  27. #endif
  28.  
  29. #if defined _ALS_OnGameModeInit
  30.     #undef OnGameModeInit
  31. #else
  32.     #define _ALS_OnGameModeInit
  33. #endif
  34. #define OnGameModeInit _OnGameModeInit
  35.  
  36. public OnGameModeExit()
  37. {
  38.     KillTimer(_pns_t);
  39.     return CallLocalFunction("_OnGameModeExit", "");
  40. }
  41.  
  42. #if defined _OnGameModeExit
  43.     forward _OnGameModeExit();
  44. #endif
  45.  
  46. #if defined _ALS_OnGameModeExit
  47.     #undef OnGameModeExit
  48. #else
  49.     #define _ALS_OnGameModeExit
  50. #endif
  51. #define OnGameModeExit _OnGameModeExit
  52.  
  53. public OnVehicleSpawn(vehicleid)
  54. {
  55.     _pns_vehicleHealth[vehicleid] = 1000.0;
  56.     return CallLocalFunction("_OnVehicleSpawn", "i", vehicleid);
  57. }
  58.  
  59. #if defined _OnVehicleSpawn
  60.     forward _OnVehicleSpawn();
  61. #endif
  62.  
  63. #if defined _ALS_OnVehicleSpawn
  64.     #undef OnVehicleSpawn
  65. #else
  66.     #define _ALS_OnVehicleSpawn
  67. #endif
  68. #define OnVehicleSpawn _OnVehicleSpawn
  69.  
  70. @_pns_Timer(); @_pns_Timer() {
  71.     new i=0, id=INVALID_VEHICLE_ID, Float:vHp=0.0;
  72.     for(; i < MAX_PLAYERS; i++) {
  73.         if(!IsPlayerConnected(i)) continue;
  74.         if(!IsPlayerInAnyVehicle(i)) continue;
  75.         if(GetPlayerState(i) != PLAYER_STATE_DRIVER) continue;
  76.         id = GetPlayerVehicleID(i);
  77.         if(id == INVALID_VEHICLE_ID) continue;
  78.         GetVehicleHealth(id, vHp);
  79.         if(vHp <= _pns_vehicleHealth[id]) {
  80.             _pns_vehicleHealth[id] = vHp;
  81.             continue;
  82.         }
  83.         _pns_vehicleHealth[id] = vHp;
  84.         if(vHp != 1000.0) continue;
  85.         CallLocalFunction("OnVehicleRepair", "ii", i, id);
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment