mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 00:01:22 +00:00
Replace PlayerPed
This commit is contained in:
+10
-10
@@ -2,7 +2,7 @@
|
||||
RegisterNetEvent('QBCore:Command:TeleportToPlayer')
|
||||
AddEventHandler('QBCore:Command:TeleportToPlayer', function(othersource)
|
||||
local coords = QBCore.Functions.GetCoords(GetPlayerPed(GetPlayerFromServerId(othersource)))
|
||||
local entity = GetPlayerPed(-1)
|
||||
local entity = PlayerPedId()
|
||||
if IsPedInAnyVehicle(Entity, false) then
|
||||
entity = GetVehiclePedIsUsing(entity)
|
||||
end
|
||||
@@ -12,7 +12,7 @@ end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:TeleportToCoords')
|
||||
AddEventHandler('QBCore:Command:TeleportToCoords', function(x, y, z)
|
||||
local entity = GetPlayerPed(-1)
|
||||
local entity = PlayerPedId()
|
||||
if IsPedInAnyVehicle(Entity, false) then
|
||||
entity = GetVehiclePedIsUsing(entity)
|
||||
end
|
||||
@@ -22,7 +22,7 @@ end)
|
||||
RegisterNetEvent('QBCore:Command:SpawnVehicle')
|
||||
AddEventHandler('QBCore:Command:SpawnVehicle', function(model)
|
||||
QBCore.Functions.SpawnVehicle(model, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(GetPlayerPed(-1), vehicle, -1)
|
||||
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
|
||||
TriggerEvent("vehiclekeys:client:SetOwner", GetVehicleNumberPlateText(vehicle))
|
||||
end)
|
||||
end)
|
||||
@@ -30,17 +30,17 @@ end)
|
||||
RegisterNetEvent('QBCore:Command:DeleteVehicle')
|
||||
AddEventHandler('QBCore:Command:DeleteVehicle', function()
|
||||
local vehicle = QBCore.Functions.GetClosestVehicle()
|
||||
if IsPedInAnyVehicle(GetPlayerPed(-1)) then vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) else vehicle = QBCore.Functions.GetClosestVehicle() end
|
||||
if IsPedInAnyVehicle(PlayerPedId()) then vehicle = GetVehiclePedIsIn(PlayerPedId(), false) else vehicle = QBCore.Functions.GetClosestVehicle() end
|
||||
-- TriggerServerEvent('QBCore:Command:CheckOwnedVehicle', GetVehicleNumberPlateText(vehicle))
|
||||
QBCore.Functions.DeleteVehicle(vehicle)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:Revive')
|
||||
AddEventHandler('QBCore:Command:Revive', function()
|
||||
local coords = QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
local coords = QBCore.Functions.GetCoords(PlayerPedId())
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z+0.2, coords.a, true, false)
|
||||
SetPlayerInvincible(GetPlayerPed(-1), false)
|
||||
ClearPedBloodDamage(GetPlayerPed(-1))
|
||||
SetPlayerInvincible(PlayerPedId(), false)
|
||||
ClearPedBloodDamage(PlayerPedId())
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:GoToMarker')
|
||||
@@ -114,20 +114,20 @@ end)
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerData')
|
||||
AddEventHandler('QBCore:Player:UpdatePlayerData', function()
|
||||
local data = {}
|
||||
data.position = QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
data.position = QBCore.Functions.GetCoords(PlayerPedId())
|
||||
TriggerServerEvent('QBCore:UpdatePlayer', data)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerPosition')
|
||||
AddEventHandler('QBCore:Player:UpdatePlayerPosition', function()
|
||||
local position = QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
local position = QBCore.Functions.GetCoords(PlayerPedId())
|
||||
TriggerServerEvent('QBCore:UpdatePlayerPosition', position)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:LocalOutOfCharacter')
|
||||
AddEventHandler('QBCore:Client:LocalOutOfCharacter', function(playerId, playerName, message)
|
||||
local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(playerId)), false)
|
||||
local pos = GetEntityCoords(GetPlayerPed(-1), false)
|
||||
local pos = GetEntityCoords(PlayerPedId(), false)
|
||||
if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true) < 20.0) then
|
||||
TriggerEvent("chatMessage", "OOC " .. playerName, "normal", message)
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ end
|
||||
|
||||
QBCore.Functions.SpawnVehicle = function(model, cb, coords, isnetworked)
|
||||
local model = (type(model)=="number" and model or GetHashKey(model))
|
||||
local coords = coords ~= nil and coords or QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
local coords = coords ~= nil and coords or QBCore.Functions.GetCoords(PlayerPedId())
|
||||
local isnetworked = isnetworked ~= nil and isnetworked or true
|
||||
|
||||
RequestModel(model)
|
||||
@@ -159,7 +159,7 @@ end
|
||||
|
||||
QBCore.Functions.GetClosestVehicle = function(coords)
|
||||
--[[local coordFrom = coords
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if coordFrom == nil then
|
||||
coordFrom = GetEntityCoords(playerPed)
|
||||
@@ -171,7 +171,7 @@ QBCore.Functions.GetClosestVehicle = function(coords)
|
||||
local vehicle
|
||||
|
||||
for i = 0, 100 do
|
||||
rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, GetPlayerPed(-1), 0)
|
||||
rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, PlayerPedId(), 0)
|
||||
a, b, c, d, vehicle = GetRaycastResult(rayHandle)
|
||||
|
||||
offset = offset - 1
|
||||
@@ -213,7 +213,7 @@ QBCore.Functions.GetClosestPed = function(coords, ignoreList)
|
||||
local closestPed = -1
|
||||
|
||||
if coords == nil then
|
||||
coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
coords = GetEntityCoords(PlayerPedId())
|
||||
end
|
||||
|
||||
for i=1, #peds, 1 do
|
||||
@@ -232,7 +232,7 @@ end
|
||||
|
||||
QBCore.Functions.GetClosestPlayer = function(coords)
|
||||
if coords == nil then
|
||||
coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
coords = GetEntityCoords(PlayerPedId())
|
||||
end
|
||||
|
||||
local closestPlayers = QBCore.Functions.GetPlayersFromCoords(coords)
|
||||
@@ -259,7 +259,7 @@ QBCore.Functions.GetPlayersFromCoords = function(coords, distance)
|
||||
local closePlayers = {}
|
||||
|
||||
if coords == nil then
|
||||
coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
coords = GetEntityCoords(PlayerPedId())
|
||||
end
|
||||
if distance == nil then
|
||||
distance = 5.0
|
||||
|
||||
@@ -38,7 +38,7 @@ Citizen.CreateThread(function()
|
||||
Citizen.Wait(math.random(3000, 5000))
|
||||
if isLoggedIn then
|
||||
if QBCore.Functions.GetPlayerData().metadata["hunger"] <= 0 or QBCore.Functions.GetPlayerData().metadata["thirst"] <= 0 then
|
||||
local ped = GetPlayerPed(-1)
|
||||
local ped = PlayerPedId()
|
||||
local currentHealth = GetEntityHealth(ped)
|
||||
|
||||
SetEntityHealth(ped, currentHealth - math.random(5, 10))
|
||||
|
||||
Reference in New Issue
Block a user