Advertisement
Combreal

antiVehiCamp.lua

Apr 24th, 2020
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. -- Warn players camping on vehicle for 140 seconds
  2. -- if the players are still on vehicle another 14O seconds after the warning
  3. -- then players are punished as to say killed
  4.  
  5. -- I miss phasor.
  6.  
  7. api_version = "1.12.0.0"
  8.  
  9. local warningCampTime = 140000
  10.  
  11. function OnScriptLoad()
  12.     register_callback(cb['EVENT_VEHICLE_ENTER'], "OnVehicleEnter")
  13. end
  14.  
  15. function OnScriptUnload()
  16. end
  17.  
  18. function OnVehicleEnter(PlayerIndex, Seat)
  19.     timer(warningCampTime, "IsCampingVehiWarning", PlayerIndex)
  20. end
  21.  
  22. function IsCampingVehiWarning(PlayerIndex)
  23.     if(IsInVehi(PlayerIndex)) then
  24.         say(PlayerIndex, "Stop camping vehicle")
  25.         timer(warningCampTime, "IsCampingVehiPunishment", PlayerIndex)
  26.     end
  27.     return false
  28. end
  29.  
  30. function IsCampingVehiPunishment(PlayerIndex)
  31.     if(IsInVehi(PlayerIndex)) then
  32.         say(PlayerIndex, "You have been warned...")
  33.         kill(PlayerIndex)
  34.     end
  35.     return false
  36. end
  37.  
  38. function IsInVehi(PlayerIndex)
  39.     local PlayerObj = get_dynamic_player(PlayerIndex)
  40.     local VehicleObjID = read_dword(PlayerObj + 0x11C)
  41.     local vehicle = get_object_memory(VehicleObjID)
  42.     if (vehicle ~= 0 and vehicle ~= nil) then
  43.             return true
  44.     end
  45.     return false
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement