From 5b1e5b9ea40edb4a7eaad592bcba91b04bb76b5c Mon Sep 17 00:00:00 2001 From: Mycroft Date: Mon, 3 May 2021 23:32:02 +0100 Subject: [PATCH] add more commands --- client/main.lua | 89 +++++++++++++++++++++++++++++++++++++++++++++ server/commands.lua | 32 +++++++++++++++- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/client/main.lua b/client/main.lua index 2f797cdb..27ad5e95 100644 --- a/client/main.lua +++ b/client/main.lua @@ -492,6 +492,8 @@ Citizen.CreateThread(function() end end) +----- Admin commnads from esx_adminplus + RegisterNetEvent("esx:tpm") AddEventHandler("esx:tpm", function() local WaypointHandle = GetFirstBlipInfoId(8) @@ -516,3 +518,90 @@ AddEventHandler("esx:tpm", function() TriggerEvent('chatMessage', "No Waypoint Set") end end) + +local noclip = false +RegisterNetEvent("esx:noclip") +AddEventHandler("esx:noclip", function(input) + local player = PlayerId() + local ped = PlayerPedId + + local msg = "disabled" + if(noclip == false)then + noclip_pos = GetEntityCoords(PlayerPedId(), false) + end + + noclip = not noclip + + if(noclip)then + msg = "enabled" + end + + TriggerEvent("chatMessage", "Noclip has been ^2^*" .. msg) + end) + + local heading = 0 + Citizen.CreateThread(function() + while true do + Citizen.Wait(0) + + if(noclip)then + SetEntityCoordsNoOffset(PlayerPedId(), noclip_pos.x, noclip_pos.y, noclip_pos.z, 0, 0, 0) + + if(IsControlPressed(1, 34))then + heading = heading + 1.5 + if(heading > 360)then + heading = 0 + end + + SetEntityHeading(PlayerPedId(), heading) + end + + if(IsControlPressed(1, 9))then + heading = heading - 1.5 + if(heading < 0)then + heading = 360 + end + + SetEntityHeading(PlayerPedId(), heading) + end + + if(IsControlPressed(1, 8))then + noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 1.0, 0.0) + end + + if(IsControlPressed(1, 32))then + noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, -1.0, 0.0) + end + + if(IsControlPressed(1, 27))then + noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, 1.0) + end + + if(IsControlPressed(1, 173))then + noclip_pos = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, -1.0) + end + else + Citizen.Wait(200) + end + end +end) + +RegisterNetEvent("esx:killPlayer") +AddEventHandler("esx:killPlayer", function() + SetEntityHealth(PlayerPedId(), 0) +end) + +RegisterNetEvent("esx:freezePlayer") +AddEventHandler("esx:freezePlayer", function(input) + local player = PlayerId() + local ped = PlayerPedId() + if input == 'freeze' then + SetEntityCollision(ped, false) + FreezeEntityPosition(ped, true) + SetPlayerInvincible(player, true) + elseif input == 'unfreeze' then + SetEntityCollision(ped, true) + FreezeEntityPosition(ped, false) + SetPlayerInvincible(player, false) + end +end) diff --git a/server/commands.lua b/server/commands.lua index 17bd6aa9..f636fdeb 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -189,10 +189,38 @@ end, true, {help = _U('goto'), validate = true, arguments = { ESX.RegisterCommand('bring', "admin", function(xPlayer, args, showError) local playerCoords = xPlayer.getCoords() args.playerId.setCoords(playerCoords) -end, true, {help = _U('goto'), validate = true, arguments = { +end, true, {help = _U('bring'), validate = true, arguments = { {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} }}) +ESX.RegisterCommand('kill', "admin", function(xPlayer, args, showError) + args.playerId.triggerEvent('esx:killPlayer') +end, true, {help = _U('kill'), validate = true, arguments = { +{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} +}}) + +ESX.RegisterCommand('freeze', "admin", function(xPlayer, args, showError) + args.playerId.triggerEvent('esx:freezePlayer', "freeze") +end, true, {help = _U('kill'), validate = true, arguments = { +{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} +}}) + +ESX.RegisterCommand('unfreeze', "admin", function(xPlayer, args, showError) + args.playerId.triggerEvent('esx:freezePlayer', "unfreeze") +end, true, {help = _U('kill'), validate = true, arguments = { +{name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} +}}) + +ESX.RegisterCommand('reviveall', "admin", function(xPlayer, args, showError) + for _, playerId in ipairs(GetPlayers()) do + TriggerClientEvent('esx_ambulancejob:revive', playerId) + end +end, false, {help = "reviveall")}) + +ESX.RegisterCommand("noclip", 'admin', function(xPlayer, args, showError) + xPlayer.triggerEvent('esx:noclip') +end, false, {help = "noclip")}) + ESX.RegisterCommand('players', "admin", function(xPlayer, args, showError) local xAll = ESX.GetPlayers() print("^5"..#xAll.." ^2online player(s)^0") @@ -200,4 +228,4 @@ ESX.RegisterCommand('players', "admin", function(xPlayer, args, showError) local xPlayer = ESX.GetPlayerFromId(xAll[i]) print("^1[ ^2ID : ^5"..xPlayer.source.." ^0| ^2Name : ^5"..xPlayer.getName().." ^0 | ^2Group : ^5"..xPlayer.getGroup().." ^0 | ^2Identifier : ^5".. xPlayer.identifier .."^1]^0\n") end -end, true) \ No newline at end of file +end, true)