import some modules from ulx-custom-commands

1. i dont want to keep using ulx-custom-commands because a lot of it is unnecessary stuff i dont need
2. although i could cut some of the Lua files out theres still a lot of code bundled into one file

so just import some modules here, but more seperate with credit given in the Lua files
This commit is contained in:
edshot99 2024-11-30 01:02:53 -06:00
parent 2c4a72d3e2
commit e6098e4f5f
3 changed files with 122 additions and 0 deletions

View File

@ -0,0 +1,46 @@
-- from: ulx-custom-commands/lua/ulx/modules/sh/cc_fun.lua
CreateConVar("explode_ragdolls", 0)
function ulx.explode(calling_ply, target_plys)
for _, v in ipairs(target_plys) do
local pos = v:GetPos()
local waterlvl = v:WaterLevel()
timer.Simple(0, function()
local tr = {}
tr.start = pos
tr.endpos = tr.start + (Vector(0, 0, -1) * 250)
local trw = util.TraceEntity(tr)
local wp1 = trw.HitPos + trw.HitNormal
local wp2 = trw.HitPos - trw.HitNormal
util.Decal("Scorch", wp1, wp2)
end)
if GetConVar("explode_ragdolls"):GetInt() > 0 then
v:SetVelocity(Vector(0, 0, 10) * math.Rand(75, 150))
timer.Simple(0.1, function()
v:Kill()
end)
else
v:Kill()
end
util.ScreenShake(pos, 5, 5, 1.5, 200)
local vPoint = pos + Vector(0, 0, 10)
local eData = EffectData()
eData:SetStart(vPoint)
eData:SetOrigin(vPoint)
eData:SetScale(1)
if (waterlvl > 1) then
util.Effect("WaterSurfaceExplosion", eData)
util.Effect("HelicopterMegaBomb", eData)
else
util.Effect("HelicopterMegaBomb", eData)
v:EmitSound(Sound("ambient/explosions/explode_4.wav"))
end
end
ulx.fancyLogAdmin(calling_ply, "#A exploded #T", target_plys)
end
local explode = ulx.command("Fun", "ulx explode", ulx.explode, "!explode")
explode:addParam{type = ULib.cmds.PlayersArg}
explode:defaultAccess(ULib.ACCESS_ADMIN)
explode:help("Explode your foes!")

View File

@ -0,0 +1,20 @@
-- from: ulx-custom-commands/lua/ulx/modules/sh/cc_util.lua
function ulx.respawn(calling_ply, target_plys)
for _, v in pairs(target_plys) do
if (v:Alive()) then
v:Kill()
end
if (GetConVar("gamemode"):GetString() == "terrortown") then
v:SpawnForRound(true)
else
v:Spawn()
end
end
ulx.fancyLogAdmin(calling_ply, "#A respawned #T", target_plys)
end
local respawn = ulx.command("Utility", "ulx respawn", ulx.respawn, "!respawn")
respawn:addParam{type = ULib.cmds.PlayersArg}
respawn:defaultAccess(ULib.ACCESS_ADMIN)
respawn:help("Force-respawn a player.")

View File

@ -0,0 +1,56 @@
-- from: ulx-custom-commands/lua/ulx/modules/sh/cc_util.lua
if CLIENT then
local enabled = false
concommand.Add("thirdperson_toggle", function()
enabled = !enabled
if (enabled) then
if (IsValid(ply:GetActiveWeapon())) then
ply:GetActiveWeapon().AccurateCrosshair = true
end
chat.AddText(Color(162, 255, 162), "Third-person mode enabled.")
else
if (IsValid(LocalPlayer():GetActiveWeapon())) then
LocalPlayer():GetActiveWeapon().AccurateCrosshair = false
end
chat.AddText(Color(255, 162, 162), "Third-person mode disabled.")
end
end)
hook.Add("ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if (enabled) and (LocalPlayer():Alive()) then
return true
end
end)
hook.Add("CalcView", "ThirdPersonView", function(ply, pos, ang, fov)
if (enabled) and (IsValid(ply)) and (ply:Alive()) then
local view = {}
view.origin = (pos - (ang:Forward() * 70) + (ang:Right() * 20) + (ang:Up() * 5))
view.ang = (ply:EyeAngles() + Angle(1, 1, 0))
local TrD = {}
TrD.start = (ply:EyePos())
TrD.endpos = (TrD.start + (ang:Forward() * - 100) + (ang:Right() * 25) + (ang:Up() * 10))
TrD.filter = ply
local trace = util.TraceLine(TrD)
pos = trace.HitPos
if (trace.Fraction < 1) then
pos = pos + trace.HitNormal * 5
end
view.origin = pos
view.fov = fov
return GAMEMODE:CalcView(ply, view.origin, view.ang, view.fov)
end
end)
end
if SERVER then
function ulx.thirdperson(calling_ply)
calling_ply:RunConsoleCommand("thirdperson_toggle")
end
local thirdperson = ulx.command("Utility", "ulx thirdperson", ulx.thirdperson, {"!3p", "!thirdperson"}, true)
thirdperson:defaultAccess(ULib.ACCESS_ALL)
thirdperson:help("Toggle third person mode.")
end