deleting a string from a file?

I attempted to do it with string.Replace, but it didn’t seem to work.

Here is the code:

string.Replace( ply:SteamID(), ply:SteamID(), "" )

Is there a different way to do this?


What you’re doing is looking for the SteamID in the SteamID and replacing it.

Look at the arguments and example.


What format does your file have? JSON? KeyValues? Custom?

string.Replace( ply:SteamID(), ply:SteamID(), "" )

I have absolutely no idea what this is even supposed to be, you are replacing ply:SteamID() in ply:SteamID() with “”?

What exactly are you trying to do? Hide/Remove a players Steam ID?

I currently have a fileban system using cookies. What I’m attempting to do is create a system that will remove the cookie if they are on a certain list, and what I need to remove the string for is so they can be re-filebanned without me having to physically remove the steam id from the file.

Sorry, i was kind of unclear in the OP about what I’m attempting to do.

[editline]31st October 2015[/editline]

Alright, i tried this:

local str = file.Read("tobiasx_unbans.txt", "DATA");
string.Replace(str, ply:SteamID(), "")

but it still isn’t working.

[lua]str = string.Replace(str, ply:SteamID(), “”)[/lua]

Wouldn’t you need to do

local str = file.Read( "tobiasx_unbans.txt", "DATA" )
str = string.Replace( str, ply:SteamID(), "" )
file.Write( "tobiasx_unbans.txt", str )

string.replace() is deprecated.
Use string.gsub()

Yup, that worked!

Thank you!