From c4add91157f9327e55747e41a461293ab2d59d50 Mon Sep 17 00:00:00 2001 From: Mycroft Date: Thu, 29 Apr 2021 23:04:36 +0100 Subject: [PATCH] things --- client/main.lua | 47 ++++++++++++++++++++++++++++++++++----------- server/commands.lua | 31 ++++++++++++++++++++++++++++++ server/main.lua | 4 ++-- 3 files changed, 69 insertions(+), 13 deletions(-) diff --git a/client/main.lua b/client/main.lua index 11f0b9cf..27969c0c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,7 +1,13 @@ local isPaused, isDead, pickups = false, false, {} +if Config.UseKashacters then + RegisterNetEvent('esx:kashloaded') + AddEventHandler('esx:kashloaded', function() + TriggerServerEvent('esx:onPlayerJoined') + end) +else Citizen.CreateThread(function() - while not Config.UseKashacters do + while true do Citizen.Wait(0) if NetworkIsPlayerActive(PlayerId()) then @@ -10,12 +16,6 @@ Citizen.CreateThread(function() end end end) - -if Config.UseKashacters then - RegisterNetEvent('esx:kashloaded') - AddEventHandler('esx:kashloaded', function() - TriggerServerEvent('esx:onPlayerJoined') - end) end RegisterNetEvent('esx:playerLoaded') @@ -23,8 +23,8 @@ AddEventHandler('esx:playerLoaded', function(playerData) ESX.PlayerLoaded = true ESX.PlayerData = playerData - if Config.UseKashacters then - -- check if player is coming from loading screen + if not Config.UseKashacters then + if GetEntityModel(PlayerPedId()) == GetHashKey('PLAYER_ZERO') then local defaultModel = GetHashKey('a_m_y_stbla_02') RequestModel(defaultModel) @@ -37,11 +37,11 @@ AddEventHandler('esx:playerLoaded', function(playerData) SetPedDefaultComponentVariation(PlayerPedId()) SetPedRandomComponentVariation(PlayerPedId(), true) SetModelAsNoLongerNeeded(defaultModel) - end end - -- freeze the player + FreezeEntityPosition(PlayerPedId(), true) +end -- enable PVP if Config.EnablePVP then @@ -525,3 +525,28 @@ Citizen.CreateThread(function() end end end) + +RegisterNetEvent("esx:tpm") +AddEventHandler("esx:tpm", function() + local WaypointHandle = GetFirstBlipInfoId(8) + if DoesBlipExist(WaypointHandle) then + local waypointCoords = GetBlipInfoIdCoord(WaypointHandle) + + for height = 1, 1000 do + SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords["x"], waypointCoords["y"], height + 0.0) + + local foundGround, zPos = GetGroundZFor_3dCoord(waypointCoords["x"], waypointCoords["y"], height + 0.0) + + if foundGround then + SetPedCoordsKeepVehicle(PlayerPedId(), waypointCoords["x"], waypointCoords["y"], height + 0.0) + + break + end + + Citizen.Wait(5) + end + TriggerEvent('chatMessage', "Successfully Teleported") + else + TriggerEvent('chatMessage', "No Waypoint Set") + end +end) \ No newline at end of file diff --git a/server/commands.lua b/server/commands.lua index 51ddd400..888ac3d3 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -151,6 +151,37 @@ ESX.RegisterCommand('getcoords', "admin", function(xPlayer, args, showError) print("".. xPlayer.getName().. ": ".. xPlayer.getCoords(true)) end, true) +ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError) + xPlayer.triggerEvent("esx:tpm") +end, true) + +ESX.RegisterCommand('goto', "admin", function(xPlayer, args, showError) + local xTarget = ESX.GetPlayerFromId(args.playerId) + if xTarget then + local targetCoords = xTarget.getCoords() + xPlayer.setCoords(targetCoords) + xPlayer.TriggerEvent("chatMessage", "Successfully Teleported") + else + xPlayer.TriggerEvent("chatMessage", "ERROR: Player Not Online!") + end +end, true, {help = _U('goto'), validate = true, arguments = { + {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} +}}) + +ESX.RegisterCommand('bring', "admin", function(xPlayer, args, showError) + local xTarget = ESX.GetPlayerFromId(args.playerId) + if xTarget then + local playerCoords = xPlayer.getCoords() + xTarget.setCoords(playerCoords) + xPlayer.TriggerEvent("chatMessage", "Successfully Brought Player") + else + xPlayer.TriggerEvent("chatMessage", "ERROR: Player Not Online!") + end +end, true, {help = _U('goto'), validate = true, arguments = { + {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} +}}) + + ESX.RegisterCommand('getplayers', "admin", function(xPlayer, args, showError) local xAll = ESX.GetPlayers() print("^2"..#xAll.." ^3online player(s)^0") diff --git a/server/main.lua b/server/main.lua index 069eddc0..eb837d68 100644 --- a/server/main.lua +++ b/server/main.lua @@ -88,8 +88,8 @@ AddEventHandler('playerConnecting', function(name, setCallback, deferrals) identifier = v break else - identifier = string.sub(v, 9) - break + identifier = string.sub(v, 9) + break end end end