forked from Nebual/NadmodPP
Refactored wrapper function
Remade to be player:function to match origional SteamID64() instead of function( player )
This commit is contained in:
parent
eb7e93f28c
commit
5b9f4db3dd
@ -198,28 +198,30 @@ function NADMOD.AdminPanel(Panel, runByNetReceive)
|
|||||||
Panel:Button("Cleanup World Ropes", "nadmod_cleanworldropes")
|
Panel:Button("Cleanup World Ropes", "nadmod_cleanworldropes")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local metaply = FindMetaTable("Player")
|
||||||
|
|
||||||
-- Wrapper function as Bots return nothing clientside for their SteamID64
|
-- Wrapper function as Bots return nothing clientside for their SteamID64
|
||||||
function SteamID64bot( ply )
|
function metaply:SteamID64bot()
|
||||||
if( not IsValid( ply ) ) then return end
|
if( not IsValid( self ) ) then return end
|
||||||
if ply:IsBot() then
|
if self:IsBot() then
|
||||||
-- Calculate Bot's SteamID64 according to gmod wiki
|
-- Calculate Bot's SteamID64 according to gmod wiki
|
||||||
return 90071996842377216 + tonumber( string.sub( ply:Nick(), 4) )
|
return 90071996842377216 + tonumber( string.sub( self:Nick(), 4) )
|
||||||
else
|
else
|
||||||
return ply:SteamID64()
|
return self:SteamID64()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
net.Receive("nadmod_ppfriends",function(len)
|
net.Receive("nadmod_ppfriends",function(len)
|
||||||
NADMOD.Friends = net.ReadTable()
|
NADMOD.Friends = net.ReadTable()
|
||||||
for _,tar in pairs(player.GetAll()) do
|
for _,tar in pairs(player.GetAll()) do
|
||||||
CreateClientConVar("npp_friend_"..SteamID64bot(tar),NADMOD.Friends[tar:SteamID()] and "1" or "0", false, false)
|
CreateClientConVar("npp_friend_"..tar:SteamID64bot(),NADMOD.Friends[tar:SteamID()] and "1" or "0", false, false)
|
||||||
RunConsoleCommand("npp_friend_"..SteamID64bot(tar),NADMOD.Friends[tar:SteamID()] and "1" or "0")
|
RunConsoleCommand("npp_friend_"..tar:SteamID64bot(),NADMOD.Friends[tar:SteamID()] and "1" or "0")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
concommand.Add("npp_applyfriends",function(ply,cmd,args)
|
concommand.Add("npp_applyfriends",function(ply,cmd,args)
|
||||||
for _,tar in pairs(player.GetAll()) do
|
for _,tar in pairs(player.GetAll()) do
|
||||||
NADMOD.Friends[tar:SteamID()] = GetConVar("npp_friend_"..SteamID64bot(tar)):GetBool()
|
NADMOD.Friends[tar:SteamID()] = GetConVar("npp_friend_"..tar:SteamID64bot()):GetBool()
|
||||||
end
|
end
|
||||||
net.Start("nadmod_ppfriends")
|
net.Start("nadmod_ppfriends")
|
||||||
net.WriteTable(NADMOD.Friends)
|
net.WriteTable(NADMOD.Friends)
|
||||||
@ -246,7 +248,7 @@ function NADMOD.ClientPanel(Panel)
|
|||||||
else
|
else
|
||||||
for _, tar in pairs(Players) do
|
for _, tar in pairs(Players) do
|
||||||
if(IsValid(tar) and tar != LocalPlayer()) then
|
if(IsValid(tar) and tar != LocalPlayer()) then
|
||||||
Panel:CheckBox(tar:Nick(), "npp_friend_"..SteamID64bot(tar))
|
Panel:CheckBox(tar:Nick(), "npp_friend_"..tar:SteamID64bot())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Panel:Button("Apply Friends", "npp_applyfriends")
|
Panel:Button("Apply Friends", "npp_applyfriends")
|
||||||
@ -278,7 +280,6 @@ end)
|
|||||||
|
|
||||||
CPPI = {}
|
CPPI = {}
|
||||||
local metaent = FindMetaTable("Entity")
|
local metaent = FindMetaTable("Entity")
|
||||||
local metaply = FindMetaTable("Player")
|
|
||||||
|
|
||||||
function CPPI:GetName() return "Nadmod Prop Protection" end
|
function CPPI:GetName() return "Nadmod Prop Protection" end
|
||||||
function CPPI:GetVersion() return "" end
|
function CPPI:GetVersion() return "" end
|
||||||
|
Loading…
Reference in New Issue
Block a user