diff --git a/vrp/cfg/lang/en.lua b/vrp/cfg/lang/en.lua index 035af037..2893e2d0 100644 --- a/vrp/cfg/lang/en.lua +++ b/vrp/cfg/lang/en.lua @@ -70,6 +70,9 @@ local lang = { }, noclip = { title = "Noclip" + }, + noclipveh = { + title = "Noclip with Vehicle" }, coords = { title = "Coords", diff --git a/vrp/cfg/lang/fr.lua b/vrp/cfg/lang/fr.lua index 91057898..8c02007d 100644 --- a/vrp/cfg/lang/fr.lua +++ b/vrp/cfg/lang/fr.lua @@ -69,6 +69,9 @@ local lang = { }, noclip = { title = "Noclip" + }, + noclipveh = { + title = "Noclip with Vehicle" }, coords = { title = "Coords", diff --git a/vrp/cfg/lang/pt-br.lua b/vrp/cfg/lang/pt-br.lua index 937efd73..a1ac2fa4 100644 --- a/vrp/cfg/lang/pt-br.lua +++ b/vrp/cfg/lang/pt-br.lua @@ -50,6 +50,9 @@ local lang = { }, noclip = { title = "NOCLIP" + }, + noclipveh = { + title = "Noclip com veĆ­culo" }, coords = { title = "SUA CORDENADA", diff --git a/vrp/client/admin.lua b/vrp/client/admin.lua index b281abd6..202c3385 100644 --- a/vrp/client/admin.lua +++ b/vrp/client/admin.lua @@ -11,6 +11,7 @@ function Admin:__construct() vRP.Extension.__construct(self) self.noclip = false + self.noclipEntity = nil self.noclip_speed = 1.0 -- noclip task @@ -21,12 +22,12 @@ function Admin:__construct() Citizen.Wait(0) if self.noclip then local ped = GetPlayerPed(-1) - local x,y,z = Base:getPosition() - local dx,dy,dz = Base:getCamDirection() + local x,y,z = Base:getPosition(self.noclipEntity) + local dx,dy,dz = Base:getCamDirection(self.noclipEntity) local speed = self.noclip_speed -- reset velocity - SetEntityVelocity(ped, 0.0001, 0.0001, 0.0001) + SetEntityVelocity(self.noclipEntity, 0.0001, 0.0001, 0.0001) -- forward if IsControlPressed(0,32) then -- MOVE UP @@ -42,23 +43,29 @@ function Admin:__construct() z = z-speed*dz end - SetEntityCoordsNoOffset(ped,x,y,z,true,true,true) + SetEntityCoordsNoOffset(self.noclipEntity,x,y,z,true,true,true) end end end) end -function Admin:toggleNoclip() +function Admin:toggleNoclip(inVeh) self.noclip = not self.noclip - local ped = GetPlayerPed(-1) - if self.noclip then -- set - SetEntityInvincible(ped, true) - SetEntityVisible(ped, false, false) - else -- unset - SetEntityInvincible(ped, false) - SetEntityVisible(ped, true, false) + + if inVeh then + self.noclipEntity = GetVehiclePedIsIn(ped, false) + else + self.noclipEntity = ped end + + SetEntityCollision(self.noclipEntity, not self.noclip, not self.noclip) + SetEntityInvincible(self.noclipEntity, self.noclip) + SetEntityVisible(self.noclipEntity, not self.noclip, false) + + -- rotate entity + vx,vy,vz = GetGameplayCamRot(2) + SetEntityRotation(self.noclipEntity, vx, nil, nil, 0, false) end -- ref: https://github.com/citizenfx/project-lambdamenu/blob/master/LambdaMenu/teleportation.cpp#L301 diff --git a/vrp/client/base.lua b/vrp/client/base.lua index b587c63e..dcd30736 100644 --- a/vrp/client/base.lua +++ b/vrp/client/base.lua @@ -105,8 +105,9 @@ function Base:vehicleTeleport(x,y,z,heading) end -- return x,y,z -function Base:getPosition() - local x,y,z = table.unpack(GetEntityCoords(GetPlayerPed(-1),true)) +function Base:getPosition(entity) + if not entity then entity = GetPlayerPed(-1) end + local x,y,z = table.unpack(GetEntityCoords(entity,true)) return x,y,z end @@ -123,8 +124,9 @@ function Base:getSpeed() end -- return dx,dy,dz -function Base:getCamDirection() - local heading = GetGameplayCamRelativeHeading()+GetEntityHeading(GetPlayerPed(-1)) +function Base:getCamDirection(entity) + if not entity then entity = GetPlayerPed(-1) end + local heading = GetGameplayCamRelativeHeading()+GetEntityHeading(entity) local pitch = GetGameplayCamRelativePitch() local x = -math.sin(heading*math.pi/180.0) diff --git a/vrp/modules/admin.lua b/vrp/modules/admin.lua index c2b92a24..80a2359b 100644 --- a/vrp/modules/admin.lua +++ b/vrp/modules/admin.lua @@ -205,6 +205,10 @@ local function menu_admin(self) local function m_noclip(menu) self.remote._toggleNoclip(menu.user.source) end + + local function m_noclip_vehicle(menu,inVeh) + self.remote._toggleNoclip(menu.user.source,inVeh) + end vRP.EXT.GUI:registerMenuBuilder("admin", function(menu) local user = menu.user @@ -226,6 +230,12 @@ local function menu_admin(self) end if user:hasPermission("player.noclip") then menu:addOption(lang.admin.noclip.title(), m_noclip) + end + if user:hasPermission("player.noclip") then + local inVeh = vRP.EXT.Garage.remote.isInVehicle(user.source) + if inVeh then + menu:addOption(lang.admin.noclipveh.title(), m_noclip_vehicle, inVeh) + end end if user:hasPermission("player.coords") then menu:addOption(lang.admin.coords.title(), m_coords)