• Defualt Rpname
    37 replies, posted
I Was wondaring 3 things; 1. How could i make a system were when a player joins it gets a name from a list and at random sets that as there rpname untill they change it. 2. Were would i put this file. 3. What files would i need Cl_init ect? Thanks in advance
Player:SetRPName( String name, Boolean firstRun ) If that^ still exists you could do: [code] local names = { "Betty", "Sneaky", "Snake", "Rat" } local function setname( ply ) timer.Simple( 2, function() if ( IsValid( ply ) ) then ply:SetRPName( table.Random( names ), false ) end end ) end hook.Add( "PlayerInitialSpawn", "asdasdas", setname ) [/code] server sided
[QUOTE=Invule;48028922]Player:SetRPName( String name, Boolean firstRun ) If that^ still exists you could do: [code] local names = { "Betty", "Sneaky", "Snake", "Rat" } local function setname( ply ) timer.Simple( 2, function() if ( IsValid( ply ) ) then ply:SetRPName( table.Random( names ) ) end end ) end hook.Add( "PlayerInitialSpawn", "asdasdas", setname ) [/code] server sided[/QUOTE] I don't get these 'dumb' ratings, but he is right. You can add: [code]if CLIENT then return end[/code] On the top of it and then save it as anything.lua and drop it to lua/autorun.
So I would list the names were it says "rat" ect and then save it to the autorun file and run it, and see if it works. Thanks, that was really helpful and I learnt some new stuff, I appreciate it. [editline]23rd June 2015[/editline] But what is the 'asdasdas' meant to represent?
[QUOTE=Netheous;48032440]I don't get these 'dumb' ratings, but he is right. You can add: [code]if CLIENT then return end[/code] On the top of it and then save it as anything.lua and drop it to lua/autorun.[/QUOTE] It's dumb because they get a random rpname [u]everytime[/u] they join.
[QUOTE=Kevlon;48036490]It's dumb because they get a random rpname [u]everytime[/u] they join.[/QUOTE] Yeah, but isn't that what he wanted? If so, it just needs a simple IF check.
[QUOTE=Borris_Squad;48036242]But what is the 'asdasdas' meant to represent?[/QUOTE] It's just a unique name, you can replace it with whatever you want.
[QUOTE=Netheous;48036869]Yeah, but isn't that what he wanted? If so, it just needs a simple IF check.[/QUOTE] I know sort of know what the IF Staement would look like but, I do not know how it would check if they have an RP and its valid.
I am not sure because I never fetched for darkrp name, but I think you could check if ply.DarkRPVars is the same as name (the one you set on steam).
[QUOTE=Netheous;48039716]I am not sure because I never fetched for darkrp name, but I think you could check if ply.DarkRPVars is the same as name (the one you set on steam).[/QUOTE] Im pretty sure darkrp overrides ply:Nick(), so use that.
[QUOTE=Exploderguy;48040343]Im pretty sure darkrp overrides ply:Nick(), so use that.[/QUOTE] Yeah, but there's also ply:Name(), does it override it aswell?
[QUOTE=Netheous;48032440]I don't get these 'dumb' ratings, but he is right. You can add: [code]if CLIENT then return end[/code] On the top of it and then save it as anything.lua and drop it to lua/autorun.[/QUOTE] Why not shove it in autorun/server? ....
[QUOTE=Netheous;48041059]Yeah, but there's also ply:Name(), does it override it aswell?[/QUOTE] Yes, if you want the Steam name then use ply:SteamName().
[QUOTE=xaviergmail;48047150]Why not shove it in autorun/server? ....[/QUOTE] It's a matter of preference. Yes, in autorun the file get's sent to client even when not executed but who cares at this point, it's a tiny file :v:
[QUOTE=Netheous;48047943]It's a matter of preference. Yes, in autorun the file get's sent to client even when not executed but who cares at this point, it's a tiny file :v:[/QUOTE] Captain Efficiency cares you sorry son of a bitch
Also, I have problem I set it up with out the if function and it simply does not set my name, even when I rejoin it gets set to my steam name.
[QUOTE=DrJenkins;48047953]Captain Efficiency cares you sorry son of a bitch[/QUOTE] Efficiency? The code isn't even executed because of "if CLIENT then". It's probably 0.00000001s less efficient because of that mr. Acecool.
It's not SetRPName, it's setRPName [img]https://dl.dropboxusercontent.com/u/79424230/ShareX/2015/June/25_June_2015_ShareX_264.png[/img]
[QUOTE=Borris_Squad;48048248]Also, I have problem I set it up with out the if function and it simply does not set my name, even when I rejoin it gets set to my steam name.[/QUOTE] Show the code, we can't magically come up with the solution out of our buttocks without seeing it.
[QUOTE=Netheous;48048338]Efficiency? The code isn't even executed because of "if CLIENT then". It's probably 0.00000001s less efficient because of that mr. Acecool.[/QUOTE] It may not be executed, but it doesn't stop someone from stealing it for their own server, or potentially seeing unsecured net messages and the like. Shared is purely for things that MUST be shared, such as specific functionality, or tables. The rest should be split into their respective states properly.
[QUOTE=Phoenixf129;48048359]It may not be executed, but it doesn't stop someone from stealing it for their own server, or potentially seeing unsecured net messages and the like. Shared is purely for things that MUST be shared, such as specific functionality, or tables. The rest should be split into their respective states properly.[/QUOTE] It's one function.. 10 lines of code, who would bother stealing it?
[code] local names = { "Oliver Hemmingsworth", "Jake Garnell", "David Jackson", "Jacky Wanky", "James White", "Brenda Andersson", "Sam Davidsson", "Richard", "Smith Kim", "Jacobs"} local function setname( ply ) timer.Simple( 2, function() if ( IsValid( ply ) ) then ply:setRPName( table.Random( names ) ) end end ) end hook.Add( "PlayerInitialSpawn", "asdasdas", setname ) [/code] Have not tried it sence i change the setRPName fucntion, i also put it in the autorun/server file. I will get back when i have tested it. [editline]25th June 2015[/editline] [code] if CLIENT then return end local names = { "Oliver Hemmingsworth", "Jake Garnell", "David Jackson", "Jacky Wanky", "James White", "Brenda Andersson", "Sam Davidsson", "Richard", "Smith Kim", "Jacobs Moore"} local function setname( ply ) timer.Simple( 2, function() if ( IsValid( ply ) ) then ply:setRPName( table.Random( names ) ) end end ) end hook.Add( "PlayerInitialSpawn", "asdasdas", setname ) [/code] This does not work, wont even change my name on spawn.
[code] local names = { "Oliver Hemmingsworth", "Jake Garnell", "David Jackson", "Jacky Wanky", "James White", "Brenda Andersson", "Sam Davidsson", "Richard", "Smith Kim", "Jacobs Moore" } hook.Add( "PlayerInitialSpawn", "changeNameOnSpawn", function( ply ) timer.Simple( 5, function() local name = table.Random( names ) ply:setRPName( name ) end ) end ) [/code] Works for me on my test server
[QUOTE=Adzter;48049352][code] local names = { "Oliver Hemmingsworth", "Jake Garnell", "David Jackson", "Jacky Wanky", "James White", "Brenda Andersson", "Sam Davidsson", "Richard", "Smith Kim", "Jacobs Moore" } hook.Add( "PlayerInitialSpawn", "changeNameOnSpawn", function( ply ) timer.Simple( 5, function() local name = table.Random( names ) ply:setRPName( name ) end ) end ) [/code] Works for me on my test server[/QUOTE] You put that in autorun file or autorun/server?
[QUOTE=Borris_Squad;48050302]You put that in autorun file or autorun/server?[/QUOTE] Put it inside anything.lua and place that inside autorun/server. The whole script is serverside so there's really no place for it in the autorun folder which is for shared files.
[QUOTE=Adzter;48050350]Put it inside anything.lua and place that inside autorun/server. The whole script is serverside so there's really no place for it in the autorun folder which is for shared files.[/QUOTE] Do you knwo how to make the IF Statement that makes it so that it will check if they have a steam name or not?
[QUOTE=Borris_Squad;48050519]Do you knwo how to make the IF Statement that makes it so that it will check if they have a steam name or not?[/QUOTE] Do you mean check to see if their Steam name is a correct RP name? For example "Firstname Lastname" rather than "xxQuickScopeKillaxx"
[QUOTE=Adzter;48050533]Do you mean check to see if their Steam name is a correct RP name? For example "Firstname Lastname" rather than "xxQuickScopeKillaxx"[/QUOTE] Yea, and if it is xxQuickScopeKillaxx then it changes it. :D
[QUOTE=Borris_Squad;48050602]Yea, and if it is xxQuickScopeKillaxx then it changes it. :D[/QUOTE] I'm assuming you'd only want the basic alphabet for people's first and last names. So you'd have to use some form of pattern checking. This should be a good start for you: [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index14ae.html[/url] You're wanting to look at: [quote] %a : represents all letters( from a to z upper and lower case ), [/quote] Note: This won't take into account any special characters, such as á é í, hyphenated names and names that have Jr. Those are all just off the top of my head, there's probably more.
[QUOTE=Adzter;48050736]I'm assuming you'd only want the basic alphabet for people's first and last names. So you'd have to use some form of pattern checking. This should be a good start for you: [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index14ae.html[/url] You're wanting to look at:[/QUOTE] Any were to show me how the IF Function Should be layed out? as when i tried doing it, it symply does not work.
Sorry, you need to Log In to post a reply to this thread.