forked from sirpapate/playercore
Initial commit
This commit is contained in:
parent
35d506417a
commit
01de97998a
49
.gitignore
vendored
49
.gitignore
vendored
@ -1,47 +1,2 @@
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# =========================
|
||||
# Operating System Files
|
||||
# =========================
|
||||
|
||||
# OSX
|
||||
# =========================
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
*.txt
|
||||
*.cmd
|
||||
|
10
addon.json
Normal file
10
addon.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"title" : "[E2] PlayerCore",
|
||||
"type" : "tool",
|
||||
"tags" : [ "build" ],
|
||||
"ignore" : [
|
||||
"*.cmd",
|
||||
"*.gma",
|
||||
"addonid.txt"
|
||||
]
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
E2Helper.Descriptions["plyApplyForce"] = "Sets the velocity of the player."
|
||||
E2Helper.Descriptions["plySetPos"] = "Sets the position of the player."
|
||||
E2Helper.Descriptions["plySetAng"] = "Sets the angle of the player."
|
||||
E2Helper.Descriptions["plyNoclip"] = "Sets the player's noclip."
|
||||
E2Helper.Descriptions["plySetHealth"] = "Sets the health of the player."
|
||||
E2Helper.Descriptions["plySetArmor"] = "The amount that the player armor is going to be set to."
|
||||
E2Helper.Descriptions["plySetMass"] = "Sets the mass of the player. - default 85"
|
||||
E2Helper.Descriptions["plySetJumpPower"] = "Sets the jump power, eg. the velocity the player will applied to when he jumps. - default 200"
|
||||
E2Helper.Descriptions["plySetGravity"] = "Sets the gravity multiplier of the player. default 600"
|
||||
E2Helper.Descriptions["plySetSpeed"] = "Sets the speed of the player. - default 200"
|
||||
E2Helper.Descriptions["plyResetSettings"] = "Reset all values of the player."
|
||||
E2Helper.Descriptions["plyEnterVehicle"] = "Enters the player into specified vehicle."
|
||||
E2Helper.Descriptions["plyExitVehicle"] = "Makes the player exit the vehicle if they're in one."
|
||||
E2Helper.Descriptions["plySpawn"] = "Brings back the player."
|
||||
E2Helper.Descriptions["plyGod"] = "It's to become invincible."
|
||||
|
||||
E2Helper.Descriptions["plyGetMass"] = "Returns the mass of the player."
|
||||
E2Helper.Descriptions["plyGetJumpPower"] = "Returns the jump power of the player."
|
||||
E2Helper.Descriptions["plyGetGravity"] = "Gets the gravity multiplier of the player."
|
||||
E2Helper.Descriptions["plyGetSpeed"] = "Gets the speed of the player."
|
||||
|
||||
local plys = {}
|
||||
|
||||
|
||||
net.Receive("wire_expression2_playercore_sendmessage", function( len, ply )
|
||||
local ply = net.ReadEntity()
|
||||
if ply and not plys[ply] then
|
||||
plys[ply] = true
|
||||
-- printColorDriver is used for the first time on us by this chip
|
||||
WireLib.AddNotify(msg1, NOTIFY_GENERIC, 7, NOTIFYSOUND_DRIP3)
|
||||
WireLib.AddNotify(msg2, NOTIFY_GENERIC, 7)
|
||||
chat.AddText(Color(255,0,0),"After this message, ", ply, " can send you a 100% realistically fake people talking, including admins.")
|
||||
chat.AddText(Color(255,0,0),"Look the console to see if the message is form an expression2")
|
||||
end
|
||||
|
||||
LocalPlayer():PrintMessage(HUD_PRINTCONSOLE, "[E2] " .. ply:Name() .. ": ")
|
||||
chat.AddText(unpack(net.ReadTable()))
|
||||
end)
|
||||
|
||||
hook.Add("PlayerNoClip", "PlyCore", function(ply, state)
|
||||
if not state then return end
|
||||
|
||||
if ply:GetNWBool("PlyCore_DisableNoclip", false) then
|
||||
return false
|
||||
end
|
||||
end)
|
659
lua/entities/gmod_wire_expression2/core/custom/playercore.lua
Normal file
659
lua/entities/gmod_wire_expression2/core/custom/playercore.lua
Normal file
@ -0,0 +1,659 @@
|
||||
|
||||
E2Lib.RegisterExtension("playercore", true)
|
||||
|
||||
local sbox_E2_PlyCore = CreateConVar("sbox_E2_PlyCore", "2", FCVAR_ARCHIVE)
|
||||
|
||||
local function ValidPly(ply)
|
||||
if not IsValid(ply) or not ply:IsPlayer() then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local function hasAccess(ply, target, command)
|
||||
local valid = hook.Call("PlyCoreCommand", GAMEMODE, ply, target, command)
|
||||
|
||||
if valid ~= nil then
|
||||
return valid
|
||||
end
|
||||
|
||||
if sbox_E2_PlyCore:GetInt() == 1 then
|
||||
return true
|
||||
elseif sbox_E2_PlyCore:GetInt() == 2 then
|
||||
if target:IsBot() then return true end
|
||||
if ply == target then return true end
|
||||
if ply:IsAdmin() then return true end
|
||||
|
||||
if CPPI then
|
||||
for k, v in pairs(target:CPPIGetFriends()) do
|
||||
if v == ply then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
elseif sbox_E2_PlyCore:GetInt() == 3 then
|
||||
if not ply:IsAdmin() then return false end
|
||||
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function check(v)
|
||||
return -math.huge < v[1] and v[1] < math.huge and
|
||||
-math.huge < v[2] and v[2] < math.huge and
|
||||
-math.huge < v[3] and v[3] < math.huge
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------
|
||||
--Make applyForce on player
|
||||
|
||||
e2function void entity:plyApplyForce(vector force)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "applyforce") then return nil end
|
||||
|
||||
if check(force) then
|
||||
this:SetVelocity(Vector(force[1],force[2],force[3]))
|
||||
end
|
||||
end
|
||||
--SetPosition
|
||||
|
||||
e2function void entity:plySetPos(vector pos)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setpos") then return nil end
|
||||
|
||||
this:SetPos(Vector(math.Clamp(pos[1],-16000,16000), math.Clamp(pos[2],-16000,16000), math.Clamp(pos[3],-16000,16000)))
|
||||
end
|
||||
|
||||
--SetEyeAngles
|
||||
|
||||
e2function void entity:plySetAng(angle ang)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setang") then return nil end
|
||||
|
||||
local normalizedAng = Angle(ang[1], ang[2], ang[3])
|
||||
normalizedAng:Normalize()
|
||||
this:SetEyeAngles(normalizedAng)
|
||||
end
|
||||
|
||||
--Noclip
|
||||
|
||||
e2function void entity:plyNoclip(number activate)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "noclip") then return nil end
|
||||
|
||||
if activate > 0 then
|
||||
this:SetMoveType(MOVETYPE_NOCLIP)
|
||||
else
|
||||
this:SetMoveType(MOVETYPE_WALK)
|
||||
end
|
||||
end
|
||||
|
||||
--Health
|
||||
|
||||
e2function void entity:plySetHealth(number health)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "sethealth") then return nil end
|
||||
|
||||
this:SetHealth(math.Clamp(health, 0, 2^32/2-1))
|
||||
end
|
||||
|
||||
-- Armor
|
||||
|
||||
e2function void entity:plySetArmor(number armor)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setarmor") then return nil end
|
||||
|
||||
this:SetArmor(math.Clamp(armor, 0, 2^32/2-1))
|
||||
end
|
||||
|
||||
-- Mass
|
||||
|
||||
e2function void entity:plySetMass(number mass)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setmass") then return nil end
|
||||
|
||||
this:GetPhysicsObject():SetMass(math.Clamp(mass, 1, 50000))
|
||||
end
|
||||
|
||||
e2function number entity:plyGetMass()
|
||||
if not ValidPly(this) then return nil end
|
||||
|
||||
return this:GetPhysicsObject():GetMass()
|
||||
end
|
||||
|
||||
-- JumpPower
|
||||
|
||||
e2function void entity:plySetJumpPower(number jumpPower)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setjumppower") then return nil end
|
||||
|
||||
this:SetJumpPower(math.Clamp(jumpPower, 0, 2^32/2-1))
|
||||
end
|
||||
|
||||
e2function number entity:plyGetJumpPower()
|
||||
if not ValidPly(this) then return nil end
|
||||
|
||||
return this:GetJumpPower()
|
||||
end
|
||||
|
||||
-- Gravity
|
||||
|
||||
e2function void entity:plySetGravity(number gravity)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setgravity") then return nil end
|
||||
|
||||
if gravity == 0 then gravity = 1/10^10 end
|
||||
this:SetGravity(gravity/600)
|
||||
end
|
||||
|
||||
e2function number entity:plyGetGravity()
|
||||
if not ValidPly(this) then return nil end
|
||||
|
||||
return this:GetGravity()*600
|
||||
end
|
||||
|
||||
-- Speed
|
||||
|
||||
e2function void entity:plySetSpeed(number speed)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setspeed") then return nil end
|
||||
|
||||
|
||||
this:SetWalkSpeed(math.Clamp(speed, 1, 10000))
|
||||
this:SetRunSpeed(math.Clamp(speed*2, 1, 10000))
|
||||
end
|
||||
|
||||
e2function void entity:plySetRunSpeed(number speed)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setrunspeed") then return nil end
|
||||
|
||||
this:SetRunSpeed(math.Clamp(speed*2, 1, 10000))
|
||||
end
|
||||
|
||||
e2function void entity:plySetWalkSpeed(number speed)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "setwalkspeed") then return nil end
|
||||
|
||||
this:SetWalkSpeed(math.Clamp(speed, 1, 10000))
|
||||
end
|
||||
|
||||
e2function number entity:plyGetSpeed()
|
||||
if not ValidPly(this) then return nil end
|
||||
|
||||
return this:GetWalkSpeed()
|
||||
end
|
||||
|
||||
e2function void entity:plyResetSettings()
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "resetsettings") then return nil end
|
||||
|
||||
this:Health(100)
|
||||
this:GetPhysicsObject():SetMass(85)
|
||||
this:SetJumpPower(200)
|
||||
this:SetGravity(1)
|
||||
this:SetWalkSpeed(200)
|
||||
this:SetRunSpeed(400)
|
||||
this:Armor(0)
|
||||
end
|
||||
|
||||
e2function void entity:plyEnterVehicle(entity vehicle)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "entervehicle") then return nil end
|
||||
if not vehicle or not vehicle:IsValid() or not vehicle:IsVehicle() then return nil end
|
||||
|
||||
|
||||
if this:InVehicle() then this:ExitVehicle() end
|
||||
|
||||
this:EnterVehicle(vehicle)
|
||||
end
|
||||
|
||||
e2function void entity:plyExitVehicle()
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "exitvehicle") then return nil end
|
||||
if not this:InVehicle() then return nil end
|
||||
|
||||
this:ExitVehicle()
|
||||
end
|
||||
|
||||
e2function void entity:plySpawn()
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "spawn") then return nil end
|
||||
if not this.e2PcLastSpawn then this.e2PcLastSpawn = CurTime()-1 end
|
||||
if (CurTime() - this.e2PcLastSpawn) < 1 then return nil end
|
||||
this.e2PcLastSpawn = CurTime()
|
||||
|
||||
this:Spawn()
|
||||
end
|
||||
|
||||
-- Freeze
|
||||
|
||||
registerCallback("destruct",function(self)
|
||||
for _, ply in pairs(player.GetAll()) do
|
||||
if ply.plycore_freezeby == self then
|
||||
ply:Freeze(false)
|
||||
end
|
||||
|
||||
if ply.plycore_noclipdiabledby == self then
|
||||
ply:SetNWBool("PlyCore_DisableNoclip", false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
e2function void entity:plyFreeze(number freeze)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "freeze") then return nil end
|
||||
|
||||
this.plycore_freezeby = self
|
||||
this:Freeze(freeze == 1)
|
||||
end
|
||||
|
||||
e2function number entity:plyIsFrozen()
|
||||
if not ValidPly(this) then return nil end
|
||||
|
||||
return this:IsFlagSet(FL_FROZEN)
|
||||
end
|
||||
|
||||
-- DisableNoclip
|
||||
|
||||
e2function void entity:plyDisableNoclip(number act)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "disablenoclip") then return nil end
|
||||
|
||||
this.plycore_noclipdiabledby = self
|
||||
this:SetNWBool("PlyCore_DisableNoclip", act == 1)
|
||||
end
|
||||
|
||||
hook.Add("PlayerNoClip", "PlyCore", function(ply, state)
|
||||
if not state then return end
|
||||
|
||||
if ply:GetNWBool("PlyCore_DisableNoclip", false) then
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
-- God
|
||||
|
||||
e2function void entity:plyGod(number active)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "god") then return nil end
|
||||
if not active == 1 then active = 0 end
|
||||
|
||||
if active == 1 then
|
||||
this:GodEnable()
|
||||
else
|
||||
this:GodDisable()
|
||||
end
|
||||
end
|
||||
|
||||
e2function number entity:plyHasGod()
|
||||
if not ValidPly(this) then return nil end
|
||||
|
||||
return this:HasGodMode() and 1 or 0
|
||||
end
|
||||
|
||||
-- Message
|
||||
|
||||
e2function void sendMessage(string text)
|
||||
if not hasAccess(self.player, nil, "globalmessage") then return nil end
|
||||
|
||||
PrintMessage(HUD_PRINTCONSOLE, self.player:Name() .. " send you the next message by an expression 2.")
|
||||
PrintMessage(HUD_PRINTTALK, text)
|
||||
end
|
||||
|
||||
e2function void sendMessageCenter(string text)
|
||||
if not hasAccess(self.player, nil, "globalmessagecenter") then return nil end
|
||||
|
||||
PrintMessage(HUD_PRINTCONSOLE, text)
|
||||
PrintMessage(HUD_PRINTCENTER, text)
|
||||
end
|
||||
|
||||
--
|
||||
|
||||
e2function void entity:sendMessage(string text)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "message") then return nil end
|
||||
|
||||
this:PrintMessage(HUD_PRINTCONSOLE, self.player:Name() .. " send you the next message by an expression 2.")
|
||||
this:PrintMessage(HUD_PRINTTALK, text)
|
||||
end
|
||||
|
||||
e2function void entity:sendMessageCenter(string text)
|
||||
if not ValidPly(this) then return nil end
|
||||
if not hasAccess(self.player, this, "messagecenter") then return nil end
|
||||
|
||||
this:PrintMessage(HUD_PRINTCONSOLE, self.player:Name() .. " send you the next message by an expression 2.")
|
||||
this:PrintMessage(HUD_PRINTCENTER, text)
|
||||
end
|
||||
|
||||
--
|
||||
|
||||
e2function void array:sendMessage(string text)
|
||||
for _, ply in pairs(this) do
|
||||
if not ValidPly(ply) then return nil end
|
||||
if not hasAccess(self.player, ply, "message") then return nil end
|
||||
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE, self.player:Name() .. " send you the next message by an expression 2.")
|
||||
ply:PrintMessage(HUD_PRINTTALK, text)
|
||||
end
|
||||
end
|
||||
|
||||
e2function void array:sendMessageCenter(string text)
|
||||
for _, ply in pairs(this) do
|
||||
if not ValidPly(ply) then return nil end
|
||||
if not hasAccess(self.player, ply, "messagecenter") then return nil end
|
||||
|
||||
ply:PrintMessage(HUD_PRINTCONSOLE, self.player:Name() .. " send you the next message by an expression 2.")
|
||||
ply:PrintMessage(HUD_PRINTCENTER, text)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
util.AddNetworkString("wire_expression2_playercore_sendmessage")
|
||||
|
||||
local printColor_typeids = {
|
||||
n = tostring,
|
||||
s = tostring,
|
||||
v = function(v) return Color(v[1],v[2],v[3]) end,
|
||||
xv4 = function(v) return Color(v[1],v[2],v[3],v[4]) end,
|
||||
e = function(e) return IsValid(e) and e:IsPlayer() and e or "" end,
|
||||
}
|
||||
|
||||
local function printColorVarArg(ply, target, typeids, ...)
|
||||
local send_array = { ... }
|
||||
|
||||
for i,tp in ipairs(typeids) do
|
||||
if printColor_typeids[tp] then
|
||||
send_array[i] = printColor_typeids[tp](send_array[i])
|
||||
else
|
||||
send_array[i] = ""
|
||||
end
|
||||
end
|
||||
|
||||
target = isentity(target) and {target}
|
||||
target = target or player.GetAll()
|
||||
|
||||
local plys = {}
|
||||
for _, ply in pairs(target) do
|
||||
if ValidPly(ply) then
|
||||
table.insert(plys, ply)
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("wire_expression2_playercore_sendmessage")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteTable(send_array)
|
||||
net.Send(plys)
|
||||
end
|
||||
|
||||
local printColor_types = {
|
||||
number = tostring,
|
||||
string = tostring,
|
||||
Vector = function(v) return Color(v[1],v[2],v[3]) end,
|
||||
table = function(tbl)
|
||||
for i,v in pairs(tbl) do
|
||||
if !isnumber(i) then return "" end
|
||||
if !isnumber(v) then return "" end
|
||||
if i < 1 or i > 4 then return "" end
|
||||
end
|
||||
return Color(tbl[1] or 0, tbl[2] or 0,tbl[3] or 0,tbl[4])
|
||||
end,
|
||||
Player = function(e) return IsValid(e) and e:IsPlayer() and e or "" end,
|
||||
}
|
||||
|
||||
local function printColorArray(ply, target, arr)
|
||||
local send_array = {}
|
||||
|
||||
for i,tp in ipairs_map(arr,type) do
|
||||
if printColor_types[tp] then
|
||||
send_array[i] = printColor_types[tp](arr[i])
|
||||
else
|
||||
send_array[i] = ""
|
||||
end
|
||||
end
|
||||
|
||||
target = isentity(target) and {target}
|
||||
target = target or player.GetAll()
|
||||
|
||||
local plys = {}
|
||||
for _, ply in pairs(target) do
|
||||
if ValidPly(ply) then
|
||||
table.insert(plys, ply)
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("wire_expression2_playercore_sendmessage")
|
||||
net.WriteEntity(ply)
|
||||
net.WriteTable(send_array)
|
||||
net.Send(plys)
|
||||
end
|
||||
|
||||
e2function void sendMessageColor(array arr)
|
||||
if not ValidPly(this) then return end
|
||||
if not hasAccess(self.player, nil, "globalmessagecolor") then return nil end
|
||||
|
||||
printColorArray(self.player, this, arr)
|
||||
end
|
||||
|
||||
e2function void sendMessageColor(...)
|
||||
if not ValidPly(this) then return end
|
||||
if not hasAccess(self.player, nil, "globalmessagecolor") then return nil end
|
||||
|
||||
printColorVarArg(self.player, this, typeids, ...)
|
||||
end
|
||||
|
||||
e2function void entity:sendMessageColor(array arr)
|
||||
if not ValidPly(this) then return end
|
||||
if not hasAccess(self.player, this, "messagecolor") then return nil end
|
||||
|
||||
printColorArray(self.player, this, arr)
|
||||
end
|
||||
|
||||
e2function void entity:sendMessageColor(...)
|
||||
if not ValidPly(this) then return end
|
||||
if not hasAccess(self.player, this, "messagecolor") then return nil end
|
||||
|
||||
printColorVarArg(self.player, this, typeids, ...)
|
||||
end
|
||||
|
||||
e2function void array:sendMessageColor(array arr)
|
||||
local plys = {}
|
||||
|
||||
for _, ply in pairs(this) do
|
||||
if not ValidPly(ply) then continue end
|
||||
if not hasAccess(self.player, ply, "messagecolor") then continue end
|
||||
|
||||
table.insert(plys, ply)
|
||||
end
|
||||
|
||||
printColorArray(self.player, plys, arr)
|
||||
end
|
||||
|
||||
e2function void array:sendMessageColor(...)
|
||||
local plys = {}
|
||||
|
||||
for _, ply in pairs(this) do
|
||||
if not ValidPly(ply) then continue end
|
||||
if not hasAccess(self.player, ply, "messagecolor") then continue end
|
||||
|
||||
table.insert(plys, ply)
|
||||
end
|
||||
|
||||
printColorVarArg(self.player, plys, typeids, ...)
|
||||
end
|
||||
|
||||
|
||||
--[[############################################]]
|
||||
|
||||
local registered_e2s_spawn = {}
|
||||
local lastspawnedplayer = NULL
|
||||
local respawnrun = 0
|
||||
|
||||
registerCallback("destruct",function(self)
|
||||
registered_e2s_spawn[self.entity] = nil
|
||||
end)
|
||||
|
||||
hook.Add("PlayerSpawn","Expresion2_PlayerSpawn", function(ply)
|
||||
local ents = {}
|
||||
|
||||
for entity,_ in pairs(registered_e2s_spawn) do
|
||||
if entity:IsValid() then table.insert(ents, entity) end
|
||||
end
|
||||
|
||||
respawnrun = 1
|
||||
lastspawnedplayer = ply
|
||||
for _,entity in ipairs(ents) do
|
||||
entity:Execute()
|
||||
end
|
||||
respawnrun = 0
|
||||
end)
|
||||
|
||||
e2function void runOnSpawn(activate)
|
||||
if activate ~= 0 then
|
||||
registered_e2s_spawn[self.entity] = true
|
||||
else
|
||||
registered_e2s_spawn[self.entity] = nil
|
||||
end
|
||||
end
|
||||
|
||||
e2function number spawnClk()
|
||||
return respawnrun
|
||||
end
|
||||
|
||||
e2function entity lastSpawnedPlayer()
|
||||
return lastspawnedplayer
|
||||
end
|
||||
|
||||
--[[############################################]]
|
||||
|
||||
local registered_e2s_death = {}
|
||||
local playerdeathinfo = {[1]=NULL, [2]=NULL, [3]=NULL}
|
||||
local deathrun = 0
|
||||
|
||||
registerCallback("destruct",function(self)
|
||||
registered_e2s_death[self.entity] = nil
|
||||
end)
|
||||
|
||||
hook.Add("PlayerDeath","Expresion2_PlayerDeath", function(victim, inflictor, attacker)
|
||||
local ents = {}
|
||||
|
||||
for entity,_ in pairs(registered_e2s_death) do
|
||||
if entity:IsValid() then table.insert(ents, entity) end
|
||||
end
|
||||
|
||||
deathrun = 1
|
||||
playerdeathinfo = { victim, inflictor, attacker}
|
||||
for _,entity in ipairs(ents) do
|
||||
entity:Execute()
|
||||
end
|
||||
deathrun = 0
|
||||
end)
|
||||
|
||||
e2function void runOnDeath(activate)
|
||||
if activate ~= 0 then
|
||||
registered_e2s_death[self.entity] = true
|
||||
else
|
||||
registered_e2s_death[self.entity] = nil
|
||||
end
|
||||
end
|
||||
|
||||
e2function number deathClk()
|
||||
return deathrun
|
||||
end
|
||||
|
||||
e2function entity lastDeath()
|
||||
return playerdeathinfo[1]
|
||||
end
|
||||
|
||||
e2function entity lastDeathInflictor()
|
||||
return playerdeathinfo[2]
|
||||
end
|
||||
|
||||
e2function entity lastDeathAttacker()
|
||||
return playerdeathinfo[3]
|
||||
end
|
||||
|
||||
--[[############################################]]
|
||||
|
||||
local registered_e2s_connect = {}
|
||||
local lastconnectedplayer = NULL
|
||||
local connectrun = 0
|
||||
|
||||
registerCallback("destruct",function(self)
|
||||
registered_e2s_connect[self.entity] = nil
|
||||
end)
|
||||
|
||||
hook.Add("PlayerInitialSpawn","Expresion2_PlayerInitialSpawn", function(ply)
|
||||
connectrun = 1
|
||||
lastconnectedplayer = ply
|
||||
|
||||
for entity,_ in pairs(registered_e2s_connect) do
|
||||
if entity:IsValid() then
|
||||
entity:Execute()
|
||||
end
|
||||
end
|
||||
|
||||
connectrun = 0
|
||||
end)
|
||||
|
||||
e2function void runOnConnect(activate)
|
||||
if activate ~= 0 then
|
||||
registered_e2s_connect[self.entity] = true
|
||||
else
|
||||
registered_e2s_connect[self.entity] = nil
|
||||
end
|
||||
end
|
||||
|
||||
e2function number connectClk()
|
||||
return connectrun
|
||||
end
|
||||
|
||||
e2function entity lastConnectedPlayer()
|
||||
return lastconnectedplayer
|
||||
end
|
||||
|
||||
--[[############################################]]
|
||||
|
||||
local registered_e2s_disconnect = {}
|
||||
local lastdisconnectedplayer = NULL
|
||||
local disconnectrun = 0
|
||||
|
||||
registerCallback("destruct",function(self)
|
||||
registered_e2s_disconnect[self.entity] = nil
|
||||
end)
|
||||
|
||||
hook.Add("PlayerDisconnected","Expresion2_PlayerDisconnected", function(ply)
|
||||
disconnectrun = 1
|
||||
lastdisconnectedplayer = ply
|
||||
|
||||
for entity,_ in pairs(registered_e2s_disconnect) do
|
||||
if entity:IsValid() then
|
||||
entity:Execute()
|
||||
end
|
||||
end
|
||||
|
||||
disconnectrun = 0
|
||||
end)
|
||||
|
||||
e2function void runOnDisconnect(activate)
|
||||
if activate ~= 0 then
|
||||
registered_e2s_disconnect[self.entity] = true
|
||||
else
|
||||
registered_e2s_disconnect[self.entity] = nil
|
||||
end
|
||||
end
|
||||
|
||||
e2function number disconnectClk()
|
||||
return disconnectrun
|
||||
end
|
||||
|
||||
e2function entity lastDisconnectedPlayer()
|
||||
return lastdisconnectedplayer
|
||||
end
|
78
lua/ulib/modules/playercore_access.lua
Normal file
78
lua/ulib/modules/playercore_access.lua
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
|
||||
print("protection up")
|
||||
|
||||
if SERVER then
|
||||
if ULib ~= nil then
|
||||
ULib.ucl.registerAccess("target_himself", {"user"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("target_friends", {"user"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("target_byrank", {"operator"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("target_everyone", {"admin"}, "", "PlayerCore")
|
||||
|
||||
ULib.ucl.registerAccess("applyforce", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setpos", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setang", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("noclip", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("unnoclip", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("sethealth", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setarmor", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setmass", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setjumppower", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setgravity", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setspeed", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setrunspeed", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("setwalkspeed", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("resetsettings", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("entervehicle", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("exitvehicle", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("spawn", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("god", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("ungod", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("freeze", {"operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("disablenoclip", {"operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
|
||||
|
||||
ULib.ucl.registerAccess("message", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("messagecenter", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("messagecolor", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("globalmessage", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
ULib.ucl.registerAccess("globalmessagecenter", {"user", "operator", "admin", "superadmin"}, "", "PlayerCore")
|
||||
|
||||
hook.Add("PlyCoreCommand", "ULX_PlyCore_Access", function(ply, target, command)
|
||||
if ULib.ucl.query(ply, command) then
|
||||
if not IsValid(target) and target:IsPlayer() then return true end
|
||||
|
||||
if ULib.ucl.query(ply, "target_himself") then
|
||||
if ply == target then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if ULib.ucl.query(ply, "target_everyone") then
|
||||
return true
|
||||
end
|
||||
|
||||
if ULib.ucl.query(ply, "target_friends") then
|
||||
if CPPI then
|
||||
for k, v in pairs(target:CPPIGetFriends()) do
|
||||
if v == ply then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local access, tag = ULib.ucl.query(ply, "target_byrank")
|
||||
if access then
|
||||
local restrictions = {}
|
||||
ULib.cmds.PlayerArg.processRestrictions(restrictions, ply, {}, tag and ULib.splitArgs(tag)[1] )
|
||||
if not (restrictions.restrictedTargets == false or (restrictions.restrictedTargets and not table.HasValue(restrictions.restrictedTargets, target))) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user