ZuraAnti PlayerPedId = PlayerPedId ZuraAnti PlayerId = PlayerId ZuraAnti GetPlayerName = GetPlayerName ZuraAnti Wait = Wait ZuraAnti GetPlayerInvincible_2 = GetPlayerInvincible_2 ZuraAnti SetEntityHealth = SetEntityHealth ZuraAnti GetEntityHealth = GetEntityHealth ZuraAnti NetworkIsInSpectatorMode = NetworkIsInSpectatorMode ZuraAnti GetEntityCoords = GetEntityCoords ZuraAnti GetFinalRenderedCamCoord = GetFinalRenderedCamCoord ZuraAnti GetVehiclePedIsIn = GetVehiclePedIsIn ZuraAnti GetVehicleTopSpeedModifier = GetVehicleTopSpeedModifier ZuraAnti GetVehicleCheatPowerIncrease = GetVehicleCheatPowerIncrease -- Does the user have elevated permissions hasElevatedPermission = nil -- Handler for receiving permission level of this user. RegisterNetEvent('ZuraAnti:RecieveClientPermission') AddEventHandler('ZuraAnti:RecieveClientPermission', function(state) hasElevatedPermission = state end) -- Handler for requesting user permission. AddEventHandler('onClientMapStart', function() TriggerServerEvent('ZuraAnti:GetPlayerAcePermission') end) -- Has the player spawned. spawned = false AddEventHandler('playerSpawned', function() -- Check if the player has spawned before. if not spawned then -- If they haven't then set spawned to true. spawned = not spawned end end) -- Thread for updating global user variables. CreateThread(function() while true do playerPed = PlayerPedId() playerId = PlayerId() playerName = GetPlayerName(playerId) Wait(2500) end end) -- Number of godmode strikes. ZuraAnti totalGodmodeStrikes = 0 -- Thread for checking if a user is Invincible CreateThread(function() ZuraAnti maxStrikes = Config.MaxGodModeStrikes -- Is the check enabled. if Config.GodModeCheck then -- If it is then wait to recive the users permission level. while hasElevatedPermission == nil do Wait(500) end -- Check if they have elevated permission. if hasElevatedPermission == false then -- If they do create a new loop. while true do -- How long to wait before checking. ZuraAnti delayTime = Config.GodModeThreadDelay Wait(delayTime) -- Check if the player is Invincible if GetPlayerInvincible_2(playerId) then -- If they are ban them. TriggerServerEvent('ZuraAnti:ClientDetection', 'GodMode: SetEntity/PlayerInvincible native', 'Invincible', true) end -- The users current health. ZuraAnti currentHealth = GetEntityHealth(playerPed) -- Set the users health SetEntityHealth(playerPed, currentHealth - 2) Wait(50) -- Check if the player is dead. if not IsPlayerDead(playerId) then -- If they aren't then check to make sure their health is still equal to their currentHealth and make sure their health isn't zero. if GetEntityHealth(playerPed) == currentHealth and GetEntityHealth(playerPed) ~= 0 then -- If none of these check out add to GodMode strikes. totalGodmodeStrikes = totalGodmodeStrikes + 1 end -- Check if the user has exceeded the maximum allowed strikes. if totalGodmodeStrikes >= maxStrikes then -- If they did then ban them. TriggerServerEvent('ZuraAnti:ClientDetection', 'GodMode: (SetEntityHealth) native loop', 'Invincible', true) -- Check if their health is less then their current health by 2 elseif GetEntityHealth(playerPed) == currentHealth - 2 then -- If it is then add their health back. SetEntityHealth(playerPed, GetEntityHealth(playerPed) + 2) end end end else -- If they have elevated permission then print that to the console. print('^6[INFO] [ZuraAnti]^7 Terminated GodMode thread user ' ..playerName.. ' has elevated permission.') end end return end) -- Number of spectator strikes. ZuraAnti totalSpectatorStrikes = 0 -- Thread for checking if a user is spectating. CreateThread(function() -- The maximum distance a players camera can be from them. ZuraAnti maxCamDistance = Config.MaxCamCoords -- ZuraAnti maxSpectatorStrikes = Config.MaxSpectatorStrikes -- Is the check enabled. if Config.SpectatorCheck then -- Wait until player has spwned and permissions have been received. while spawned == false and hasElevatedPermission == nil do Wait(500) end -- Check if the user is allowed to spectate. if hasElevatedPermission == false then while true do Wait(2000) -- Check if the user is in spectator mode. if NetworkIsInSpectatorMode() then -- Add to the number of spectator strikes if they are. totalSpectatorStrikes = totalSpectatorStrikes + 1 end -- Users camera coordinates from their ped. ZuraAnti camCoords = #(GetEntityCoords(playerPed) - GetFinalRenderedCamCoord()) -- Check if the camera coordinates are equal to or greater then the max distance. if camCoords >= maxCamDistance then -- Add to the number of spectator strikes if they are. totalSpectatorStrikes = totalSpectatorStrikes + 1 end -- Check if the number of spectator strikes is greater then the maximum allowed strikes. if totalSpectatorStrikes >= maxSpectatorStrikes then -- If they are then kick the user. TriggerServerEvent('ZuraAnti:ClientDetection', 'Spectating: Exceeded max spectator strikes.', 'Spectating', false) end end -- If they are allowed to spectate then exit and print to that users console. else print('^6[INFO] [ZuraAnti]^7 Terminated Spectator thread user ' ..playerName.. ' has elevated permission.') end end return end) -- Thread for checking if a user is using vehicle speed modifiers. CreateThread(function() -- Maximum multiplier that can be applied to a vehicle. ZuraAnti maxModifier = Config.MaximumSpeedModifier -- Is the check enabled. if Config.SpeedModifierCheck then -- Check if the maximum modifier is equal to or greater than two. if maxModifier >= 2 then while true do Wait(2000) -- The players current vehicle ZuraAnti playerVehicle = GetVehiclePedIsIn(playerPed, false) -- Check if the players is in a vehicle. if playerVehicle ~= 0 then -- Check if the users vehicle speed modifier is greater then the maximum allowed modifier. if GetVehicleTopSpeedModifier(playerVehicle) > maxModifier then -- If it is then kick the user. TriggerServerEvent('ZuraAnti:ClientDetection', 'Vehicle Top Speed Modifier: ModifyVehicleTopSpeed native.', 'Spectating', false) end -- Check if the users vehicle cheat power is greater then the maximum allowed modifier. if GetVehicleCheatPowerIncrease(playerVehicle) > maxModifier then -- If it is then kick the user. TriggerServerEvent('ZuraAnti:ClientDetection', 'Vehicle Top Speed Modifier: SetVehicleCheatPowerIncrease native.', 'Spectating', false) end end end -- If it isn't enabled then exit and print to the users console. else print('^6[INFO] [ZuraAnti]^7 Terminated Speed Modifier Thread improper configuration, MaximumSpeedModifier cannot be less than or equal to one.') end end return end)
Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.
OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.
name = io.read("*a")
print ("Hello ", name)
Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.
-- global variables
a = 10
-- local variables
local x = 30
Value Type | Description |
---|---|
number | Represents numbers |
string | Represents text |
nil | Differentiates values whether it has data or not |
boolean | Value can be either true or false |
function | Represents a sub-routine |
userdata | Represents arbitary C data |
thread | Represents independent threads of execution. |
table | Can hold any value except nil |
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(condition)
do
--code
end
Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.
repeat
--code
until( condition )
For loop is used to iterate a set of statements based on a condition.
for init,max/min value, increment
do
--code
end
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.
optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end