Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _pnscallback_included
- #endinput
- #endif
- #define _pnscallback_included
- // Variables
- new Float:_pns_vehicleHealth[MAX_VEHICLES] = {1000.0,...};
- new _pns_t;
- forward OnVehicleRepair(playerid, vehicleid);
- public OnGameModeInit()
- {
- _pns_t = SetTimer("@_pns_Timer", 100, true);
- print("\n======================================\n");
- print("<-> PNS Callback by HydranT_ geladen");
- print("\n======================================\n");
- return CallLocalFunction("_OnGameModeInit", "");
- }
- #if defined _OnGameModeInit
- forward _OnGameModeInit();
- #endif
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit _OnGameModeInit
- public OnGameModeExit()
- {
- KillTimer(_pns_t);
- return CallLocalFunction("_OnGameModeExit", "");
- }
- #if defined _OnGameModeExit
- forward _OnGameModeExit();
- #endif
- #if defined _ALS_OnGameModeExit
- #undef OnGameModeExit
- #else
- #define _ALS_OnGameModeExit
- #endif
- #define OnGameModeExit _OnGameModeExit
- public OnVehicleSpawn(vehicleid)
- {
- _pns_vehicleHealth[vehicleid] = 1000.0;
- return CallLocalFunction("_OnVehicleSpawn", "i", vehicleid);
- }
- #if defined _OnVehicleSpawn
- forward _OnVehicleSpawn();
- #endif
- #if defined _ALS_OnVehicleSpawn
- #undef OnVehicleSpawn
- #else
- #define _ALS_OnVehicleSpawn
- #endif
- #define OnVehicleSpawn _OnVehicleSpawn
- @_pns_Timer(); @_pns_Timer() {
- new i=0, id=INVALID_VEHICLE_ID, Float:vHp=0.0;
- for(; i < MAX_PLAYERS; i++) {
- if(!IsPlayerConnected(i)) continue;
- if(!IsPlayerInAnyVehicle(i)) continue;
- if(GetPlayerState(i) != PLAYER_STATE_DRIVER) continue;
- id = GetPlayerVehicleID(i);
- if(id == INVALID_VEHICLE_ID) continue;
- GetVehicleHealth(id, vHp);
- if(vHp <= _pns_vehicleHealth[id]) {
- _pns_vehicleHealth[id] = vHp;
- continue;
- }
- _pns_vehicleHealth[id] = vHp;
- if(vHp != 1000.0) continue;
- CallLocalFunction("OnVehicleRepair", "ii", i, id);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement