Combreal icon

antiVehiCamp.lua

Combreal | PRO | 04/24/20 01:27:43 PM UTC | 0 ⭐ | 1410 👁️ | Never ⏰ | []
Lua |

1.16 KB

|

None

|

0 👍

/

0 👎

-- Warn players camping on vehicle for 140 seconds
-- if the players are still on vehicle another 14O seconds after the warning
-- then players are punished as to say killed 
 
-- I miss phasor.
 
api_version = "1.12.0.0"
 
local warningCampTime = 140000
 
function OnScriptLoad()
    register_callback(cb['EVENT_VEHICLE_ENTER'], "OnVehicleEnter")
end
 
function OnScriptUnload()
end
 
function OnVehicleEnter(PlayerIndex, Seat)
    timer(warningCampTime, "IsCampingVehiWarning", PlayerIndex)
end
 
function IsCampingVehiWarning(PlayerIndex)
    if(IsInVehi(PlayerIndex)) then
        say(PlayerIndex, "Stop camping vehicle")
        timer(warningCampTime, "IsCampingVehiPunishment", PlayerIndex)
    end
    return false
end
 
function IsCampingVehiPunishment(PlayerIndex)
    if(IsInVehi(PlayerIndex)) then
        say(PlayerIndex, "You have been warned...")
        kill(PlayerIndex)
    end
    return false
end
 
function IsInVehi(PlayerIndex)
    local PlayerObj = get_dynamic_player(PlayerIndex)
    local VehicleObjID = read_dword(PlayerObj + 0x11C)
    local vehicle = get_object_memory(VehicleObjID)
    if (vehicle ~= 0 and vehicle ~= nil) then
            return true
    end
    return false
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎