Jump to content

[Request] Player name Changer (Revision)


DazzaJay

Recommended Posts

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_King

Drag_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.

rotatorsig.php

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 by Guest
Link to comment

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

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)) 

___________

rotatorsig.php

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 by Guest
Link to comment

You mean changing This:

setClientName ( source, names[math.random (1, #names)]) 

to

setClientName ( source, names[math.random (1, #names)]math.random(1, 99)) 

?

___________

rotatorsig.php

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
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

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
  • 2 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...