Skip to content

Commit

Permalink
Merge pull request #671 from Boss-Man-Dev/v3
Browse files Browse the repository at this point in the history
V3 Updated fxmanifest, Admin, Commands and Misc Modules
  • Loading branch information
Sharky521 authored Jun 21, 2022
2 parents f0326c6 + f428443 commit 7a0ccb1
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 41 deletions.
51 changes: 51 additions & 0 deletions vrp/cfg/commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local cfg = {}

cfg.weapons = {
"WEAPON_ADVANCEDRIFLE",
"WEAPON_AIRSTRIKE_ROCKET",
"WEAPON_APPISTOL",
"WEAPON_ASSAULTRIFLE",
"WEAPON_ASSAULTSHOTGUN",
"WEAPON_ASSAULTSMG",
"WEAPON_BALL",
"WEAPON_BAT",
"WEAPON_BULLPUPSHOTGUN",
"WEAPON_CARBINERIFLE",
"WEAPON_COMBATMG",
"WEAPON_COMBATPISTOL",
"WEAPON_COMPACTRIFLE",
"WEAPON_CROWBAR",
"WEAPON_FIREEXTINGUISHER",
"WEAPON_FIREWORK",
"WEAPON_FLARE",
"WEAPON_FLAREGUN",
"WEAPON_FLASHLIGHT",
"WEAPON_GOLFCLUB",
"WEAPON_GRENADE",
"WEAPON_GRENADELAUNCHER",
"WEAPON_HAMMER",
"WEAPON_HEAVYPISTOL",
"WEAPON_HEAVYREVOLVER",
"WEAPON_HEAVYSNIPER",
"WEAPON_KNIFE",
"WEAPON_MARKSMANRIFLE",
"WEAPON_MG",
"WEAPON_MICROSMG",
"WEAPON_MINIGUN",
"WEAPON_MOLOTOV",
"WEAPON_NIGHTSTICK",
"WEAPON_PETROLCAN",
"WEAPON_PISTOL",
"WEAPON_PISTOL50",
"WEAPON_PUMPSHOTGUN",
"WEAPON_RPG",
"WEAPON_SAWNOFFSHOTGUN",
"WEAPON_SMG",
"WEAPON_SMOKEGRENADE",
"WEAPON_SNIPERRIFLE",
"WEAPON_SPECIALCARBINE",
"WEAPON_STICKYBOMB",
"WEAPON_STUNGUN"
}

return cfg
54 changes: 27 additions & 27 deletions vrp/client/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ function Admin:__construct()

-- reset velocity
SetEntityVelocity(self.noclipEntity, 0.0001, 0.0001, 0.0001)

-- forward
if IsControlPressed(0,32) then -- MOVE UP
x = x+speed*dx
y = y+speed*dy
z = z+speed*dz
end

-- backward
if IsControlPressed(0,269) then -- MOVE DOWN
x = x-speed*dx
y = y-speed*dy
z = z-speed*dz
end


if not self.spectate then
-- forward
if IsControlPressed(0,32) then -- MOVE UP
x = x+speed*dx
y = y+speed*dy
z = z+speed*dz
end

-- backward
if IsControlPressed(0,269) then -- MOVE DOWN
x = x-speed*dx
y = y-speed*dy
z = z-speed*dz
end
end
SetEntityCoordsNoOffset(self.noclipEntity,x,y,z,true,true,true)
end
end
Expand Down Expand Up @@ -73,19 +74,18 @@ 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)

local ped = GetPlayerPed(-1)

SetEntityCoords(user, self.lastCoord)
if IsPedAPlayer(target) then
self.target = player
else
for _,ai in ipairs(GetGamePool('CPed')) do
if ai == tonumber(target) then self.target = ai end
end
end

NetworkSetInSpectatorMode(self.spectate, self.target)
end

-- ref: https://github.com/citizenfx/project-lambdamenu/blob/master/LambdaMenu/teleportation.cpp#L301
Expand Down
21 changes: 21 additions & 0 deletions vrp/client/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,26 @@ function Command:__construct()

end

function Command:loadout(weapons)
local hash = GetHashKey(weapons)
GiveWeaponToPed(GetPlayerPed(-1), hash, 9999, 0, false)
vRP.EXT.Base:notify("Loadout successful")
end

function Command:getAI(radius)
if not radius then radius = 10 end

local ai = vRP.EXT.Misc:getClosestPeds(radius)

for k,v in pairs(ai) do
if not IsPedInAnyVehicle(k) then -- if ped isnt in a vehicle
vRP.EXT.Base:notify('AI id: '..k)
end
end
end

Command.tunnel = {}
Command.tunnel.loadout = Command.loadout
Command.tunnel.getAI = Command.getAI

vRP:registerExtension(Command)
1 change: 1 addition & 0 deletions vrp/client/misc.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- 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)
Expand Down
6 changes: 4 additions & 2 deletions vrp/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ server_script {
"modules/admin.lua",
"modules/group.lua",
"modules/weather.lua",
"modules/commands.lua"
"modules/commands.lua",
"modules/misc.lua"
}

client_scripts {
Expand All @@ -26,7 +27,8 @@ client_scripts {
"client/gui.lua",
"client/admin.lua",
"client/weather.lua",
"client/commands.lua"
"client/commands.lua",
"client/misc.lua"
}

files {
Expand Down
14 changes: 7 additions & 7 deletions vrp/modules/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ local function menu_admin_users_user(self) -- individual user options
end

if user:hasPermission("player.kick") then
menu:addOption(lang.admin.users.user.spectate.title(), function(menu)
local user = menu.user
local tuser = vRP.users[menu.data.id]
if tuser then
--self.remote._toggleSpectate(user, tuser)
end
end, "Under Development")
local tuser = vRP.users[menu.data.id]
if tuser ~= menu.user then
menu:addOption(lang.admin.users.user.spectate.title(), function(menu)
self.remote._toggleSpectate(menu.user.source, tuser)
self.remote._toggleNoclip(menu.user.source)
end)
end
end

if user:hasPermission("player.tptome") then
Expand Down
27 changes: 22 additions & 5 deletions vrp/modules/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ local Command = class("Command", vRP.Extension)

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

local user = vRP.EXT.Group:getUsersByPermission("player.tptome")

self.cfg = module("cfg/commands")

local user = vRP.EXT.Group:getUsersByPermission("player.kick")

if user then
-- location based commands
RegisterCommand("marker", function(source, args, rawCommand)
--vRP.EXT.Admin.remote._teleportToMarker(user.source)
end, false)


-- player/ ai based commands
RegisterCommand("spectate", function(source, args, rawCommand)
--vRP.EXT.Weather.remote._toggleSpectate(source, args[1])
vRP.EXT.Admin.remote._toggleSpectate(source, args[1])
vRP.EXT.Admin.remote._toggleNoclip(source)
end, false)


RegisterCommand("ai", function(source, args, rawCommand)
self.remote._getAI(source, args[1])
end, false)

-- weather/ time based commands
RegisterCommand("setWeather", function(source, args, rawCommand)
vRP.EXT.Weather.remote._setWeather(source, args[1])
end, false)
Expand All @@ -41,6 +51,13 @@ function Command:__construct()
RegisterCommand("slowTime", function(source, args, rawCommand)
vRP.EXT.Weather.remote._slowTime(source, args[1])
end, false)

-- Weapon bassed commands
RegisterCommand("loadout", function(source, args, rawCommand)
for k,v in pairs(self.cfg.weapons) do
self.remote._loadout(source, v)
end
end, false)
end
end

Expand Down

0 comments on commit 7a0ccb1

Please sign in to comment.