DazzaJay Posted November 11, 2008 Share Posted November 11, 2008 (edited) Hello, this is a serverside script. function checkName() if getClientName ( source ) == "Player" then setClientName ( source, getPlayerUserName ( source ) ) end end addEventHandler ( "onPlayerJoin", getRootElement(), checkName ) and it used to work perfectley. But then DP2.3 was released and it ofcourse now dows not work. (Because DP2.3 no longer returns the correct username with getPlayerUserName it only returns DP2.3 for P2.3 users) What i am looking for is a Slightly more complex version of this script. Basically, what i want it to do, is kind of like the script that somone has that changes their names to "Noob**" But i dont want it limited to One name (noob) Basically, on join, if the player is named DP2.3 or Player. to then Select a Random name from a list of names. and change their name to that (with ofcourse some random numbers at the end) The main reason why i dont want to change people to just Noob** is because its too comon, i want to mix it up a bit. Here is the list of names i have so far... (yes, its for use in my Race server, can you tell) Burnout_KingDrag_Master Speed_Freak Infernus_Drifter Turbocharged Supercharged Fat_Tyres Crap_Suspension Gearbox Clutch_Plate So basically, in the end it would act like this: * Player joined the server.* Player is now known as Speed_Freak71 * DP2.3 Joined the Server. * DP2.3 is now known as Fat_Tyres69 * DP2.3 Joined the Server. * DP2.3 is now known as Infernus_Drifter82 * Player joined the server. * Player is now known as Burnout_King65 As having a list of names like this wouldbe better than just "noob**" ever been in a server, with everyone named Noob** i have, its kind of irritating. at the moment, Our server just kicks people with Player or DP2.3 or Noob** with the message "Change your name before returning" and i want to remove the kicker, which is why i want this Complex renamer. The Most Accurate Real Car Names List & Mod Ever. No Bullcrap. <-- Updated 20-January-2008! The Most Awesome MTA Clan and Servers Ever! No Bullcrap! <-- We Are Recruting New Members! [PS] Clan signups are open to the public! Click Here to join! Edited November 11, 2008 by Guest Link to comment
Mr.Hankey Posted November 11, 2008 Share Posted November 11, 2008 This might work: names = { "Burnout_King", "Drag_Master", "Speed_Freak", "Infernus_Drifter", "Turbocharged", "Supercharged", "Fat_Tyres", "Crap_Suspension", "Gearbox", "Clutch_Plate" } function checkName() if getClientName ( source ) == "Player" or getClientName (source) == "DP2.3" then setClientName ( source, names[math.random (1, #names)]) end end addEventHandler ( "onPlayerJoin", getRootElement(), checkName ) Link to comment
DazzaJay Posted November 11, 2008 Author Share Posted November 11, 2008 (edited) Thanks, iil test, and report here if it has any issues. ___________ The Most Accurate Real Car Names List & Mod Ever. No Bullcrap. <-- Updated 20-January-2008! The Most Awesome MTA Clan and Servers Ever! No Bullcrap! <-- We Are Recruting New Members! [PS] Clan signups are open to the public! Click Here to join! Edited November 11, 2008 by Guest Link to comment
DazzaJay Posted November 11, 2008 Author Share Posted November 11, 2008 (edited) Works perfectly, altho its not adding 2 random numbers after the name that its changing to. I looked into it, but theres no wiki page on math.random. so i have no idea on how it even works. http://development.mtasa.com/index.php? ... ndom&go=Go Im guessing its not as simple as changing setClientName ( source, names[math.random (1, #names)]) to setClientName ( source, names[math.random (1, #names)]math.random(1,99)) ___________ The Most Accurate Real Car Names List & Mod Ever. No Bullcrap. <-- Updated 20-January-2008! The Most Awesome MTA Clan and Servers Ever! No Bullcrap! <-- We Are Recruting New Members! [PS] Clan signups are open to the public! Click Here to join! Edited November 11, 2008 by Guest Link to comment
XetaQuake Posted November 11, 2008 Share Posted November 11, 2008 Its easy: math.random(1, 99) Should output a random number between 1 and 99 Link to comment
DazzaJay Posted November 11, 2008 Author Share Posted November 11, 2008 You mean changing This: setClientName ( source, names[math.random (1, #names)]) to setClientName ( source, names[math.random (1, #names)]math.random(1, 99)) ? ___________ The Most Accurate Real Car Names List & Mod Ever. No Bullcrap. <-- Updated 20-January-2008! The Most Awesome MTA Clan and Servers Ever! No Bullcrap! <-- We Are Recruting New Members! [PS] Clan signups are open to the public! Click Here to join! Link to comment
Gamesnert Posted November 11, 2008 Share Posted November 11, 2008 More like: setClientName ( source, names[math.random (1, #names)]..math.random(1, 99)) --Note the ".." More bout that over here: Programming in Lua: 3.4(only a small page ) Link to comment
Mr.Hankey Posted November 11, 2008 Share Posted November 11, 2008 names = { "Burnout_King", "Drag_Master", "Speed_Freak", "Infernus_Drifter", "Turbocharged", "Supercharged", "Fat_Tyres", "Crap_Suspension", "Gearbox", "Clutch_Plate" } function checkName() if getClientName ( source ) == "Player" or getClientName (source) == "DP2.3" then setClientName ( source, names[math.random (1, #names)]..tostring(math.random(1,99))) end end addEventHandler ( "onPlayerJoin", getRootElement(), checkName ) first you need to convert the number you got from the math.random function (btw thats a standart lua function so it's not on the wiki) to a string and then connect the name string with the random number using two points. E.g.: if local a = "blah".."blubb" then a would be "blahblubb" Link to comment
eXo|Flobu Posted November 11, 2008 Share Posted November 11, 2008 (edited) Works perfectly, altho its not adding 2 random numbers after the name that its changing to. but if you really want two numbers you must use math.random(1,9)..math.random(0,9) instead of math.random(1,99) Edited November 11, 2008 by Guest Link to comment
DazzaJay Posted November 11, 2008 Author Share Posted November 11, 2008 Thanks Guys, will post back here if i have any issues, but im pretty sure it wont Link to comment
XetaQuake Posted November 11, 2008 Share Posted November 11, 2008 but if you really want two numbers you must use math.random(1,9)..math.random(0,9) Or just math.random(10,99) thats the same... ^^ Only your example is more flexible possible Link to comment
DazzaJay Posted November 11, 2008 Author Share Posted November 11, 2008 but if you really want two numbers you must use math.random(1,9)..math.random(0,9) Or just math.random(10,99) thats the same... ^^ Only your example is more flexible possible Tried all the options i was given here, and Mr hankeys was the one that worked. ..tostring(math.random(1,99)) as he said, it needed the ..tostring names = { "Burnout_King", "Drag_Master", "Speed_Freak", "Infernus_Drifter", "Turbocharged", "Supercharged", "Fat_Tyres", "Crap_Suspension", "Gearbox", "Clutch_Plate" } function checkName() if getClientName ( source ) == "Player" or getClientName (source) == "DP2.3" then setClientName ( source, names[math.random (1, #names)]..tostring(math.random(1,99))) end end addEventHandler ( "onPlayerJoin", getRootElement(), checkName ) Works perfectly, Thanks MrHankey. theres nothing left to do on this. Link to comment
TimJ Posted November 23, 2008 Share Posted November 23, 2008 By the way, i was wanting to make a script like this a while ago for my server so if someone on my server was wearing my clans tag that wasnt in the clan, i could change there name but because im a noob at scripting i failed miserably, i found out about a command which anyone on your server with admin powers can use that makes a player do a command, just type in the console: axec so for example to change a name you could do: aexec n00b87 nick chaos_drift sorry if this is no use at all, Tim Link to comment
arc_ Posted November 27, 2008 Share Posted November 27, 2008 I looked into it, but theres no wiki page on math.random. so i have no idea on how it even works. The math library is a part of Lua - it is not MTA specific, which is why it's not on the MTA wiki. You can find the math.random documentation in the Lua manual. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now