From 1c5594ec82b5afe2e01bedd956fc1b38c270fadd Mon Sep 17 00:00:00 2001 From: Swellington Soares Date: Thu, 20 Apr 2023 04:07:56 -0300 Subject: [PATCH 1/2] remove old entry point file. --- vrp/__resource.lua | 101 --------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 vrp/__resource.lua diff --git a/vrp/__resource.lua b/vrp/__resource.lua deleted file mode 100644 index d764c43d..00000000 --- a/vrp/__resource.lua +++ /dev/null @@ -1,101 +0,0 @@ -resource_manifest_version "44febabe-d386-4d18-afbe-5e627f4af937" - -description "RP module/framework" - -ui_page "gui/index.html" - --- server scripts -server_scripts{ - "lib/utils.lua", - "base.lua", - "modules/map.lua", - "modules/gui.lua", - "modules/audio.lua", - "modules/login.lua", - "modules/admin.lua", - "modules/identity.lua", - "modules/group.lua", - "modules/transformer.lua", - "modules/hidden_transformer.lua", - "modules/inventory.lua", - "modules/player_state.lua", - "modules/survival.lua", - "modules/money.lua", - "modules/emotes.lua", - "modules/atm.lua", - "modules/phone.lua", - "modules/aptitude.lua", - "modules/shop.lua", - "modules/skinshop.lua", - "modules/mission.lua", - "modules/cloak.lua", - "modules/garage.lua", - "modules/business.lua", - "modules/home.lua", - "modules/home_components.lua", - "modules/police.lua", - "modules/radio.lua", - "modules/ped_blacklist.lua", - "modules/veh_blacklist.lua", - "modules/edible.lua", - "modules/warp.lua", - "modules/profiler.lua" -} - --- client scripts -client_scripts{ - "lib/utils.lua", - "client/base.lua", - "client/map.lua", - "client/gui.lua", - "client/audio.lua", - "client/admin.lua", - "client/player_state.lua", - "client/survival.lua", - "client/identity.lua", - "client/phone.lua", - "client/garage.lua", - "client/police.lua", - "client/radio.lua", - "client/ped_blacklist.lua", - "client/veh_blacklist.lua", - "client/warp.lua", - "client/iplloader.lua" -} - --- client files -files{ - "lib/Luaoop.lua", - "lib/Tunnel.lua", - "lib/Proxy.lua", - "lib/IDManager.lua", - "lib/ActionDelay.lua", - "lib/Luang.lua", - "lib/ELProfiler.lua", - "client/vRP.lua", - "vRPShared.lua", - "cfg/client.lua", - "cfg/modules.lua", - "gui/index.html", - "gui/design.css", - "gui/main.js", - "gui/Menu.js", - "gui/ProgressBar.js", - "gui/WPrompt.js", - "gui/RequestManager.js", - "gui/AnnounceManager.js", - "gui/RadioDisplay.js", - "gui/Div.js", - "gui/dynamic_classes.js", - "gui/countdown.js", - "gui/AudioEngine.js", - "gui/lib/libopus.wasm.js", - "gui/images/voice_active.png", - "gui/sounds/phone_dialing.ogg", - "gui/sounds/phone_ringing.ogg", - "gui/sounds/phone_sms.ogg", - "gui/sounds/radio_on.ogg", - "gui/sounds/radio_off.ogg", - "gui/sounds/eating.ogg", - "gui/sounds/drinking.ogg" -} From 0aa8467fbedba3e2ecf5cf1d2294f3e62b087167 Mon Sep 17 00:00:00 2001 From: Swellington Soares Date: Thu, 20 Apr 2023 04:08:23 -0300 Subject: [PATCH 2/2] optimization: Change GetPlayerPed(-1) to PlayerPedId() --- vrp/client/admin.lua | 6 +++--- vrp/client/audio.lua | 2 +- vrp/client/base.lua | 26 +++++++++++++------------- vrp/client/garage.lua | 12 ++++++------ vrp/client/player_state.lua | 30 +++++++++++++++--------------- vrp/client/police.lua | 18 +++++++++--------- vrp/client/survival.lua | 8 ++++---- 7 files changed, 51 insertions(+), 51 deletions(-) diff --git a/vrp/client/admin.lua b/vrp/client/admin.lua index a368683e..f7ccd94a 100644 --- a/vrp/client/admin.lua +++ b/vrp/client/admin.lua @@ -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 @@ -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) @@ -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 diff --git a/vrp/client/audio.lua b/vrp/client/audio.lua index a0e3b808..a361a32e 100644 --- a/vrp/client/audio.lua +++ b/vrp/client/audio.lua @@ -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 diff --git a/vrp/client/base.lua b/vrp/client/base.lua index dcd30736..7103fbec 100644 --- a/vrp/client/base.lua +++ b/vrp/client/base.lua @@ -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) @@ -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") @@ -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) @@ -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 @@ -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() @@ -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) @@ -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 @@ -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 @@ -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 --]] diff --git a/vrp/client/garage.lua b/vrp/client/garage.lua index 1464ce8c..2d719cde 100644 --- a/vrp/client/garage.lua +++ b/vrp/client/garage.lua @@ -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 @@ -328,13 +328,13 @@ 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) @@ -342,13 +342,13 @@ function Garage:ejectVehicle() 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 @@ -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) diff --git a/vrp/client/player_state.lua b/vrp/client/player_state.lua index 03fe7c12..610f0b56 100644 --- a/vrp/client/player_state.lua +++ b/vrp/client/player_state.lua @@ -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(), @@ -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 @@ -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 @@ -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 --]] @@ -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 @@ -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 = {} @@ -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 @@ -279,7 +279,7 @@ function PlayerState:setCustomization(custom) end end - ped = GetPlayerPed(-1) + ped = PlayerPedId() local is_mp = self.mp_models[GetEntityModel(ped)] diff --git a/vrp/client/police.lua b/vrp/client/police.lua index 7658a0f2..58555765 100644 --- a/vrp/client/police.lua +++ b/vrp/client/police.lua @@ -29,7 +29,7 @@ function Police:__construct() while true do Citizen.Wait(0) if self.handcuffed then - SetPedStealthMovement(GetPlayerPed(-1),true,"") + SetPedStealthMovement(PlayerPedId(),true,"") DisableControlAction(0,21,true) -- disable sprint DisableControlAction(0,24,true) -- disable attack DisableControlAction(0,25,true) -- disable aim @@ -63,7 +63,7 @@ function Police:__construct() Citizen.Wait(5000) if self.follow_player then local tplayer = GetPlayerFromServerId(self.follow_player) - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() if NetworkIsPlayerConnected(tplayer) then local tped = GetPlayerPed(tplayer) TaskGoToEntity(ped, tped, -1, 1.0, 10.0, 1073741824.0, 0) @@ -85,7 +85,7 @@ function Police:__construct() local dist = math.sqrt(dx*dx+dy*dy) if dist >= self.current_jail[4] then - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() SetEntityVelocity(ped, 0.0001, 0.0001, 0.0001) -- stop player -- normalize + push to the edge + add origin @@ -123,7 +123,7 @@ function Police:__construct() Citizen.CreateThread(function() while true do Citizen.Wait(1) - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() if IsPedTryingToEnterALockedVehicle(ped) or IsPedJacking(ped) then Citizen.Wait(2000) -- wait x seconds before setting wanted local model = vRP.EXT.Garage:getNearestOwnedVehicle(5) @@ -142,7 +142,7 @@ end -- set player as cop (true or false) function Police:setCop(flag) self.cop = flag - SetPedAsCop(GetPlayerPed(-1),flag) + SetPedAsCop(PlayerPedId(),flag) end -- HANDCUFF @@ -150,12 +150,12 @@ end function Police:toggleHandcuff() self.handcuffed = not self.handcuffed - SetEnableHandcuffs(GetPlayerPed(-1), self.handcuffed) + SetEnableHandcuffs(PlayerPedId(), self.handcuffed) if self.handcuffed then vRP.EXT.Base:playAnim(true,{{"mp_arresting","idle",1}},true) else vRP.EXT.Base:stopAnim(true) - SetPedStealthMovement(GetPlayerPed(-1),false,"") + SetPedStealthMovement(PlayerPedId(),false,"") end end @@ -175,7 +175,7 @@ function Police:putInNearestVehicleAsPassenger(radius) if IsEntityAVehicle(veh) then for i=1,math.max(GetVehicleMaxNumberOfPassengers(veh),3) do if IsVehicleSeatFree(veh,i) then - SetPedIntoVehicle(GetPlayerPed(-1),veh,i) + SetPedIntoVehicle(PlayerPedId(),veh,i) return true end end @@ -192,7 +192,7 @@ function Police:followPlayer(player) self.follow_player = player if not player then -- unfollow - ClearPedTasks(GetPlayerPed(-1)) + ClearPedTasks(PlayerPedId()) end end diff --git a/vrp/client/survival.lua b/vrp/client/survival.lua index 8f447702..4cc93aec 100644 --- a/vrp/client/survival.lua +++ b/vrp/client/survival.lua @@ -28,7 +28,7 @@ function Survival:__construct() Citizen.Wait(5000) if IsPlayerPlaying(PlayerId()) then - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() local water = 0 local food = 0 @@ -73,7 +73,7 @@ function Survival:__construct() while true do Citizen.Wait(0) - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() local health = GetEntityHealth(ped) if health <= vRP.cfg.coma_threshold and self.coma_left > 0 then @@ -157,7 +157,7 @@ function Survival:__construct() end function Survival:varyHealth(variation) - local ped = GetPlayerPed(-1) + local ped = PlayerPedId() local n = math.floor(GetEntityHealth(ped)+variation) SetEntityHealth(ped,n) @@ -165,7 +165,7 @@ end function Survival:setFriendlyFire(flag) NetworkSetFriendlyFireOption(flag) - SetCanAttackFriendly(GetPlayerPed(-1), flag, flag) + SetCanAttackFriendly(PlayerPedId(), flag, flag) end function Survival:setPolice(flag)