• string_gsub
    2 replies, posted
I'm getting an error when I call a function saying "Bad argument #1 to string_gsub (string expected, got nil)" I don't understand what that means, help? [lua] function CheckTempBans( ply ) local id = string.Replace( ply:SteamID(), ":", "!" ) local filename = id .. ".txt" local bans = file.Find( "tempbans/" .. filename ) if #bans >= 1 then local data = file.Read( "tempbans/" .. filename ) local data = string.Explode( data, "/" ) local ostime = string.Explode( data[3], ":" ) local ostime = tonumber( ostime[2] ) print( os.time() .. "\t" .. ostime ) if os.time() >= ostime then PardonPlayer( ply ) file.Delete( "tempbans/" .. id .. ".txt" ) else local length = string.Explode( data[2], ":" ) local ostime = string.Explode( data[3], ":" ) local reason = string.Explode( data[4], ":" ) local admin = string.Explode( data[5], ":" ) local server = string.Explode( data[6], ":" ) local length = tonumber( length[2] ) local ostime = tonumber( ostime[2] ) local left = ostime - os.time() KickPlayer( ply, server[2], length, left, reason[2], admin[2] ) end end end [/lua]
Check everything you pass to string.Explode.
Thanks.. I just realized I have the 2 arguments in the wrong places... Derp.
Sorry, you need to Log In to post a reply to this thread.