• Storing files in garrysmod/data
    16 replies, posted
I have a config file that is supposed to save in "garrysmod/data/mas_data", but it never ends up in the "mas_data" or "data" folders. I have no clue where my addon is storing the config. Any help is greatly appreciated! Below is everything that deals with the config file: [CODE] -- If DATA directory doesn't exist, make it -- if !file.Exists( "mas_data", "DATA" ) then file.CreateDir( "mas_data", "DATA" ) end -- Protection Variables -- AntiSpam = {} AntiSpam.Chat = {} AntiSpam.Prop = {} AntiSpam.Sent = {} AntiSpam.Effect = {} AntiSpam.Ragdoll = {} AntiSpam.Vehicle = {} AntiSpam.Npc = {} -- Includes -- include("von.lua") -- Config File Defaults -- //These will be the default values when changed in the file. AntiSpam.AntiSpamming = true AntiSpam.Chat.Enabled = true AntiSpam.Prop.Enabled = true AntiSpam.Sent.Enabled = true AntiSpam.Effect.Enabled = true AntiSpam.Ragdoll.Enabled = true AntiSpam.Vehicle.Enabled = false AntiSpam.Npc.Enabled = true AntiSpam.Chat.Delay = 1 AntiSpam.Prop.Delay = 1 AntiSpam.Sent.Delay = 1 AntiSpam.Effect.Delay = 1 AntiSpam.Ragdoll.Delay = 1 AntiSpam.Vehicle.Delay = 1 AntiSpam.Npc.Delay = 1 -- Serialization & De-Serialization of the config file -- function SettingsSave() //This method takes the table and converts it into a string before saving it to a file. This needs to be ran every time you change a value in SETTINGS. local SettingString = von.serialize(AntiSpam) file.Write("mas_data/antispam.txt", SettingString) //The file will be in the data/ folder. Use lower case filenames! print("ANTI-SPAM SETTINGS HAVE BEEN SAVED!") end function SettingsLoad() //This method opens the file if it exists and converts the string stored into a table. This needs running when the addon initialises. if file.Exists("mas_data/antispam.txt", "DATA") then //Im hoping this bit is self explanatory. DATA means the data folder. local ReadFile = file.Read("mas_data/antispam.txt", "DATA") //Read file from DATA folder. Returns a string. AntiSpam = von.deserialize(ReadFile) //Overwrite the settings table with values from file. Msg("AntiSpam SETTINGS LOADED") end end function CheckBooleanFunc( input ) if(input == "on") then // so if the command is !antispam chat on return true elseif(input == "off") then return false end end function CheckNumberFunc( input ) if ( type(tonumber(input)) == "number" ) then if ( tonumber(input) >= 0 ) then return input elseif ( tonumber(input) < 0 ) then return '1' end end end -- Enable-Disable Features & Delays -- hook.Add( "PlayerSay", "ChangeAction", function( ply, text, public ) //An example of a chat command changing a setting. text = string.lower( text ) text = string.Explode( " ", text ) if ply:IsUserGroup( "superadmin", "owner" ) then //Add groups who you want to access the script here(Currently on supports ULX) if ( text[1] == "!antispam" ) then if ( text[2] == "on" ) then AntiSpam.AntiSpamming = true //Change das value. elseif ( text[2] == "off" ) then AntiSpam.AntiSpamming = false //Change das value elseif ( text[2] == "chat" ) then AntiSpam.Chat.Enabled.CheckBooleanFunc( text[3] ) ply:ChatPrint( "Chat spam protection has been set to "..text[3] ) elseif ( text[2] == "props" ) then AntiSpam.Prop.Enabled.CheckBooleanFunc( text[3] ) elseif ( text[2] == "sents" ) then AntiSpam.Sent.Enabled.CheckBooleanFunc( text[3] ) elseif ( text[2] == "effects" ) then AntiSpam.Effect.Enabled.CheckBooleanFunc( text[3] ) elseif ( text[2] == "ragdolls" ) then AntiSpam.Ragdoll.Enabled.CheckBooleanFunc( text[3] ) elseif ( text[2] == "vehicles" ) then AntiSpam.Vehicle.Enabled.CheckBooleanFunc( text[3] ) elseif ( text[2] == "chatdelay" && CheckNumberFunc( text[3] ) ) then AntiSpam.Chat.Delay( text[3] ) end SettingsSave() end else ply:ChatPrint( "You do not have the permissions to do this!" ) return '' end end) [/CODE]
I was going to make a pull request on your github repository, but you deleted it, so I'll post the "right"(I didn't test it, but looks like its fixed) code here: [lua] /*=======================================*\ |==========================================| Anti-Spam Protection By: MexicanRaindeer Copyright © 2015-2016 MexicanRaindeer |==========================================| \*=======================================*/ -- Check for updates -- local version = "1.0.0" http.Fetch( "https://gist.githubusercontent.com/Kyrpt0/0393ae3aef12db36ba7a/raw/MASVersion", function( body ) if body == version then MsgC( "[MAS]You're Up-to-date with version "..version ) else MsgC( "[MAS]You're not Up-to-date, please download new version!" ) end end, function( error ) MsgC( "[MAS]Failed to check version!" ) end ) -- If DATA directory doesn't exist, make it -- if !file.Exists( "mas_data", "DATA" ) then file.CreateDir( "mas_data", "DATA" ) end -- Protection Variables -- AntiSpam = {} AntiSpam.Chat = {} AntiSpam.Prop = {} AntiSpam.Sent = {} AntiSpam.Effect = {} AntiSpam.Ragdoll = {} AntiSpam.Vehicle = {} AntiSpam.Npc = {} AntiSpam.Settings = {} -- Includes -- include("von.lua") -- Config File Defaults -- // These will be the default values when changed in the file. // The AntiSpam system is enabled by default AntiSpam.Settings.AntiSpamming = true // Chat AntiSpam Settings AntiSpam.Settings.Chat = {} AntiSpam.Settings.Chat.Enabled = true AntiSpam.Settings.Chat.Delay = 1 // Prop AntiSpam Settings AntiSpam.Settings.Prop = {} AntiSpam.Settings.Prop.Enabled = true AntiSpam.Settings.Prop.Delay = 1 // Scripted Ents AntiSpam Settings AntiSpam.Settings.Sent = {} AntiSpam.Settings.Sent.Enabled = true AntiSpam.Settings.Sent.Delay = 1 // Effects AntiSpam Settings AntiSpam.Settings.Effect = {} AntiSpam.Settings.Effect.Enabled = true AntiSpam.Settings.Effect.Delay = 1 // Ragdoll AntiSpam Settings AntiSpam.Settings.Ragdoll = {} AntiSpam.Settings.Ragdoll.Enabled = true AntiSpam.Settings.Ragdoll.Delay = 1 // Vehicle AntiSpam Settings AntiSpam.Settings.Vehicle = {} AntiSpam.Settings.Vehicle.Enabled = false AntiSpam.Settings.Vehicle.Delay = 1 // NPC AntiSpam Settings AntiSpam.Settings.Npc = {} AntiSpam.Settings.Npc.Enabled = true AntiSpam.Settings.Npc.Delay = 1 -- Serialization & De-Serialization of the config file -- function SettingsSave() //This method takes the table and converts it into a string before saving it to a file. This needs to be ran every time you change a value in SETTINGS. local SettingString = von.serialize(AntiSpam.Settings) file.Write("mas_data/antispam.txt", SettingString) //The file will be in the data/ folder. Use lower case filenames! print("ANTI-SPAM SETTINGS HAVE BEEN SAVED!") end function SettingsLoad() //This method opens the file if it exists and converts the string stored into a table. This needs running when the addon initialises. if file.Exists("mas_data/antispam.txt", "DATA") then //Im hoping this bit is self explanatory. DATA means the data folder. local ReadFile = file.Read("mas_data/antispam.txt", "DATA") //Read file from DATA folder. Returns a string. AntiSpam.Settings = von.deserialize(ReadFile) //Overwrite the settings table with values from file. Msg("AntiSpam SETTINGS LOADED") end end function CheckBooleanFunc( input ) if(input == "on") then // so if the command is !antispam chat on return true elseif(input == "off") then return false end end function CheckNumberFunc( input ) if ( type(tonumber(input)) == "number" ) then if ( tonumber(input) >= 0 ) then return tonumber(input) elseif ( tonumber(input) < 0 ) then return '1' end end end -- Enable-Disable Features & Delays -- hook.Add( "PlayerSay", "ChangeAction", function( ply, text, public ) //An example of a chat command changing a setting. text = string.lower( text ) text = string.Explode( " ", text ) if ply:IsUserGroup( "superadmin", "owner" ) then if ( text[1] == "!antispam" ) then if ( text[2] == "on" ) then AntiSpam.Settings.AntiSpamming = true //Change das value. elseif ( text[2] == "off" ) then AntiSpam.Settings.AntiSpamming = false //Change das value elseif ( text[2] == "chat" ) then AntiSpam.Settings.Chat.Enabled = CheckBooleanFunc( text[3] ) ply:ChatPrint( "Chat spam protection has been set to "..text[3] ) elseif ( text[2] == "props" ) then AntiSpam.Settings.Prop.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "sents" ) then AntiSpam.Settings.Sent.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "effects" ) then AntiSpam.Settings.Effect.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "ragdolls" ) then AntiSpam.Settings.Ragdoll.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "vehicles" ) then AntiSpam.Settings.Vehicle.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "chatdelay" && tonumber(text[3]) ~= nil ) then AntiSpam.Settings.Chat.Delay = CheckNumberFunc(text[3]) end SettingsSave() end else ply:ChatPrint( "You do not have the permissions to do this!" ) return '' end end) -- Anti-Spam Script Start -- local meta = FindMetaTable("Player") function AntiSpam.Chat.ResetTimer(pl) pl:EnableChatting(true) end function AntiSpam.Chat.Chatting( ply, text ) if AntiSpam.Settings.Chat.Enabled then if AntiSpam.Settings.AntiSpamming then if !ply:CanChat() then ply:PrintMessage(HUD_PRINTCONSOLE, "Message \""..text.."\" was not sent.\n") ply:PrintMessage(HUD_PRINTTALK, "STOP SPAMMING THE SERVER!") return "" end ply:EnableChatting(false) timer.Simple(AntiSpam.Settings.Chat.Delay, AntiSpam.Chat.ResetTimer, ply) end else return '' end end // hook event when a player enters something into chat hook.Add("PlayerSay", "AntiSpam.Chat.Chatting", AntiSpam.Chat.Chatting) function AntiSpam.Prop.ResetTimer(pl) pl:EnablePropSpawning(true) end function AntiSpam.Prop.Spawning( ply, model, ent ) if AntiSpam.Settings.Prop.Enabled == true then if AntiSpam.Settings.AntiSpamming then if !ply:CanPropSpawn() then ply:SendLua("GAMEMODE:AddNotify(\"STOP SPAMMING THE SERVER!\", NOTIFY_ERROR, 5)") return false end ply:EnablePropSpawning(false) timer.Simple(AntiSpam.Settings.Prop.Delay, AntiSpam.Prop.ResetTimer, ply) end else return '' end end // hook event when a player spawns a prop hook.Add("PlayerSpawnProp", "AntiSpam.Prop.Spawning", AntiSpam.Prop.Spawning) function AntiSpam.Sent.ResetTimer(pl) pl:EnableSentSpawning(true) end function AntiSpam.Sent.Spawning( ply, model, ent ) if AntiSpam.Settings.Sent.Enabled == true then if AntiSpam.Settings.AntiSpamming then if !ply:CanSentSpawn() then ply:SendLua("GAMEMODE:AddNotify(\"STOP SPAMMING THE SERVER!\", NOTIFY_ERROR, 5)") return false end ply:EnableSentSpawning(false) timer.Simple(AntiSpam.Settings.Sent.Delay, AntiSpam.Sent.ResetTimer, ply) end else return '' end end // hook event when a player spawns a SENT hook.Add("PlayerSpawnSENT", "AntiSpam.Sent.Spawning", AntiSpam.Sent.Spawning) function AntiSpam.Effect.ResetTimer(pl) pl:EnableEffectSpawning(true) end function AntiSpam.Effect.Spawning( ply, model, ent ) if AntiSpam.Settings.Effect.Enabled == true then if AntiSpam.Settings.AntiSpamming then if !ply:CanEffectSpawn() then ply:SendLua("GAMEMODE:AddNotify(\"STOP SPAMMING THE SERVER!\", NOTIFY_ERROR, 5)") return false end ply:EnableEffectSpawning(false) timer.Simple(AntiSpam.Settings.Effect.Delay, AntiSpam.Effect.ResetTimer, ply) end else return '' end end // hook event when a player spawns an effect hook.Add("Play
[QUOTE=GGG KILLER;49416660]I was going to make a pull request on your github repository, but you deleted it, so I'll post the "right"(I didn't test it, but looks like its fixed) code here: [lua] /*=======================================*\ |==========================================| Anti-Spam Protection By: MexicanRaindeer Copyright © 2015-2016 MexicanRaindeer |==========================================| \*=======================================*/ -- Check for updates -- local version = "1.0.0" http.Fetch( "https://gist.githubusercontent.com/Kyrpt0/0393ae3aef12db36ba7a/raw/MASVersion", function( body ) if body == version then MsgC( "[MAS]You're Up-to-date with version "..version ) else MsgC( "[MAS]You're not Up-to-date, please download new version!" ) end end, function( error ) MsgC( "[MAS]Failed to check version!" ) end ) -- If DATA directory doesn't exist, make it -- if !file.Exists( "mas_data", "DATA" ) then file.CreateDir( "mas_data", "DATA" ) end -- Protection Variables -- AntiSpam = {} AntiSpam.Chat = {} AntiSpam.Prop = {} AntiSpam.Sent = {} AntiSpam.Effect = {} AntiSpam.Ragdoll = {} AntiSpam.Vehicle = {} AntiSpam.Npc = {} AntiSpam.Settings = {} -- Includes -- include("von.lua") -- Config File Defaults -- // These will be the default values when changed in the file. // The AntiSpam system is enabled by default AntiSpam.Settings.AntiSpamming = true // Chat AntiSpam Settings AntiSpam.Settings.Chat = {} AntiSpam.Settings.Chat.Enabled = true AntiSpam.Settings.Chat.Delay = 1 // Prop AntiSpam Settings AntiSpam.Settings.Prop = {} AntiSpam.Settings.Prop.Enabled = true AntiSpam.Settings.Prop.Delay = 1 // Scripted Ents AntiSpam Settings AntiSpam.Settings.Sent = {} AntiSpam.Settings.Sent.Enabled = true AntiSpam.Settings.Sent.Delay = 1 // Effects AntiSpam Settings AntiSpam.Settings.Effect = {} AntiSpam.Settings.Effect.Enabled = true AntiSpam.Settings.Effect.Delay = 1 // Ragdoll AntiSpam Settings AntiSpam.Settings.Ragdoll = {} AntiSpam.Settings.Ragdoll.Enabled = true AntiSpam.Settings.Ragdoll.Delay = 1 // Vehicle AntiSpam Settings AntiSpam.Settings.Vehicle = {} AntiSpam.Settings.Vehicle.Enabled = false AntiSpam.Settings.Vehicle.Delay = 1 // NPC AntiSpam Settings AntiSpam.Settings.Npc = {} AntiSpam.Settings.Npc.Enabled = true AntiSpam.Settings.Npc.Delay = 1 -- Serialization & De-Serialization of the config file -- function SettingsSave() //This method takes the table and converts it into a string before saving it to a file. This needs to be ran every time you change a value in SETTINGS. local SettingString = von.serialize(AntiSpam.Settings) file.Write("mas_data/antispam.txt", SettingString) //The file will be in the data/ folder. Use lower case filenames! print("ANTI-SPAM SETTINGS HAVE BEEN SAVED!") end function SettingsLoad() //This method opens the file if it exists and converts the string stored into a table. This needs running when the addon initialises. if file.Exists("mas_data/antispam.txt", "DATA") then //Im hoping this bit is self explanatory. DATA means the data folder. local ReadFile = file.Read("mas_data/antispam.txt", "DATA") //Read file from DATA folder. Returns a string. AntiSpam.Settings = von.deserialize(ReadFile) //Overwrite the settings table with values from file. Msg("AntiSpam SETTINGS LOADED") end end function CheckBooleanFunc( input ) if(input == "on") then // so if the command is !antispam chat on return true elseif(input == "off") then return false end end function CheckNumberFunc( input ) if ( type(tonumber(input)) == "number" ) then if ( tonumber(input) >= 0 ) then return tonumber(input) elseif ( tonumber(input) < 0 ) then return '1' end end end -- Enable-Disable Features & Delays -- hook.Add( "PlayerSay", "ChangeAction", function( ply, text, public ) //An example of a chat command changing a setting. text = string.lower( text ) text = string.Explode( " ", text ) if ply:IsUserGroup( "superadmin", "owner" ) then if ( text[1] == "!antispam" ) then if ( text[2] == "on" ) then AntiSpam.Settings.AntiSpamming = true //Change das value. elseif ( text[2] == "off" ) then AntiSpam.Settings.AntiSpamming = false //Change das value elseif ( text[2] == "chat" ) then AntiSpam.Settings.Chat.Enabled = CheckBooleanFunc( text[3] ) ply:ChatPrint( "Chat spam protection has been set to "..text[3] ) elseif ( text[2] == "props" ) then AntiSpam.Settings.Prop.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "sents" ) then AntiSpam.Settings.Sent.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "effects" ) then AntiSpam.Settings.Effect.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "ragdolls" ) then AntiSpam.Settings.Ragdoll.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "vehicles" ) then AntiSpam.Settings.Vehicle.Enabled = CheckBooleanFunc( text[3] ) elseif ( text[2] == "chatdelay" && tonumber(text[3]) ~= nil ) then AntiSpam.Settings.Chat.Delay = CheckNumberFunc(text[3]) end SettingsSave() end else ply:ChatPrint( "You do not have the permissions to do this!" ) return '' end end) -- Anti-Spam Script Start -- local meta = FindMetaTable("Player") function AntiSpam.Chat.ResetTimer(pl) pl:EnableChatting(true) end function AntiSpam.Chat.Chatting( ply, text ) if AntiSpam.Settings.Chat.Enabled then if AntiSpam.Settings.AntiSpamming then if !ply:CanChat() then ply:PrintMessage(HUD_PRINTCONSOLE, "Message \""..text.."\" was not sent.\n") ply:PrintMessage(HUD_PRINTTALK, "STOP SPAMMING THE SERVER!") return "" end ply:EnableChatting(false) timer.Simple(AntiSpam.Settings.Chat.Delay, AntiSpam.Chat.ResetTimer, ply) end else return '' end end // hook event when a player enters something into chat hook.Add("PlayerSay", "AntiSpam.Chat.Chatting", AntiSpam.Chat.Chatting) function AntiSpam.Prop.ResetTimer(pl) pl:EnablePropSpawning(true) end function AntiSpam.Prop.Spawning( ply, model, ent ) if AntiSpam.Settings.Prop.Enabled == true then if AntiSpam.Settings.AntiSpamming then if !ply:CanPropSpawn() then ply:SendLua("GAMEMODE:AddNotify(\"STOP SPAMMING THE SERVER!\", NOTIFY_ERROR, 5)") return false end ply:EnablePropSpawning(false) timer.Simple(AntiSpam.Settings.Prop.Delay, AntiSpam.Prop.ResetTimer, ply) end else return '' end end // hook event when a player spawns a prop hook.Add("PlayerSpawnProp", "AntiSpam.Prop.Spawning", AntiSpam.Prop.Spawning) function AntiSpam.Sent.ResetTimer(pl) pl:EnableSentSpawning(true) end function AntiSpam.Sent.Spawning( ply, model, ent ) if AntiSpam.Settings.Sent.Enabled == true then if AntiSpam.Settings.AntiSpamming then if !ply:CanSentSpawn() then ply:SendLua("GAMEMODE:AddNotify(\"STOP SPAMMING THE SERVER!\", NOTIFY_ERROR, 5)") return false end ply:EnableSentSpawning(false) timer.Simple(AntiSpam.Settings.Sent.Delay, AntiSpam.Sent.ResetTimer, ply) end else return '' end end // hook event when a player spawns a SENT hook.Add("PlayerSpawnSENT", "AntiSpam.Sent.Spawning", AntiSpam.Sent.Spawning) function AntiSpam.Effect.ResetTimer(pl) pl:EnableEffectSpawning(true) end function AntiSpam.Effect.Spawning( ply, model, ent ) if AntiSpam.Settings.Effect.Enabled == true then if AntiSpam.Settings.AntiSpamming then if !ply:CanEffectSpawn() then ply:SendLua("GAMEMODE:AddNotify(\"STOP SPAMMING THE SERVER!\", NOTIFY_ERROR, 5)") return false end ply:EnableEffectSpawning(false) timer.Simple(AntiSpam.Settings.Effect.Delay, AntiSpam.Effect.ResetTimer, ply) end else return '' end end // hook event when a player spawn
Maybe because the chat commands hook does not let the player talk unless the player is on the superadmin or owner group? [editline]30th December 2015[/editline] Wait, nvm, its not that, let me see if I can find what it is...
[QUOTE=GGG KILLER;49416762]Maybe because the chat commands hook does not let the player talk unless the player is on the superadmin or owner group? [editline]30th December 2015[/editline] Wait, nvm, its not that, let me see if I can find what it is...[/QUOTE] Is it the timers for the actual function controlling whether the player can chat?
Yeah, read this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] It only accepts 2 arguments, the rest of the arguments passed are discarded, so you'll have to find another way to make the timers work. A way you could use is function currying (bind a function to a list of arguments) like FPtje does on DarkRP [editline]30th December 2015[/editline] But the chat command hook is a real issue, the player will not be able to talk unless he is on the "superadmin" or "owner" group, I suggest making the check for the "!antispam" before and ignore if it was not an "!antispam" command.
[QUOTE=GGG KILLER;49416783]Yeah, read this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Simple]timer.Simple[/url] It only accepts 2 arguments, the rest of the arguments passed are discarded, so you'll have to find another way to make the timers work. [editline]30th December 2015[/editline] But the chat command hook is a real issue, the player will not be able to talk unless he is on the "superadmin" or "owner" group, I suggest making the check for the "!antispam" before and ignore if it was not an "!antispam" command.[/QUOTE] Great, I have no clue what to do now. Back to the drawing board. :suicide:
[QUOTE=MexicanR;49416804]Great, I have no clue what to do now. Back to the drawing board. :suicide:[/QUOTE] You could instead of passing AntiSpam.<antispam controller>.ResetTimer as an argument do this on all of the timers: [lua] timer.Simple(AntiSpam.Settings.Chat.Delay, function() AntiSpam.Chat.ResetTimer (ply) end) [/lua]
[QUOTE=GGG KILLER;49416829]You could instead of passing AntiSpam.<antispam controller>.ResetTimer as an argument do this on all of the timers: [lua] timer.Simple(AntiSpam.Settings.Chat.Delay, function() AntiSpam.Chat.ResetTimer (ply) end) [/lua][/QUOTE] It still does the same thing, I have no clue why though?
The blocking never did work, now that I realized, the function you're using "table.ValueToKey" doesn't exists. [editline]30th December 2015[/editline] Maybe the function you were looking for is [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/KeyFromValue]table.KeyFromValue[/url]?
[QUOTE=GGG KILLER;49416971]The blocking never did work, now that I realized, the function you're using "table.ValueToKey" doesn't exists. [editline]30th December 2015[/editline] Maybe the function you were looking for is [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/KeyFromValue]table.KeyFromValue[/url]?[/QUOTE] I forgot to include my table.lua file. ValueToKey is part of a custom library I made. I listed the table.lua file just in case you wanted to see it. [CODE] // globals local table = table //----------------------------------------------------------------------------- // Description: This checks if a table exists or not // Input: table // Returns: boolean //----------------------------------------------------------------------------- function table.Exists(_table) if type(_table) == "table" then return true end return false end //----------------------------------------------------------------------------- // Description: This gets the number of keys in a table // Input: table // Returns: number //----------------------------------------------------------------------------- function table.GetNumKeys(_table) local NumKeys = 0 for k,v in pairs(_table) do NumKeys = NumKeys + 1 end return tonumber(NumKeys) end //----------------------------------------------------------------------------- // Description: This deletes a table // Input: table //----------------------------------------------------------------------------- function table.Delete(_table) _table = nil end //----------------------------------------------------------------------------- // Description: This clears all values and keys in a table // Input: table //----------------------------------------------------------------------------- function table.Clear(_table) for k,v in pairs(_table) do table.remove(_table,tonumber(k)) end end //----------------------------------------------------------------------------- // Description: This gets the position (key) of the value // Input: table,value //----------------------------------------------------------------------------- function table.ValueToKey(_table,value) for k,v in pairs(_table) do if v == value then return k end end end //----------------------------------------------------------------------------- // Description: This returns the value of the position (key) // Input: table,key //----------------------------------------------------------------------------- function table.KeyToValue(_table,key) for k,v in pairs(_table) do if k == key then return v end end end [/CODE]
The setting you changed wasn't disabling the chat antispam? because on that hook, if the chat antispam is disabled, it disables the chat entirely by returning an empty string.
[QUOTE=GGG KILLER;49417028]The setting you changed wasn't disabling the chat antispam? because on that hook, if the chat antispam is disabled, it disables the chat entirely by returning an empty string.[/QUOTE] I see that now, the thing that confuses me is that I had it working properly last night. [editline]30th December 2015[/editline] [QUOTE=MexicanR;49417057]I see that now, the thing that confuses me is that I had it working properly last night.[/QUOTE] This should solve the problem [CODE] function meta:CanChat() if AntiSpam.Settings.Chat.Enabled == true then return true elseif table.HasValue(AntiSpam.Chat.Players, self:SteamID()) then return false else return true end end [/CODE]
no, that still won't solve the problem. The problem is here: [lua] function AntiSpam.Chat.Chatting( ply, text ) if AntiSpam.Settings.Chat.Enabled then if AntiSpam.Settings.AntiSpamming then if !ply:CanChat() then ply:PrintMessage(HUD_PRINTCONSOLE, "Message \""..text.."\" was not sent.\n") ply:PrintMessage(HUD_PRINTTALK, "STOP SPAMMING THE SERVER!") return "" end ply:EnableChatting(false) timer.Simple(AntiSpam.Settings.Chat.Delay, AntiSpam.Chat.ResetTimer, ply) end else return '' -- <- You return '' when the antispam is disabled, thus disabling the chat end end [/lua] try just removing that else and see if it works.
[QUOTE=GGG KILLER;49417181]no, that still won't solve the problem. The problem is here: [lua] function AntiSpam.Chat.Chatting( ply, text ) if AntiSpam.Settings.Chat.Enabled then if AntiSpam.Settings.AntiSpamming then if !ply:CanChat() then ply:PrintMessage(HUD_PRINTCONSOLE, "Message \""..text.."\" was not sent.\n") ply:PrintMessage(HUD_PRINTTALK, "STOP SPAMMING THE SERVER!") return "" end ply:EnableChatting(false) timer.Simple(AntiSpam.Settings.Chat.Delay, AntiSpam.Chat.ResetTimer, ply) end else return '' -- <- You return '' when the antispam is disabled, thus disabling the chat end end [/lua] try just removing that else and see if it works.[/QUOTE] I'm going to try the following: [CODE]if AntiSpam.Settings.Chat.Enabled //Remove[/CODE] Then I changed was the function that handles whether or not the player can chat which is [CODE]function CanChat()[/CODE] The code below is how you stop the AntiSpam Script from muting the player when the chat portion is disabled [CODE] function meta:CanChat() if AntiSpam.Settings.Chat.Enabled == true then //Checks if AntiSpan.Chat is enabled return true //If it is not then let the player chat elseif table.HasValue(AntiSpam.Chat.Players, self:SteamID()) then //^Otherwise check the table for the ply's steamid return false //Stops the player from chatting if steamid is found else return true //Otherwise let the player chat end end [/CODE] UPDATE: I ended up having to use both of our solutions your's to see the chat when it was disabled & mine to disable the spam protection without disabling the ability to chat.
[QUOTE=MexicanR;49417236]I'm going to try the following: [CODE]if AntiSpam.Settings.Chat.Enabled //Remove[/CODE] Then I changed was the function that handles whether or not the player can chat which is [CODE]function CanChat()[/CODE] The code below is how you stop the AntiSpam Script from muting the player when the chat portion is disabled [CODE] function meta:CanChat() if AntiSpam.Settings.Chat.Enabled == true then //Checks if AntiSpan.Chat is enabled return true //If it is not then let the player chat elseif table.HasValue(AntiSpam.Chat.Players, self:SteamID()) then //^Otherwise check the table for the ply's steamid return false //Stops the player from chatting if steamid is found else return true //Otherwise let the player chat end end [/CODE] UPDATE: I ended up having to use both of our solutions your's to see the chat when it was disabled & mine to disable the spam protection without disabling the ability to chat.[/QUOTE] Change [lua] if AntiSpam.Settings.Chat.Enabled == true then //Checks if AntiSpan.Chat is enabled [/lua] to [lua] if not AntiSpam.Settings.Chat.Enabled then //Checks if AntiSpan.Chat is enabled [/lua]
[QUOTE=GGG KILLER;49417366]Change [lua] if AntiSpam.Settings.Chat.Enabled == true then //Checks if AntiSpan.Chat is enabled [/lua] to [lua] if not AntiSpam.Settings.Chat.Enabled then //Checks if AntiSpan.Chat is enabled [/lua][/QUOTE] Thanks, I fixed that.
Sorry, you need to Log In to post a reply to this thread.