first commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
local PlayerData = nil
|
||||
|
||||
local function notify(message)
|
||||
BeginTextCommandThefeedPost('STRING')
|
||||
AddTextComponentSubstringPlayerName(message)
|
||||
EndTextCommandThefeedPostTicker(false, false)
|
||||
end
|
||||
|
||||
exports('GetPlayerData', function()
|
||||
return PlayerData
|
||||
end)
|
||||
|
||||
exports('IsPlayerLoaded', function()
|
||||
return PlayerData ~= nil
|
||||
end)
|
||||
|
||||
exports('Notify', notify)
|
||||
|
||||
RegisterNetEvent('devx_core:client:playerData', function(data)
|
||||
PlayerData = data
|
||||
LocalPlayer.state:set('devxCharacterId', data.characterId, true)
|
||||
TriggerEvent('devx_core:client:playerLoaded', data)
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(DevXConfig.PositionSaveIntervalMs)
|
||||
if PlayerData then
|
||||
local ped = PlayerPedId()
|
||||
if DoesEntityExist(ped) and not IsEntityDead(ped) then
|
||||
local coords = GetEntityCoords(ped)
|
||||
TriggerServerEvent('devx_core:server:updatePosition', {
|
||||
x = coords.x,
|
||||
y = coords.y,
|
||||
z = coords.z,
|
||||
heading = GetEntityHeading(ped)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterCommand('coords', function()
|
||||
local ped = PlayerPedId()
|
||||
local coords = GetEntityCoords(ped)
|
||||
local text = ('vector4(%.2f, %.2f, %.2f, %.2f)'):format(
|
||||
coords.x, coords.y, coords.z, GetEntityHeading(ped)
|
||||
)
|
||||
print(text)
|
||||
notify(text)
|
||||
end, false)
|
||||
|
||||
RegisterCommand('unstuck', function()
|
||||
if not PlayerData then return end
|
||||
local spawn = DevXConfig.StreetSpawn
|
||||
SetEntityCoords(PlayerPedId(), spawn.x, spawn.y, spawn.z, false, false, false, false)
|
||||
SetEntityHeading(PlayerPedId(), spawn.heading)
|
||||
notify('Du wurdest zum Straßenstart teleportiert.')
|
||||
end, false)
|
||||
|
||||
RegisterNetEvent('devx_core:client:returnedToWorld', function()
|
||||
notify('Du wurdest in die öffentliche Welt zurückgesetzt.')
|
||||
end)
|
||||
Reference in New Issue
Block a user