-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Nov 19, 2022
1 parent
d68f9f6
commit c8ceb3e
Showing
11 changed files
with
511 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# knxr-antitroll | ||
|
||
 | ||
|
||
## Features | ||
- Admin Command to Toggle antitroll: /troll <id> | ||
- AntiVDM | ||
- Disable DriveBy | ||
- Disable Punching / Disable Punching Damage | ||
|
||
## Installation | ||
- Downloaded! | ||
- Move it to your Resources folder. | ||
- Have Fun! :D | ||
# knxr-antitroll | ||
|
||
 | ||
|
||
## Features | ||
- Admin Command to Toggle antitroll: /troll <id> | ||
- AntiVDM | ||
- Disable DriveBy | ||
- Disable Punching / Disable Punching Damage | ||
|
||
## Installation | ||
- Downloaded! | ||
- Move it to your Resources folder. | ||
- Have Fun! :D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,118 @@ | ||
local isTimerInstance = false | ||
function setUiShow(bool) | ||
SendNUIMessage({ | ||
type = "show", | ||
show = bool | ||
}) | ||
end | ||
|
||
function updateUiTime(timeLeft) | ||
SendNUIMessage({ | ||
type = "update", | ||
minleft = timeLeft | ||
}) | ||
end | ||
|
||
function updateTimeToDatabase(overrideTime) | ||
TriggerServerEvent("knxr-antitroll:updateTime", overrideTime or timeLeft) | ||
end | ||
|
||
function startTimer() | ||
local interval = timeToSafe | ||
|
||
updateTimeToDatabase() | ||
|
||
CreateThread(function() | ||
isTimerInstance = true | ||
while hasProtection do | ||
|
||
if interval == timeToSafe or timeLeft <= 0 then | ||
interval = 0 | ||
setUiShow(true) | ||
updateTimeToDatabase() | ||
end | ||
|
||
interval = interval + 1 | ||
|
||
if timeLeft <= 0 then | ||
stopAntiTroll() | ||
isTimerInstance = false | ||
return | ||
end | ||
|
||
timeLeft = timeLeft - 1 | ||
|
||
|
||
updateUiTime(timeLeft) | ||
Wait(1000 * 60) | ||
end | ||
end) | ||
end | ||
|
||
function startAntiTroll() | ||
if not isTimerInstance then | ||
startTimer() | ||
end | ||
setUiShow(true) | ||
|
||
-- Anti VDM | ||
if Config.DisableVDM then | ||
SetWeaponDamageModifier(-1553120962, 0.0) | ||
end | ||
|
||
-- Anti Driveby | ||
if not Config.DriveBy then | ||
SetPlayerCanDoDriveBy(PlayerId(), false) | ||
end | ||
|
||
if Config.DisablePunching then | ||
CreateThread(function() | ||
while hasProtection do | ||
Wait(5) | ||
DisableControlAction(0, 140, true) | ||
DisableControlAction(0, 141, true) | ||
DisableControlAction(0, 142, true) | ||
end | ||
end) | ||
end | ||
|
||
if Config.DisableShooting then | ||
CreateThread(function() | ||
while hasProtection do | ||
Wait(5) | ||
DisablePlayerFiring(player, true) | ||
end | ||
end) | ||
end | ||
|
||
if Config.DisablePunchingDamage then | ||
SetWeaponDamageModifier(-1569615261, 0.0) | ||
end | ||
end | ||
|
||
function stopAntiTroll() | ||
hasProtection = false | ||
timeLeft = 0 | ||
|
||
-- Anti VDM | ||
if Config.DisableVDM then | ||
SetWeaponDamageModifier(-1553120962, 1.0) | ||
end | ||
|
||
-- Anti Driveby | ||
if not Config.DriveBy then | ||
SetPlayerCanDoDriveBy(PlayerId(), true) | ||
end | ||
|
||
if Config.DisablePunching then | ||
EnableControlAction(0, 140, true) | ||
EnableControlAction(0, 141, true) | ||
EnableControlAction(0, 142, true) | ||
end | ||
|
||
if Config.DisablePunchingDamage then | ||
SetWeaponDamageModifier(-1569615261, 1.0) | ||
end | ||
setUiShow(false) | ||
local isTimerInstance = false | ||
|
||
function setUiShow(bool) | ||
SendNUIMessage({ | ||
type = "show", | ||
show = bool | ||
}) | ||
end | ||
|
||
function updateUiTime(timeLeft) | ||
SendNUIMessage({ | ||
type = "update", | ||
minleft = timeLeft | ||
}) | ||
end | ||
|
||
function updateTimeToDatabase(overrideTime) | ||
TriggerServerEvent("knxr-antitroll:updateTime", overrideTime or timeLeft) | ||
end | ||
|
||
function startTimer() | ||
local interval = timeToSafe | ||
|
||
updateTimeToDatabase() | ||
|
||
CreateThread(function() | ||
isTimerInstance = true | ||
while hasProtection do | ||
|
||
if interval == timeToSafe or timeLeft <= 0 then | ||
interval = 0 | ||
setUiShow(true) | ||
updateTimeToDatabase() | ||
end | ||
|
||
interval = interval + 1 | ||
|
||
if timeLeft <= 0 then | ||
stopAntiTroll() | ||
isTimerInstance = false | ||
return | ||
end | ||
|
||
timeLeft = timeLeft - 1 | ||
|
||
|
||
updateUiTime(timeLeft) | ||
Wait(1000 * 60) | ||
end | ||
end) | ||
end | ||
|
||
function startAntiTroll() | ||
if not isTimerInstance then | ||
startTimer() | ||
end | ||
setUiShow(true) | ||
|
||
-- Anti VDM | ||
if Config.DisableVDM then | ||
SetWeaponDamageModifier(-1553120962, 0.0) | ||
end | ||
|
||
-- Anti Driveby | ||
if not Config.DriveBy then | ||
SetPlayerCanDoDriveBy(PlayerId(), false) | ||
end | ||
|
||
if Config.DisablePunching then | ||
CreateThread(function() | ||
while hasProtection do | ||
Wait(5) | ||
DisableControlAction(0, 140, true) | ||
DisableControlAction(0, 141, true) | ||
DisableControlAction(0, 142, true) | ||
end | ||
end) | ||
end | ||
|
||
if Config.DisableShooting then | ||
CreateThread(function() | ||
while hasProtection do | ||
Wait(5) | ||
DisablePlayerFiring(player, true) | ||
end | ||
end) | ||
end | ||
|
||
if Config.DisablePunchingDamage then | ||
SetWeaponDamageModifier(-1569615261, 0.0) | ||
end | ||
end | ||
|
||
function stopAntiTroll() | ||
hasProtection = false | ||
timeLeft = 0 | ||
|
||
-- Anti VDM | ||
if Config.DisableVDM then | ||
SetWeaponDamageModifier(-1553120962, 1.0) | ||
end | ||
|
||
-- Anti Driveby | ||
if not Config.DriveBy then | ||
SetPlayerCanDoDriveBy(PlayerId(), true) | ||
end | ||
|
||
if Config.DisablePunching then | ||
EnableControlAction(0, 140, true) | ||
EnableControlAction(0, 141, true) | ||
EnableControlAction(0, 142, true) | ||
end | ||
|
||
if Config.DisablePunchingDamage then | ||
SetWeaponDamageModifier(-1569615261, 1.0) | ||
end | ||
setUiShow(false) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
-- old esx Support | ||
if not ESX then | ||
ESX = nil | ||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) | ||
while ESX == nil do | ||
Citizen.Wait(0) | ||
end | ||
end | ||
|
||
hasProtection = false | ||
timeLeft = 0 | ||
|
||
-- STATIC VARIABLES | ||
timeToSafe = Config.TimeToSave | ||
|
||
RegisterNetEvent("knxr-antitroll:toggle", function(toggle, timeOverride) | ||
hasProtection = toggle or not hasProtection | ||
timeLeft = timeOverride or Config.HowLong | ||
|
||
if hasProtection then | ||
startAntiTroll() | ||
else | ||
stopAntiTroll() | ||
updateTimeToDatabase(0) | ||
end | ||
end) | ||
|
||
RegisterNetEvent('esx:playerLoaded') | ||
AddEventHandler('esx:playerLoaded',function(xPlayer, isNew, skin) | ||
TriggerServerEvent("knxr-antitroll:onjoin", isNew) | ||
end) | ||
|
||
AddEventHandler("onResourceStart", function(resourceName) | ||
if resourceName == GetCurrentResourceName() then | ||
TriggerServerEvent("knxr-antitroll:onjoin", false) | ||
end | ||
-- old esx Support | ||
if not ESX then | ||
ESX = nil | ||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) | ||
while ESX == nil do | ||
Citizen.Wait(0) | ||
end | ||
end | ||
|
||
hasProtection = false | ||
timeLeft = 0 | ||
|
||
-- STATIC VARIABLES | ||
timeToSafe = Config.TimeToSave | ||
|
||
RegisterNetEvent("knxr-antitroll:toggle", function(toggle, timeOverride) | ||
hasProtection = toggle or not hasProtection | ||
timeLeft = timeOverride or Config.HowLong | ||
|
||
if hasProtection then | ||
startAntiTroll() | ||
else | ||
stopAntiTroll() | ||
updateTimeToDatabase(0) | ||
end | ||
end) | ||
|
||
RegisterNetEvent('esx:playerLoaded') | ||
AddEventHandler('esx:playerLoaded',function(xPlayer, isNew, skin) | ||
TriggerServerEvent("knxr-antitroll:onjoin", isNew) | ||
end) | ||
|
||
AddEventHandler("onResourceStart", function(resourceName) | ||
if resourceName == GetCurrentResourceName() then | ||
TriggerServerEvent("knxr-antitroll:onjoin", false) | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
Config = {} | ||
|
||
Config.AdminCommand = "troll" -- The Name of the Admin Command | ||
Config.Rang = "admin" -- The Rang needed for the Admin Command | ||
|
||
Config.HowLong = 60 -- How Long the Player should have antitroll on | ||
Config.TimeToSave = 5 -- How often the time should be saved in the Database | ||
|
||
-- SETTING FOR PLAYERS WITH ANTITROLL ON | ||
Config.DisableVDM = true -- Disables damage from cars while the player still has Troll Protection. (Players still get demage off the ground) | ||
Config.DriveBy = false -- Activates / Deactivates Drivebys | ||
Config.DisableShooting = false -- Disables Shooting | ||
Config.DisablePunching = true -- Disables hitting for players still in troll protect mode | ||
Config = {} | ||
|
||
Config.AdminCommand = "troll" -- The Name of the Admin Command | ||
Config.Rang = "admin" -- The Rang needed for the Admin Command | ||
|
||
Config.HowLong = 60 -- How Long the Player should have antitroll on | ||
Config.TimeToSave = 5 -- How often the time should be saved in the Database | ||
|
||
-- SETTING FOR PLAYERS WITH ANTITROLL ON | ||
Config.DisableVDM = true -- Disables damage from cars while the player still has Troll Protection. (Players still get demage off the ground) | ||
Config.DriveBy = false -- Activates / Deactivates Drivebys | ||
Config.DisableShooting = false -- Disables Shooting | ||
Config.DisablePunching = true -- Disables hitting for players still in troll protect mode | ||
Config.DisablePunchingDamage = true -- Disables the Damage other would get with Fists when they get Punshed |
Oops, something went wrong.