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

V3 fxmanifest swap, added Commands & Misc modules and some updates #670

Merged
merged 4 commits into from
Jun 19, 2022
Merged
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
63 changes: 0 additions & 63 deletions vrp/__resource.lua

This file was deleted.

3 changes: 3 additions & 0 deletions vrp/cfg/lang/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ local lang = {
kick = {
title = "Kick",
prompt = "Reason: "
},
spectate = {
title = "Spectate"
},
tptome = {
title = "TpToMe"
Expand Down
2 changes: 2 additions & 0 deletions vrp/cfg/modules.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ local modules = {
gui = true,
map = true,
weather = true,
misc = true,
command = true
}

return modules
20 changes: 20 additions & 0 deletions vrp/client/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function Admin:__construct()
vRP.Extension.__construct(self)

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

Expand Down Expand Up @@ -69,6 +71,23 @@ function Admin:toggleNoclip()
SetEntityRotation(self.noclipEntity, vx, nil, nil, 0, false)
end

function Admin:toggleSpectate(target)
self.spectate = not self.spectate
self.lastCoord = GetEntityCoords(user)

local user = PlayerPedId()
local targetUser = GetPlayerFromServerId(target)
local tuser = GetPlayerPed(targetUser)

SetEntityCollision(user, not self.spectate, not self.spectate)
SetEntityInvincible(user, self.spectate)
SetEntityVisible(user, not self.spectate, false)
NetworkSetEntityInvisibleToNetwork(user, true)
NetworkSetInSpectatorMode(self.spectate, target)

SetEntityCoords(user, self.lastCoord)
end

-- ref: https://github.com/citizenfx/project-lambdamenu/blob/master/LambdaMenu/teleportation.cpp#L301
function Admin:teleportToMarker()
local ped = GetPlayerPed(-1)
Expand Down Expand Up @@ -113,6 +132,7 @@ end

Admin.tunnel = {}
Admin.tunnel.toggleNoclip = Admin.toggleNoclip
Admin.tunnel.toggleSpectate = Admin.toggleSpectate
Admin.tunnel.teleportToMarker = Admin.teleportToMarker

vRP:registerExtension(Admin)
13 changes: 13 additions & 0 deletions vrp/client/commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- https://github.com/ImagicTheCat/vRP
-- MIT license (see LICENSE or vrp/vRPShared.lua)
if not vRP.modules.command then return end

local Command = class("Command", vRP.Extension)

function Command:__construct()
vRP.Extension.__construct(self)

end


vRP:registerExtension(Command)
82 changes: 82 additions & 0 deletions vrp/client/misc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
-- https://github.com/ImagicTheCat/vRP
-- MIT license (see LICENSE or vrp/vRPShared.lua)
if not vRP.modules.misc then return end

local Misc = class("Misc", vRP.Extension)

function Misc:__construct()
vRP.Extension.__construct(self)
end

function Misc:getClosestPeds(radius) -- gets all nearby ped
local r = {}
local px,py,pz = table.unpack(GetEntityCoords(GetPlayerPed(-1)))

for _,pedAI in ipairs(GetGamePool('CPed')) do
if pedAI ~= GetPlayerPed(-1) then
local x,y,z = table.unpack(GetEntityCoords(pedAI))
local dist = GetDistanceBetweenCoords(x,y,z,px,py,pz,true)
if dist <= radius then
r[pedAI] = dist
end
end
end

return r
end

function Misc:getClosestPed(radius) --gets closest ped
local p = nil

local ai = self:getClosestPeds(radius)
local min = radius+10.0
for k,v in pairs(ai) do
if v < min then
min = v
p = k
end
end

return p
end

function Misc:getClosestObjects(radius) -- gets all nearby objects
local r = {}
local px,py,pz = table.unpack(GetEntityCoords(GetPlayerPed(-1)))

for _,obj in ipairs(GetGamePool('CObject')) do
if obj ~= GetPlayerPed(-1) then
local x,y,z = table.unpack(GetEntityCoords(obj))
local dist = GetDistanceBetweenCoords(x,y,z,px,py,pz,true)
if dist <= radius then
r[obj] = dist
end
end
end

return r
end

function Misc:getClosestObject(radius) --gets closest object
local p = nil

local obj = self:getClosestObjects(radius)
local min = radius+10.0
for k,v in pairs(obj) do
if v < min then
min = v
p = k
end
end

return p
end

Misc.tunnel = {}

Misc.tunnel.getClosestObject = Misc.getClosestObject
Misc.tunnel.getClosestObjects = Misc.getClosestObjects
Misc.tunnel.getClosestPed = Misc.getClosestPed
Misc.tunnel.getClosestPeds = Misc.getClosestPeds

vRP:registerExtension(Misc)
1 change: 1 addition & 0 deletions vrp/client/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ end

function Weather:toggleFreeze()
self.freeze = not self.freeze
SetMillisecondsPerGameMinute(self.normal)
local hours, minutes, seconds = GetClockHours(), GetClockMinutes(), GetClockSeconds()

while self.freeze do
Expand Down
29 changes: 15 additions & 14 deletions vrp/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
fx_version "adamant"
games {"gta5"}
fx_version 'cerulean'
games { 'gta5' }

description "RP module/framework"
version '3.0.1'

ui_page "gui/index.html"

-- server scripts
server_scripts{
"lib/utils.lua",
shared_script {
"lib/utils.lua"
}

server_script {
"base.lua",
"modules/map.lua",
"modules/gui.lua",
"modules/admin.lua",
"modules/group.lua",
"modules/weather.lua"
"modules/weather.lua",
"modules/commands.lua"
}

-- client scripts
client_scripts{
"lib/utils.lua",
client_scripts {
"client/base.lua",
"client/map.lua",
"client/gui.lua",
"client/admin.lua",
"client/weather.lua"
"client/weather.lua",
"client/commands.lua"
}

-- client files
files{
files {
"lib/Luaoop.lua",
"lib/Tunnel.lua",
"lib/Proxy.lua",
Expand All @@ -38,7 +40,6 @@ files{
"client/vRP.lua",
"vRPShared.lua",
"cfg/client.lua",
"cfg/control.lua",
"cfg/modules.lua",
"gui/index.html",
"gui/design.css",
Expand All @@ -62,4 +63,4 @@ files{
"gui/sounds/radio_off.ogg",
"gui/sounds/eating.ogg",
"gui/sounds/drinking.ogg"
}
}
8 changes: 4 additions & 4 deletions vrp/gui/AudioEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function AudioEngine()
var peer = channel.players[player];
if(peer.speaking && time - peer.last_packet_time >= 500){ // event
peer.speaking = false;
$.post("http://vrp/audio", JSON.stringify({act: "voice_channel_player_speaking_change", channel: peer.channel, player: peer.player, speaking: peer.speaking}));
$.post("https://vrp/audio", JSON.stringify({act: "voice_channel_player_speaking_change", channel: peer.channel, player: peer.player, speaking: peer.speaking}));
}
}
}
Expand Down Expand Up @@ -445,7 +445,7 @@ AudioEngine.prototype.connectVoIP = function()
peer.last_packet_time = new Date().getTime();
if(!peer.speaking){
peer.speaking = true;
$.post("http://vrp/audio", JSON.stringify({act: "voice_channel_player_speaking_change", channel: peer.channel, player: peer.player, speaking: peer.speaking}));
$.post("https://vrp/audio", JSON.stringify({act: "voice_channel_player_speaking_change", channel: peer.channel, player: peer.player, speaking: peer.speaking}));
}

peer.psamples.push(samples);
Expand Down Expand Up @@ -713,7 +713,7 @@ AudioEngine.prototype.disconnectVoice = function(data)

if(peer.speaking){ // event
peer.speaking = false;
$.post("http://vrp/audio", JSON.stringify({act: "voice_channel_player_speaking_change", channel: peer.channel, player: peer.player, speaking: peer.speaking}));
$.post("https://vrp/audio", JSON.stringify({act: "voice_channel_player_speaking_change", channel: peer.channel, player: peer.player, speaking: peer.speaking}));
}

// dereference channel
Expand Down Expand Up @@ -768,5 +768,5 @@ AudioEngine.prototype.channelTransmittingCheck = function(channel)

// event
if(channel.transmitting != old_transmitting)
$.post("http://vrp/audio", JSON.stringify({act: "voice_channel_transmitting_change", channel: channel.id, transmitting: channel.transmitting}));
$.post("https://vrp/audio", JSON.stringify({act: "voice_channel_transmitting_change", channel: channel.id, transmitting: channel.transmitting}));
}
2 changes: 1 addition & 1 deletion vrp/gui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
LIBOPUS_WASM_URL = "http://cdn.jsdelivr.net/gh/ImagicTheCat/libopusjs@7b92b296f24a5c9de57499db803df6bb7636a581/dist/libopus.wasm"; //fix for "nui://" fetch requests
LIBOPUS_WASM_URL = "https://cdn.jsdelivr.net/gh/ImagicTheCat/libopusjs@7b92b296f24a5c9de57499db803df6bb7636a581/dist/libopus.wasm"; //fix for "nui://" fetch requests
</script>
<script src="lib/libopus.wasm.js" type="text/javascript"></script>
<script src="dynamic_classes.js" type="text/javascript"></script>
Expand Down
5,622 changes: 5,621 additions & 1 deletion vrp/gui/lib/libopus.wasm.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions vrp/gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ window.addEventListener("load",function(){
var radio_display = new RadioDisplay();
var aengine = new AudioEngine();

requestmgr.onResponse = function(id,ok){ $.post("http://vrp/request",JSON.stringify({act: "response", id: id, ok: ok})); }
wprompt.onClose = function(){ $.post("http://vrp/prompt",JSON.stringify({act: "close", result: wprompt.result})); }
dynamic_menu.onValid = function(option,mod){ $.post("http://vrp/menu",JSON.stringify({act: "valid", option: option, mod: mod})); }
requestmgr.onResponse = function(id,ok){ $.post("https://vrp/request",JSON.stringify({act: "response", id: id, ok: ok})); }
wprompt.onClose = function(){ $.post("https://vrp/prompt",JSON.stringify({act: "close", result: wprompt.result})); }
dynamic_menu.onValid = function(option,mod){ $.post("https://vrp/menu",JSON.stringify({act: "valid", option: option, mod: mod})); }
var select_event = false;
dynamic_menu.onSelect = function(option){
if(select_event){
$.post("http://vrp/menu",JSON.stringify({act: "select", option: option}));
$.post("https://vrp/menu",JSON.stringify({act: "select", option: option}));
}
}

//init
$.post("http://vrp/init","");
$.post("https://vrp/init","");

var pbars = {}
var divs = {}
Expand Down
Loading