Purge (round based)Coding props to be moveable except map spawned props(doors/windows)
7 replies, posted
Hey guys our team has been working on getting this fixed but we cannot find a solution we need to make it so props can be phys gunned (locked in place by the owner of the proponly)but not doors and windows. from the map. and we want to make it so people cant own doors by pressing e instead we want all doors accesible. simply just want to make it so our phys gun will lock the prop in place but no one else but the owner and enviorment props like doors and windows can not be pulled from their frames. [code]- if not NADMOD then
-- User is running without my Admin mod NADMOD, lets just copy some required initialization stuff over here
concommand.Add("nadmod_reload", function(ply,cmd,args)
if args[1] == "full" then NADMOD = nil end
include("autorun/server/nadmod_pp.lua")
end)
NADMOD = util.JSONToTable(file.Read("nadmod_config.txt","DATA") or "") or {Users = {}, Groups = {}, Bans = {}, PPConfig = {}}
function NADMOD.Save()
file.Write("nadmod_config.txt", util.TableToJSON({Users = NADMOD.Users, Groups = NADMOD.Groups, Bans = NADMOD.Bans, PPConfig = NADMOD.PPConfig}))
end
hook.Add("Shutdown","NADMOD.Save",NADMOD.Save)
function NADMOD.FindPlayer(nick)
if not nick or nick == "" then return end
nick = string.lower(nick)
local num = tonumber(nick)
for _,v in pairs(player.GetAll()) do
if string.lower(v:Nick()) == nick then return v -- Exact name match
elseif v:UserID() == num then return v -- UserID match (from status)
end
end
-- If the above two exact searches fail, try doing a partial search
for _,v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), nick) then return v end
end
end
end
if not NADMOD.Props then
-- NADMOD PP Initialization
NADMOD.PPVersion = "1.2.6p"
NADMOD.Props = {} // {entid = {Ent = ent, Owner = ply, SteamID = ply:SteamID(), Name = ply:Nick() or "W" or "O"}}
NADMOD.PropOwnersSmall = {} // A smaller buffer of PropOwner names to send to current players
NADMOD.AutoCDPTimers = {}
local oldCPPI = CPPI
CPPI = {}
-- Copy over default settings if they aren't present in the disk's PPConfig
for k,v in pairs({toggle=true,use=true,adminall=true,autocdp=0,autocdpadmins=false}) do
if NADMOD.PPConfig[k] == nil then NADMOD.PPConfig[k] = v end
end
--AddCSLuaFile("autorun/client/cl_nadmodpp.lua")
util.AddNetworkString("nadmod_propowners")
util.AddNetworkString("nadmod_ppfriends")
util.AddNetworkString("nadmod_ppconfig")
util.AddNetworkString("nadmod_cleanclragdolls")
util.AddNetworkString("nad
function NADMOD.PlayerMakePropOwner(ply,ent)
if !IsValid(ent) or !IsValid(ply) or ent:IsPlayer() or !ply:IsPlayer() then return end
NADMOD.Props[ent:EntIndex()] = {
Ent = ent,
Owner = ply,
SteamID = ply:SteamID(),
Name = ply:Nick()
}
NADMOD.PropOwnersSmall[ent:EntIndex()] = ply:Nick()
ent.SPPOwner = ply
ent.Owner = ply
end function metaent:CPPIGetOwner() return self.Owner end
function metaent:CPPISetOwner(ply) return NADMOD.PlayerMakePropOwner(ply, self) end
function metaent:CPPICanTool(ply,mode) return NADMOD.CanTool(ply,{Entity=self},mode) != false end
function metaent:CPPICanPhysgun(ply) return NADMOD.PlayerCanTouchSafe(ply,self) != false end
function metaent:CPPICanPickup(ply) return NADMOD.GravGunPickup(ply, self) != false end
function metaent:CPPICanPunt(ply) return NADMOD.GravGunPickup(ply, self) != false end
-[/code]
The project is near complete we just have 2 things including this we need to fix one is the timer if anyone would like to help us out it would be greatly aprecieated
You should tab that code to keep people's sanity while reading it. One of the best benefits of tabbing is being able to see where a statement and/or function begins and ends.
Formatted this for you
[code]
if not NADMOD then
-- User is running without my Admin mod NADMOD, lets just copy some required initialization stuff over here
concommand.Add("nadmod_reload",
function(ply, cmd, args)
if args[1] == "full" then
NADMOD = nil
end
include("autorun/server/nadmod_pp.lua")
end
)
NADMOD = util.JSONToTable(file.Read("nadmod_config.txt", "DATA") or "") or {Users = {}, Groups = {}, Bans = {}, PPConfig = {}}
function NADMOD.Save()
file.Write("nadmod_config.txt", util.TableToJSON({Users = NADMOD.Users, Groups = NADMOD.Groups, Bans = NADMOD.Bans, PPConfig = NADMOD.PPConfig}))
end
hook.Add("Shutdown", "NADMOD.Save", NADMOD.Save)
function NADMOD.FindPlayer(nick)
if not nick or nick == "" then
return
end
nick = string.lower(nick)
local num = tonumber(nick)
for _, v in pairs(player.GetAll()) do -- Exact name match
if string.lower(v:Nick()) == nick then
return v
elseif v:UserID() == num then
return v
end
end
-- UserID match (from status)
-- If the above two exact searches fail, try doing a partial search
for _, v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), nick) then
return v
end
end
end
end
if not NADMOD.Props then
-- NADMOD PP Initialization
NADMOD.PPVersion = "1.2.6p"
NADMOD.Props = {} -- {entid = {Ent = ent, Owner = ply, SteamID = ply:SteamID(), Name = ply:Nick() or "W" or "O"}}
NADMOD.PropOwnersSmall = {} -- A smaller buffer of PropOwner names to send to current players
NADMOD.AutoCDPTimers = {}
local oldCPPI = CPPI
CPPI = {}
-- Copy over default settings if they aren't present in the disk's PPConfig
for k, v in pairs({toggle = true, use = true, adminall = true, autocdp = 0, autocdpadmins = false}) do
if NADMOD.PPConfig[k] == nil then
NADMOD.PPConfig[k] = v
end
end
--AddCSLuaFile("autorun/client/cl_nadmodpp.lua")
util.AddNetworkString("nadmod_propowners")
util.AddNetworkString("nadmod_ppfriends")
util.AddNetworkString("nadmod_ppconfig")
util.AddNetworkString("nadmod_cleanclragdolls")
util.AddNetworkString("nad") --Incomplete string
function NADMOD.PlayerMakePropOwner(ply, ent)
if not IsValid(ent) or not IsValid(ply) or ent:IsPlayer() or not ply:IsPlayer() then
return
end
NADMOD.Props[ent:EntIndex()] = {Ent = ent, Owner = ply, SteamID = ply:SteamID(), Name = ply:Nick()}
NADMOD.PropOwnersSmall[ent:EntIndex()] = ply:Nick()
ent.SPPOwner = ply
ent.Owner = ply
end
function metaent:CPPIGetOwner()
return self.Owner
end
function metaent:CPPISetOwner(ply)
return NADMOD.PlayerMakePropOwner(ply, self)
end
function metaent:CPPICanTool(ply, mode)
return NADMOD.CanTool(ply, {Entity = self}, mode)
end
function metaent:CPPICanPhysgun(ply)
return NADMOD.PlayerCanTouchSafe(ply, self)
end
function metaent:CPPICanPickup(ply)
return NADMOD.GravGunPickup(ply, self)
end
function metaent:CPPICanPunt(ply)
return NADMOD.GravGunPickup(ply, self)
end
end
[/code]
Thank you for your help also what is tabbing and could you explain for me. please.
[editline]15th August 2015[/editline]
oh are you talking about line numbers by any chance. how do i do that?
[QUOTE=K3rm1tFr0g;48463822]Thank you for your help also what is tabbing and could you explain for me. please.
[editline]15th August 2015[/editline]
oh are you talking about line numbers by any chance. how do i do that?[/QUOTE]
Press tab so your code doesnt look like you brewed it up in notepad.
[code]-- Nebual 2012 (nebual@nebtown.info) presents:
-- NADMOD Prop Protection
-- Inspired by Spacetech's Simple Prop Protection, <3's
-- Bugs? Feature requests? "why are you using JSON?!"? Email me or poke the Facepunch http://www.facepunch.com/showthread.php?t=1221183
if not NADMOD then
-- User is running without my Admin mod NADMOD, lets just copy some required initialization stuff over here
concommand.Add("nadmod_reload", function(ply,cmd,args)
if args[1] == "full" then NADMOD = nil end
include("autorun/server/nadmod_pp.lua")
end)
NADMOD = util.JSONToTable(file.Read("nadmod_config.txt","DATA") or "") or {Users = {}, Groups = {}, Bans = {}, PPConfig = {}}
function NADMOD.Save()
file.Write("nadmod_config.txt", util.TableToJSON({Users = NADMOD.Users, Groups = NADMOD.Groups, Bans = NADMOD.Bans, PPConfig = NADMOD.PPConfig}))
end
hook.Add("Shutdown","NADMOD.Save",NADMOD.Save)
function NADMOD.FindPlayer(nick)
if not nick or nick == "" then return end
nick = string.lower(nick)
local num = tonumber(nick)
for _,v in pairs(player.GetAll()) do
if string.lower(v:Nick()) == nick then return v -- Exact name match
elseif v:UserID() == num then return v -- UserID match (from status)
end
end
-- If the above two exact searches fail, try doing a partial search
for _,v in pairs(player.GetAll()) do
if string.find(string.lower(v:Nick()), nick) then return v end
end
end
end
if not NADMOD.Props then
-- NADMOD PP Initialization
NADMOD.PPVersion = "1.2.6p"
NADMOD.Props = {} // {entid = {Ent = ent, Owner = ply, SteamID = ply:SteamID(), Name = ply:Nick() or "W" or "O"}}
NADMOD.PropOwnersSmall = {} // A smaller buffer of PropOwner names to send to current players
NADMOD.AutoCDPTimers = {}
local oldCPPI = CPPI
CPPI = {}
-- Copy over default settings if they aren't present in the disk's PPConfig
for k,v in pairs({toggle=true,use=true,adminall=true,autocdp=0,autocdpadmins=false}) do
if NADMOD.PPConfig[k] == nil then NADMOD.PPConfig[k] = v end
end
--AddCSLuaFile("autorun/client/cl_nadmodpp.lua")
util.AddNetworkString("nadmod_propowners")
util.AddNetworkString("nadmod_ppfriends")
util.AddNetworkString("nadmod_ppconfig")
util.AddNetworkString("nadmod_cleanclragdolls")
util.AddNetworkString("nadmod_notify")
timer.Create("WarnOtherPPs", 0, 1, function()
//Print a harmless error if we detect other PP's active, since this often leads to confusion. NPP'll still load fine
//Known CPPI plugins: FPP, SPP, NPP, ULX's UPS
if not oldCPPI or (oldCPPI.GetName and oldCPPI:GetName() == "Nadmod Prop Protection") then oldCPPI = CPPI end
if oldCPPI and (not oldCPPI.GetName or oldCPPI:GetName() ~= "Nadmod Prop Protection") then Error("NPP has detected "..(oldCPPI.GetName and oldCPPI:GetName() or "another CPPI PP").." is installed, you probably only want one PP active at a time!!\n")
elseif PP_Settings then Error("NPP has detected Evolve's PP plugin, you probably only want one PP active at a time!!\n")
end
end)
end
local metaply = FindMetaTable("Player")
local metaent = FindMetaTable("Entity")
-- Does your admin mod not seem to work with Nadmod PP? Try overriding this function!
function NADMOD.IsPPAdmin(ply)
if NADMOD.HasPermission then
return NADMOD.HasPermission(ply, "PP_All")
else
-- If the admin mod NADMOD isn't present, just default to using IsAdmin
return ply:IsAdmin()
end
end
function NADMOD.PPInitPlayer(ply)
local steamid = ply:SteamID()
for _,v in pairs(NADMOD.Props) do
if v.SteamID == steamid then
v.Owner = ply
v.Ent.SPPOwner = ply
v.Ent.Owner = ply
end
end
net.Start("nadmod_propowners")
net.WriteUInt(table.Count(NADMOD.Props),16)
for k,v in pairs(NADMOD.Props) do
net.WriteUInt(k,16)
net.WriteString(v.Name)
end
net.Send(ply)
end
hook.Add("PlayerInitialSpawn", "NADMOD.PPInitPlayer", NADMOD.PPInitPlayer)
function NADMOD.RefreshOwners()
if next(NADMOD.PropOwnersSmall) then
net.Start("nadmod_propowners")
net.WriteUInt(table.Count(NADMOD.PropOwnersSmall),16)
for k,v in pairs(NADMOD.PropOwnersSmall) do
net.WriteUInt(k,16)
net.WriteString(v)
end
//net.WriteTable(NADMOD.PropOwnersSmall)
net.Broadcast()
table.Empty(NADMOD.PropOwnersSmall)
end
end
timer.Create("NADMOD.RefreshOwners", 1, 0, NADMOD.RefreshOwners)
function NADMOD.IsFriendProp(ply, ent)
if IsValid(ent) && IsValid(ply) && ply:IsPlayer() && NADMOD.Props[ent:EntIndex()] then
local ownerSteamID = NADMOD.Props[ent:EntIndex()].SteamID
if NADMOD.Users[ownerSteamID] then
local friends = NADMOD.Users[ownerSteamID].Friends
return friends && friends[ply:SteamID()]
end
end
return false
end
function NADMOD.PlayerCanTouch(ply, ent)
-- If PP is off or the ent is worldspawn, let them touch it
if not tobool(NADMOD.PPConfig["toggle"]) or ent:IsWorld() then return true end
if !IsValid(ent) or !IsValid(ply) or ent:IsPlayer() or !ply:IsPlayer() then return false end
if not NADMOD.Props[ent:EntIndex()] then
local class = ent:GetClass()
if(string.find(class, "stone_") == 1 or string.find(class, "rock_") == 1 or string.find(class, "stargate_") == 0 or string.find(class, "dhd_") == 0 or class == "flag" or class == "item") then
NADMOD.SetOwnerWorld(ent)
else
NADMOD.PlayerMakePropOwner(ply, ent)
NADMOD.Notify(ply, "You now own this prop")
return true
end
end
-- Ownerless props can be touched by all
if NADMOD.Props[ent:EntIndex()].Name == "O" then return true end
-- Admins can touch anyones props + world
if NADMOD.PPConfig["adminall"] and NADMOD.IsPPAdmin(ply) then return true end
-- Players can touch their own props and friends
if NADMOD.Props[ent:EntIndex()].SteamID == ply:SteamID() or NADMOD.IsFriendProp(ply, ent) then return true end
return false
end
-- We could hook directly to PlayerCanTouch, but returning true stops other hooks from being called
function NADMOD.PlayerCanTouchSafe(ply, ent)
if !IsValid(ent) or ent:IsPlayer() then return end
if !NADMOD.PlayerCanTouch(ply,ent) then return false end
end
hook.Add("PhysgunPickup", "NADMOD.PhysgunPickup", NADMOD.PlayerCanTouchSafe)
hook.Add("CanProperty", "NADMOD.CanProperty", function(ply, mode, ent) return NADMOD.PlayerCanTouchSafe(ply, ent) end)
hook.Add("CanEditVariable", "NADMOD.CanEditVariable", function(ent, ply, key, val, editor) return NADMOD.PlayerCanTouchSafe(ply, ent) end)
function NADMOD.OnPhysgunReload(weapon, ply)
local tr = util.TraceLine(util.GetPlayerTrace(ply))
if not tr.HitNonWorld or !tr.Entity:IsValid() or tr.Entity:IsPlayer() then return end
if !NADMOD.PlayerCanTouch(ply, tr.Entity) then return false end
end
hook.Add("OnPhysgunReload", "NADMOD.OnPhysgunReload", NADMOD.OnPhysgunReload)
-- Basically just PlayerCanTouchSafe, but world props are fine to gravgun
function NADMOD.GravGunPickup(ply, ent)
if !IsValid(ent) or ent:IsPlayer() then return end
if NADMOD.Props[ent:EntIndex()] and NADMOD.Props[ent:EntIndex()].Name == "W" then return end
if !NADMOD.PlayerCanTouch(ply,ent) then return false end
end
hook.Add("GravGunPunt", "NADMOD.GravGunPunt", NADMOD.GravGunPickup)
hook.Add("GravGunPickupAllowed", "NADMOD.GravGunPickupAllowed", NADMOD.GravGunPickup)
NADMOD.PPWeirdTraces = {"wire_winch","wire_hydraulic","slider","hydraulic","winch","muscle"}
function NADMOD.CanTool(ply, tr, mode)
local ent = tr.Entity
if !ent:IsWorld() and (!ent:IsValid() or ent:IsPlayer()) then return false end
if !NADMOD.PlayerCanTouch(ply, ent) then
if not ((NADMOD.Props[ent:EntIndex()] or {}).Name == "W" and (mode == "wire_debugger" or mode == "wire_adv")) then
return false
end
elseif(mode == "nail") then
local Trace = {}
Trace.start = tr.HitPos
Trace.endpos = tr.HitPos + (ply:GetAimVector() * 16.0)
Trace.filter = {ply, tr.Entity}
local tr2 = util.TraceLine(Trace)
if(tr2.Hit and IsValid(tr2.Entity) and !tr2.Entity:IsPlayer()) then
if(!NADMOD.PlayerCanTouch(ply, tr2.Entity)) then
return false
end
end
elseif(table.HasValue(NADMOD.PPWeirdTraces, mode)) then
local
Notepad++ is the tab button to indent the line so its not all just one line. Sounds like a personal problem and not anyone elses.(In regards to reformatting 100 lines of code but he kept 400..?)
no he basically sent me it intentionally but somehow it not all got sent maybe it was a limit to letters h could send at one point.
[editline]15th August 2015[/editline]
we are trying to rebuild te purge(round based) any help is greatly apreciated and anyone who helps like xavier did will receive recognition for their work. and im willing to do whatever it takes to get the purge back up and running and not for a fee i simply want to be able to play the game mode that made me love garrys mod so much. and alot of people are missing and they belive that it isnt coming back so in a last attempt we are trying to bring it back to life.
[editline]15th August 2015[/editline]
Ok it looks like its indented now i belive
Sorry, you need to Log In to post a reply to this thread.