• Search TXT file for steam ID
    5 replies, posted
Ok, so I'm making a basic whitelist for my server and so far I have the following code. [lua] local id = file.Read( "jobs/whitelist/cpn_whitelist.txt" ) if id ~= nil then local whitelist = string.find( id, ply:SteamID() ) if (whitelist > 0) then ply:SetTeam( 2 ) else ply:PrintMessage( HUD_PRINTTALK, "You, cannot use this class" ) end else ply:PrintMessage( HUD_PRINTTALK, "You, cannot use this class" ) end [/lua] My txt file looks like this: [quote] STEAM_0:0:11817524 [/quote] It is not reading it though, any help would be appreciated! Thank you!
-= should be either ~= or != Also, don't use text saving, use tables and mysql. So save all id's with ; between then explode them to produce a localised table of steamids.
[QUOTE=Science;31105045]-= should be either ~= or != Also, don't use text saving, use tables and mysql. So save all id's with ; between then explode them to produce a localised table of steamids.[/QUOTE] I am using ~= I also do not want to use mysql. XD
Sorry, the phone draws the tidle shit. Use pdata and glon or localsql
Well for one make sure your files are in the right place [b][url=http://wiki.garrysmod.com/?title=File.Read]file.Read [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] is relative to your "garrysmod/data" folder
[lua] local whitelists = file.Read( "jobs/whitelist/cpn_whitelist.txt" ) for _, sid in pairs(string.Explode("\n", whitelists)) do if ply:SteamID() == sid then ply:SetTeam(2) else ply:ChatPrint("You cannot use this class") end end [/lua]
Sorry, you need to Log In to post a reply to this thread.