mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Change coord grabbing back to client
This commit is contained in:
+5
-2
@@ -105,12 +105,15 @@ end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerData')
|
||||
AddEventHandler('QBCore:Player:UpdatePlayerData', function()
|
||||
TriggerServerEvent('QBCore:UpdatePlayer')
|
||||
local data = {}
|
||||
data.position = QBCore.Functions.GetCoords(PlayerPedId())
|
||||
TriggerServerEvent('QBCore:UpdatePlayer', data)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerPosition')
|
||||
AddEventHandler('QBCore:Player:UpdatePlayerPosition', function()
|
||||
TriggerServerEvent('QBCore:UpdatePlayerPosition')
|
||||
local position = QBCore.Functions.GetCoords(PlayerPedId())
|
||||
TriggerServerEvent('QBCore:UpdatePlayerPosition', position)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:LocalOutOfCharacter')
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(7)
|
||||
if isLoggedIn then
|
||||
Citizen.Wait((1000 * 60) * 10)
|
||||
Citizen.Wait((1000 * 60) * 5)
|
||||
TriggerEvent("QBCore:Player:UpdatePlayerData")
|
||||
else
|
||||
Citizen.Wait(5000)
|
||||
|
||||
+3
-11
@@ -87,33 +87,25 @@ AddEventHandler('QBCore:server:OpenServer', function()
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:UpdatePlayer")
|
||||
AddEventHandler('QBCore:UpdatePlayer', function()
|
||||
AddEventHandler('QBCore:UpdatePlayer', function(data)
|
||||
local src = source
|
||||
local entity = GetPlayerPed(src)
|
||||
local position = QBCore.Functions.GetEntityCoords(entity)
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if Player ~= nil then
|
||||
Player.PlayerData.position = position
|
||||
|
||||
Player.PlayerData.position = data.position
|
||||
local newHunger = Player.PlayerData.metadata["hunger"] - 4.2
|
||||
local newThirst = Player.PlayerData.metadata["thirst"] - 3.8
|
||||
if newHunger <= 0 then newHunger = 0 end
|
||||
if newThirst <= 0 then newThirst = 0 end
|
||||
Player.Functions.SetMetaData("thirst", newThirst)
|
||||
Player.Functions.SetMetaData("hunger", newHunger)
|
||||
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, newHunger, newThirst)
|
||||
|
||||
Player.Functions.Save()
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:UpdatePlayerPosition")
|
||||
AddEventHandler("QBCore:UpdatePlayerPosition", function()
|
||||
AddEventHandler("QBCore:UpdatePlayerPosition", function(position)
|
||||
local src = source
|
||||
local entity = GetPlayerPed(src)
|
||||
local position = QBCore.Functions.GetEntityCoords(entity)
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if Player ~= nil then
|
||||
Player.PlayerData.position = position
|
||||
|
||||
Reference in New Issue
Block a user