Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite chnage to optimization and remove unused file #679

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 0 additions & 101 deletions vrp/__resource.lua

This file was deleted.

6 changes: 3 additions & 3 deletions vrp/client/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Admin:__construct()
while true do
Citizen.Wait(0)
if self.noclip then
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
local x,y,z = Base:getPosition(self.noclipEntity)
local dx,dy,dz = Base:getCamDirection(self.noclipEntity)
local speed = self.noclip_speed
Expand Down Expand Up @@ -52,7 +52,7 @@ end
function Admin:toggleNoclip()
self.noclip = not self.noclip

local ped = GetPlayerPed(-1)
local ped = PlayerPedId()

if IsPedInAnyVehicle(ped, false) then
self.noclipEntity = GetVehiclePedIsIn(ped, false)
Expand All @@ -71,7 +71,7 @@ end

-- ref: https://github.com/citizenfx/project-lambdamenu/blob/master/LambdaMenu/teleportation.cpp#L301
function Admin:teleportToMarker()
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()

-- find GPS blip

Expand Down
2 changes: 1 addition & 1 deletion vrp/client/audio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Audio:__construct()
if self.vrp_voip then -- vRP voip
NetworkSetTalkerProximity(self.voip_proximity) -- disable voice chat
else -- regular voice chat
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
local proximity = vRP.cfg.voice_proximity

if IsPedSittingInAnyVehicle(ped) then
Expand Down
26 changes: 13 additions & 13 deletions vrp/client/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Base:__construct()
while true do
Citizen.Wait(10)
if self.ragdoll then
SetPedToRagdoll(GetPlayerPed(-1), 1000, 1000, 0, 0, 0, 0)
SetPedToRagdoll(PlayerPedId(), 1000, 1000, 0, 0, 0, 0)
end
end
end)
Expand All @@ -86,7 +86,7 @@ end

-- heading: (optional) entity heading
function Base:teleport(x,y,z,heading)
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
SetEntityCoords(ped, x+0.0001, y+0.0001, z+0.0001, 1,0,0,1)
if heading then SetEntityHeading(ped, heading) end
vRP:triggerEvent("playerTeleport")
Expand All @@ -95,7 +95,7 @@ end
-- teleport vehicle when inside one (placed on ground)
-- heading: (optional) entity heading
function Base:vehicleTeleport(x,y,z,heading)
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
local veh = GetVehiclePedIsIn(ped,false)

SetEntityCoords(veh, x+0.0001, y+0.0001, z+0.0001, 1,0,0,1)
Expand All @@ -106,7 +106,7 @@ end

-- return x,y,z
function Base:getPosition(entity)
if not entity then entity = GetPlayerPed(-1) end
if not entity then entity = PlayerPedId() end
local x,y,z = table.unpack(GetEntityCoords(entity,true))
return x,y,z
end
Expand All @@ -119,13 +119,13 @@ end

-- return ped speed (based on velocity)
function Base:getSpeed()
local vx,vy,vz = table.unpack(GetEntityVelocity(GetPlayerPed(-1)))
local vx,vy,vz = table.unpack(GetEntityVelocity(PlayerPedId()))
return math.sqrt(vx*vx+vy*vy+vz*vz)
end

-- return dx,dy,dz
function Base:getCamDirection(entity)
if not entity then entity = GetPlayerPed(-1) end
if not entity then entity = PlayerPedId() end
local heading = GetGameplayCamRelativeHeading()+GetEntityHeading(entity)
local pitch = GetGameplayCamRelativePitch()

Expand Down Expand Up @@ -249,7 +249,7 @@ function Base:playAnim(upper, seq, looping)
if seq.task then -- is a task (cf https://github.com/ImagicTheCat/vRP/pull/118)
self:stopAnim(true)

local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
if seq.task == "PROP_HUMAN_SEAT_CHAIR_MP_PLAYER" then -- special case, sit in a chair
local x,y,z = self:getPosition()
TaskStartScenarioAtPosition(ped, seq.task, x, y, z-1, GetEntityHeading(ped), 0, 0, false)
Expand Down Expand Up @@ -294,11 +294,11 @@ function Base:playAnim(upper, seq, looping)
if not first then inspeed = 2.0001 end
if not last then outspeed = 2.0001 end

TaskPlayAnim(GetPlayerPed(-1),dict,name,inspeed,outspeed,-1,flags,0,0,0,0)
TaskPlayAnim(PlayerPedId(),dict,name,inspeed,outspeed,-1,flags,0,0,0,0)
end

Citizen.Wait(0)
while GetEntityAnimCurrentTime(GetPlayerPed(-1),dict,name) <= 0.95 and IsEntityPlayingAnim(GetPlayerPed(-1),dict,name,3) and self.anims[id] do
while GetEntityAnimCurrentTime(PlayerPedId(),dict,name) <= 0.95 and IsEntityPlayingAnim(PlayerPedId(),dict,name,3) and self.anims[id] do
Citizen.Wait(0)
end
end
Expand All @@ -317,9 +317,9 @@ end
function Base:stopAnim(upper)
self.anims = {} -- stop all sequences
if upper then
ClearPedSecondaryTask(GetPlayerPed(-1))
ClearPedSecondaryTask(PlayerPedId())
else
ClearPedTasks(GetPlayerPed(-1))
ClearPedTasks(PlayerPedId())
end
end

Expand Down Expand Up @@ -385,9 +385,9 @@ Base.tunnel.playSound = Base.playSound
-- not working
function tvRP.setMovement(dict)
if dict then
SetPedMovementClipset(GetPlayerPed(-1),dict,true)
SetPedMovementClipset(PlayerPedId(),dict,true)
else
ResetPedMovementClipset(GetPlayerPed(-1),true)
ResetPedMovementClipset(PlayerPedId(),true)
end
end
--]]
Expand Down
12 changes: 6 additions & 6 deletions vrp/client/garage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function Garage:spawnVehicle(model, state, position, rotation)

-- spawn car
if HasModelLoaded(mhash) then
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()

local x,y,z
if position then
Expand Down Expand Up @@ -328,27 +328,27 @@ end
function Garage:putInOwnedVehicle(model)
local veh = self.vehicles[model]
if veh then
SetPedIntoVehicle(GetPlayerPed(-1),veh,-1) -- put player inside
SetPedIntoVehicle(PlayerPedId(),veh,-1) -- put player inside
end
end

-- eject the ped from the vehicle
function Garage:ejectVehicle()
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
if IsPedSittingInAnyVehicle(ped) then
local veh = GetVehiclePedIsIn(ped,false)
TaskLeaveVehicle(ped, veh, 4160)
end
end

function Garage:isInVehicle()
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
return IsPedSittingInAnyVehicle(ped)
end

-- return model or nil if not in owned vehicle
function Garage:getInOwnedVehicleModel()
local veh = GetVehiclePedIsIn(GetPlayerPed(-1),false)
local veh = GetVehiclePedIsIn(PlayerPedId(),false)
local cid, model = self:getVehicleInfo(veh)
if cid and cid == vRP.EXT.Base.cid then
return model
Expand Down Expand Up @@ -388,7 +388,7 @@ end
-- partial update per property
function Garage:setVehicleCustomization(veh, custom)
if not veh or veh == nil then
veh = GetVehiclePedIsIn(GetPlayerPed(-1),false)
veh = GetVehiclePedIsIn(PlayerPedId(),false)
end
SetVehicleModKit(veh, 0)

Expand Down
30 changes: 15 additions & 15 deletions vrp/client/player_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function PlayerState:__construct()

self.remote._update({
position = {x=x,y=y,z=z},
heading = GetEntityHeading(GetPlayerPed(-1)),
heading = GetEntityHeading(PlayerPedId()),
weapons = self:getWeapons(),
customization = self:getCustomization(),
health = self:getHealth(),
Expand All @@ -92,7 +92,7 @@ end
-- get player weapons
-- return map of name => {.ammo}
function PlayerState:getWeapons()
local player = GetPlayerPed(-1)
local player = PlayerPedId()

local ammo_types = {} -- remember ammo type to not duplicate ammo amount

Expand Down Expand Up @@ -129,7 +129,7 @@ end
-- weapons: map of name => {.ammo}
--- ammo: (optional)
function PlayerState:giveWeapons(weapons, clear_before)
local player = GetPlayerPed(-1)
local player = PlayerPedId()

-- give weapons to player

Expand All @@ -147,25 +147,25 @@ end

-- set player armour (0-100)
function PlayerState:setArmour(amount)
SetPedArmour(GetPlayerPed(-1), amount)
SetPedArmour(PlayerPedId(), amount)
end

function PlayerState:getArmour()
return GetPedArmour(GetPlayerPed(-1))
return GetPedArmour(PlayerPedId())
end

-- amount: 100-200 ?
function PlayerState:setHealth(amount)
SetEntityHealth(GetPlayerPed(-1), math.floor(amount))
SetEntityHealth(PlayerPedId(), math.floor(amount))
end

function PlayerState:getHealth()
return GetEntityHealth(GetPlayerPed(-1))
return GetEntityHealth(PlayerPedId())
end

--[[
function tvRP.dropWeapon()
SetPedDropsWeapon(GetPlayerPed(-1))
SetPedDropsWeapon(PlayerPedId())
end
--]]

Expand All @@ -177,9 +177,9 @@ function PlayerState:getDrawables(part)
local index = parseInt(args[2])

if args[1] == "prop" then
return GetNumberOfPedPropDrawableVariations(GetPlayerPed(-1),index)
return GetNumberOfPedPropDrawableVariations(PlayerPedId(),index)
elseif args[1] == "drawable" then
return GetNumberOfPedDrawableVariations(GetPlayerPed(-1),index)
return GetNumberOfPedDrawableVariations(PlayerPedId(),index)
elseif args[1] == "overlay" then
return GetNumHeadOverlayValues(index)
end
Expand All @@ -191,16 +191,16 @@ function PlayerState:getDrawableTextures(part,drawable)
local index = parseInt(args[2])

if args[1] == "prop" then
return GetNumberOfPedPropTextureVariations(GetPlayerPed(-1),index,drawable)
return GetNumberOfPedPropTextureVariations(PlayerPedId(),index,drawable)
elseif args[1] == "drawable" then
return GetNumberOfPedTextureVariations(GetPlayerPed(-1),index,drawable)
return GetNumberOfPedTextureVariations(PlayerPedId(),index,drawable)
end
end

-- get player skin customization
-- return custom parts
function PlayerState:getCustomization()
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()

local custom = {}

Expand Down Expand Up @@ -241,7 +241,7 @@ function PlayerState:setCustomization(custom)

Citizen.CreateThread(function() -- new thread
if custom then
local ped = GetPlayerPed(-1)
local ped = PlayerPedId()
local mhash = nil

-- model
Expand Down Expand Up @@ -279,7 +279,7 @@ function PlayerState:setCustomization(custom)
end
end

ped = GetPlayerPed(-1)
ped = PlayerPedId()

local is_mp = self.mp_models[GetEntityModel(ped)]

Expand Down
Loading