1. Post #1
    InfernalCookie's Avatar
    December 2010
    700 Posts
    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?

    
    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
    

  2. Post #2
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    Check everything you pass to string.Explode.

  3. Post #3
    InfernalCookie's Avatar
    December 2010
    700 Posts
    Thanks.. I just realized I have the 2 arguments in the wrong places... Derp.