• Defualt Rpname
    37 replies, posted
[QUOTE=Borris_Squad;48050761]Any were to show me how the IF Function Should be layed out? as when i tried doing it, it symply does not work.[/QUOTE] Post your code so far
[QUOTE=Adzter;48050798]Post your code so far[/QUOTE] I dont have it anymore i gave up, before you posted the working code
This is probably horibly wrong but, I'm giving it a shot [code] local names = { "Oliver Hemmingsworth", "Jake Garnell", "David Jackson", "Jacky Wanky", "James White", "Brenda Andersson", "Sam Davidsson", "Richard", "Smith Kim", "Jacobs Moore" } end if ply:Name() == ply:SteamName then hook.Add( "PlayerInitialSpawn", "changeNameOnSpawn", function( ply ) timer.Simple( 5, function() local name = table.Random( names ) ply:setRPName( name ) end ) end ) [/code] don't hate me :( [editline]25th June 2015[/editline] Then again, Even if that's right for some reason I need an else statement surly.
[code] local firstnames = { "Oliver", "Jake", "David", "Jacky", "James", "Brenda", "Sam", "Richard", "Smith", "Jacobs" } local lastnames = { "Hemmingsworth", "Garnell", "Jackson", "Wanky", "White", "Andersson", "Davidsson", "Moore" } hook.Add( "PlayerInitialSpawn", "changeNameOnSpawn", function( ply ) if(ply:SteamName():match("%W")) then --proper characters detected. local delay = 10 -- This is a delay in seconds. Gives time for the palyer to spawn in fully. timer.Simple( delay , function() local firstname = table.Random( firstnames ) -- Picks random first name from our table local lastname = table.Random( lastnames ) -- Picks random last name from our table ply:setRPName( firstname .. " " .. lastname ) -- Combines our new first and last name together! end ) end end ) [/code] Throw it in autorun/server/anythingyouwanttonamethis.lua The pattern I looked for only checks for numbers in the name and if one is found then it will change their RP name. You can change this pattern very easily by going to [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index14ae.html[/url] , like Adzter recommended.
So now, if you join and your name is Jack Jones it won't change but if it's Xx_1234pronoob1234_xX it will change it?
[QUOTE=Borris_Squad;48051960]So now, if you join and your name is Jack Jones it won't change but if it's Xx_1234pronoob1234_xX it will change it?[/QUOTE] Correct.
And how could I add more like %p just add a comma or?
Im sorry, my code was wrong it was checking for letters and numbers. Here is the updated code to your liking. [code] local firstnames = { "Oliver", "Jake", "David", "Jacky", "James", "Brenda", "Sam", "Richard", "Smith", "Jacobs" } local lastnames = { "Hemmingsworth", "Garnell", "Jackson", "Wanky", "White", "Andersson", "Davidsson", "Moore" } hook.Add( "PlayerInitialSpawn", "changeNameOnSpawn", function( ply ) if(ply:SteamName():match("%x%p")) then --improper characters detected. local delay = 10 -- This is a delay in seconds. Gives time for the palyer to spawn in fully. timer.Simple( delay , function() local firstname = table.Random( firstnames ) -- Picks random first name from our table local lastname = table.Random( lastnames ) -- Picks random last name from our table ply:setRPName( firstname .. " " .. lastname ) -- Combines our new first and last name together! end ) end end ) [/code]
Sorry, you need to Log In to post a reply to this thread.