I attempted to do it with string.Replace, but it didn't seem to work.
Here is the code:
[code]string.Replace( ply:SteamID(), ply:SteamID(), "" )[/code]
Is there a different way to do this?
thanks.
What you're doing is looking for the SteamID in the SteamID and replacing it.
Look at the arguments and example.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/Replace]string.Replace[/url]
What format does your file have? JSON? KeyValues? Custom?
[code]
string.Replace( ply:SteamID(), ply:SteamID(), "" )[/code]
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?
[QUOTE=Robotboy655;49024061]What format does your file have? JSON? KeyValues? Custom?
[code]
string.Replace( ply:SteamID(), ply:SteamID(), "" )[/code]
I have absolutely no idea what this is even supposed to be, you are replacing ply:SteamID() in ply:SteamID() with ""?[/QUOTE]
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:
[code]
local str = file.Read("tobiasx_unbans.txt", "DATA");
string.Replace(str, ply:SteamID(), "")
[/code]
but it still isn't working.
[QUOTE=Tobiasx;49024083]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:
[code]
local str = file.Read("tobiasx_unbans.txt", "DATA");
string.Replace(str, ply:SteamID(), "")
[/code]
but it still isn't working.[/QUOTE]
[lua]str = string.Replace(str, ply:SteamID(), "")[/lua]
Wouldn't you need to do
[CODE]
local str = file.Read( "tobiasx_unbans.txt", "DATA" )
str = string.Replace( str, ply:SteamID(), "" )
file.Write( "tobiasx_unbans.txt", str )
[/CODE]
string.replace() is deprecated.
Use string.gsub()
[QUOTE=MPan1;49025692]Wouldn't you need to do
[CODE]
local str = file.Read( "tobiasx_unbans.txt", "DATA" )
str = string.Replace( str, ply:SteamID(), "" )
file.Write( "tobiasx_unbans.txt", str )
[/CODE][/QUOTE]
Yup, that worked!
Thank you!
Sorry, you need to Log In to post a reply to this thread.