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

Noclip with Vehicle #662

Closed
wants to merge 4 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
3 changes: 3 additions & 0 deletions vrp/cfg/lang/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ local lang = {
},
noclip = {
title = "Noclip"
},
noclipveh = {
title = "Noclip with Vehicle"
},
coords = {
title = "Coords",
Expand Down
3 changes: 3 additions & 0 deletions vrp/cfg/lang/fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ local lang = {
},
noclip = {
title = "Noclip"
},
noclipveh = {
title = "Noclip with Vehicle"
},
coords = {
title = "Coords",
Expand Down
3 changes: 3 additions & 0 deletions vrp/cfg/lang/pt-br.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ local lang = {
},
noclip = {
title = "NOCLIP"
},
noclipveh = {
title = "Noclip com veículo"
},
coords = {
title = "SUA CORDENADA",
Expand Down
31 changes: 19 additions & 12 deletions vrp/client/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function Admin:__construct()
vRP.Extension.__construct(self)

self.noclip = false
self.noclipEntity = nil
self.noclip_speed = 1.0

-- noclip task
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions vrp/client/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions vrp/modules/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down