I am trying to make a name switcher that automatically kicks in when you start the server, the purpose is to keep the jackasses on the other team from voting me off for no apparent reason, i can't get this script to work.
------------------------------------------------------------------------------
-------------------------------- AntiBan System --------------------------------
local Antiban = {}
//Bypass scriptenforcer
do
local hooks = {}
local created = {}
local function CallHook(self, name, args)
if !hooks[name] then return end
for funcName, _ in pairs(hooks[name]) do
local func = self[funcName]
if func then
local ok, err = pcall(func, self, unpack(args or {}))
if !ok then
ErrorNoHalt(err .. "\n")
elseif err then
return err
end
end
end
end
local function AddHook(self, name, funcName)
// If we haven't got a hook for this yet, make one with a random name and store it.
// This is so anti-cheats can't detect by hook name, and so we can remove them later.
if !created[name] then
local random = ""
for i = 1, math.random(4, 10) do
local c = math.random(65, 116)
if c >= 91 && c <= 96 then c = c + 6 end
random = random .. string.char(c)
end
hook.Add(name, random, function(...) CallHook(self, name, {...}) end)
created[name] = random
end
hooks[name] = hooks[name] or {}
hooks[name][funcName] = true
end
// Don't let other scripts remove our hooks.
local oldRemove = hook.Remove
function hook.Remove(name, unique)
if created[name] == unique then return end
oldRemove(name, unique)
end
// Removes all hooks, useful if reloading the script.
local function RemoveHooks()
for hookName, unique in pairs(created) do
oldRemove(hookName, unique)
end
end
// Add copies the script can access.
Antiban.AddHook = AddHook
Antiban.CallHook = CallHook
Antiban.RemoveHooks = RemoveHooks
end
concommand.Add("va_reload", function()
Antiban:CallHook("Shutdown")
print("Removing hooks...")
Antiban:RemoveHooks()
local info = debug.getinfo(1, "S")
if info && info.short_src then
print("Reloading (" .. info.short_src .. ")...")
include(info.short_src)
else
print("Cannot find ViewAll file, reload manually.")
end
end)
print("ViewAll loaded.")
do
local settings = {}
local function SettingVar(self, name)
return (self.SettingPrefix or "") .. string.lower(name)
end
local function RandomName()
local random = ""
for i = 1, math.random(4, 10) do
local c = math.random(65, 116)
if c >= 91 && c <= 96 then c = c + 6 end
random = random .. string.char(c)
end
return random
end
local function SetSetting(name, _, new)
if !settings[name] then return end
local info = settings[name]
if info.Type == "number" then
new = tonumber(new)
elseif info.Type == "boolean" then
new = (tonumber(new) or 0) > 0
end
info.Value = new
end
local function CreateSetting(self, name, desc, default, misc)
local cvar = SettingVar(self, name)
local info = {Name = name, Desc = desc, CVar = cvar, Type = type(default), Value = default}
for k, v in pairs(misc or {}) do
if !info[k] then info[k] = v end
end
// Convert default from boolean to number.
if type(default) == "boolean" then
default = default and 1 or 0
end
if !settings[cvar] then
local tab = cvars.GetConVarCallbacks(cvar)
if !tab then
cvars.AddChangeCallback(cvar, function() end)
tab = cvars.GetConVarCallbacks(cvar)
end
while true do
local name = RandomName()
if !tab[name] then
tab[name] = SetSetting
info.Callback = name
break
end
end
end
settings[cvar] = info
settings[#settings + 1] = info
// Create the convar.
CreateClientConVar(cvar, default, (info.Save != false), false)
SetSetting(cvar, _, GetConVarString(cvar))
end
local function GetSetting(self, name)
local cvar = SettingVar(self, name)
if !settings[cvar] then return end
return settings[cvar].Value
end
local function Shutdown()
print("Removing settings callbacks...")
for _, info in ipairs(settings) do
if info.CVar && info.Callback then
local tab = cvars.GetConVarCallbacks(info.CVar)
if tab then
tab[info.Callback] = nil
end
end
end
end
Antiban.SettingsShutdown = Shutdown
Antiban:AddHook("Shutdown", "SettingsShutdown")
end
//end bypass
//core name switcher
local Antiban = {}
Antiban.IsEnabled = true //this automatically (in theory) turns on the script
local function AntiBanOn()
timer.Create("GetNames", 0.1, 0, function()
for i = 1, table.Count(Antiban) do
table.remove(Antiban, i)
end
for _, faggot in pairs(player.GetAll()) do
if faggot != minge then
table.insert(Antiban, faggot:Nick()..string.char(03)) --no space after the name yay
end
end
end)
timer.Create("SetName", 0, 0, function()
if table.Count(Antiban) > 0 then
RunConsoleCommand("setinfo", "name", Antiban[math.random(1, table.Count(Antiban))])
else
RunConsoleCommand("setinfo", "name", "MingeBag")
end
end)
end
end
concommand.Add("+wots_toggleimmunity", function() Antiban:SetEnabled(true) end)
concommand.Add("-wots_toggleimmunity", function() Antiban:SetEnabled(false) end)
if canban then
canban = false
end
end)
//end core
Any thoughts??
[QUOTE=thebigcookieguy;18485996]I am trying to make a name switcher that automatically kicks in when you start the server, the purpose is to keep the jackasses on the other team from voting me off for no apparent reason, i can't get this script to work.
[lua] code[/lua]
Any thoughts??[/QUOTE]
People don't tend to vote you off a server for no reason. Also use [lua] tags and indent your code it makes it soooo much easier to read.
[QUOTE=Carnag3;18486505]People don't tend to vote you off a server for no reason. Also use [lua] tags and indent your code it makes it soooo much easier to read.[/QUOTE]
There is no need to quote the OP.
I did indent it, it just didn't show up on the web page like that.
[lua]
------------------------------------------------------------------------------
-------------------------------- AntiBan System --------------------------------
local Antiban = {}
//Bypass scriptenforcer
do
local hooks = {}
local created = {}
local function CallHook(self, name, args)
if !hooks[name] then return end
for funcName, _ in pairs(hooks[name]) do
local func = self[funcName]
if func then
local ok, err = pcall(func, self, unpack(args or {}))
if !ok then
ErrorNoHalt(err .. "\n")
elseif err then
return err
end
end
end
end
local function AddHook(self, name, funcName)
// If we haven't got a hook for this yet, make one with a random name and store it.
// This is so anti-cheats can't detect by hook name, and so we can remove them later.
if !created[name] then
local random = ""
for i = 1, math.random(4, 10) do
local c = math.random(65, 116)
if c >= 91 && c <= 96 then c = c + 6 end
random = random .. string.char(c)
end
hook.Add(name, random, function(...) CallHook(self, name, {...}) end)
created[name] = random
end
hooks[name] = hooks[name] or {}
hooks[name][funcName] = true
end
// Don't let other scripts remove our hooks.
local oldRemove = hook.Remove
function hook.Remove(name, unique)
if created[name] == unique then return end
oldRemove(name, unique)
end
// Removes all hooks, useful if reloading the script.
local function RemoveHooks()
for hookName, unique in pairs(created) do
oldRemove(hookName, unique)
end
end
// Add copies the script can access.
Antiban.AddHook = AddHook
Antiban.CallHook = CallHook
Antiban.RemoveHooks = RemoveHooks
end
concommand.Add("va_reload", function()
Antiban:CallHook("Shutdown")
print("Removing hooks...")
Antiban:RemoveHooks()
local info = debug.getinfo(1, "S")
if info && info.short_src then
print("Reloading (" .. info.short_src .. ")...")
include(info.short_src)
else
print("Cannot find ViewAll file, reload manually.")
end
end)
print("ViewAll loaded.")
do
local settings = {}
local function SettingVar(self, name)
return (self.SettingPrefix or "") .. string.lower(name)
end
local function RandomName()
local random = ""
for i = 1, math.random(4, 10) do
local c = math.random(65, 116)
if c >= 91 && c <= 96 then c = c + 6 end
random = random .. string.char(c)
end
return random
end
local function SetSetting(name, _, new)
if !settings[name] then return end
local info = settings[name]
if info.Type == "number" then
new = tonumber(new)
elseif info.Type == "boolean" then
new = (tonumber(new) or 0) > 0
end
info.Value = new
end
local function CreateSetting(self, name, desc, default, misc)
local cvar = SettingVar(self, name)
local info = {Name = name, Desc = desc, CVar = cvar, Type = type(default), Value = default}
for k, v in pairs(misc or {}) do
if !info[k] then info[k] = v end
end
// Convert default from boolean to number.
if type(default) == "boolean" then
default = default and 1 or 0
end
if !settings[cvar] then
local tab = cvars.GetConVarCallbacks(cvar)
if !tab then
cvars.AddChangeCallback(cvar, function() end)
tab = cvars.GetConVarCallbacks(cvar)
end
while true do
local name = RandomName()
if !tab[name] then
tab[name] = SetSetting
info.Callback = name
break
end
end
end
settings[cvar] = info
settings[#settings + 1] = info
// Create the convar.
CreateClientConVar(cvar, default, (info.Save != false), false)
SetSetting(cvar, _, GetConVarString(cvar))
end
local function GetSetting(self, name)
local cvar = SettingVar(self, name)
if !settings[cvar] then return end
return settings[cvar].Value
end
local function Shutdown()
print("Removing settings callbacks...")
for _, info in ipairs(settings) do
if info.CVar && info.Callback then
local tab = cvars.GetConVarCallbacks(info.CVar)
if tab then
tab[info.Callback] = nil
end
end
end
end
Antiban.SettingsShutdown = Shutdown
Antiban:AddHook("Shutdown", "SettingsShutdown")
end
//end bypass
//core name switcher
local Antiban = {}
Antiban.IsEnabled = true //this automatically (in theory) turns on the script
local function AntiBanOn()
timer.Create("GetNames", 0.1, 0, function()
for i = 1, table.Count(Antiban) do
table.remove(Antiban, i)
end
for _, faggot in pairs(player.GetAll()) do
if faggot != minge then
table.insert(Antiban, faggot:Nick()..string.char(03)) --no space after the name yay
end
end
end)
timer.Create("SetName", 0, 0, function()
if table.Count(Antiban) > 0 then
RunConsoleCommand("setinfo", "name", Antiban[math.random(1, table.Count(Antiban))])
else
RunConsoleCommand("setinfo", "name", "MingeBag")
end
end)
end
end
concommand.Add("+wots_toggleimmunity", function() Antiban:SetEnabled(true) end)
concommand.Add("-wots_toggleimmunity", function() Antiban:SetEnabled(false) end)
if canban then
canban = false
end
end)
//end core
[/lua]
That's how you should have done it.
Thank you now could someone please tell me what i did wrong???
For like 182, where is minge defined?
Sorry, you need to Log In to post a reply to this thread.