Jump to content

Join As Guest , Nick Name


Recommended Posts

local tag = -1
addEventHandler('onPlayerJoin', root,
local tag = tag + 1
	function(oldNick, newNick)
	name = getPlayerName(source)
	setPlayerName ( source, "Guest_".. tag )
	end
)
addEventHandler('onPlayerLogin', root,
function ()
setPlayerName ( source, name )
end
)

any idea how to make this work , i want to change the player name into guest_*** if he or she hasnt logged in , and when logged in i want the name to be changed back to name they joined from

 

Link to comment
  • Moderators

Something like that.

-- SERVER SIDE SCRIPT

local counter = 0
local originalName = {}

addEventHandler('onPlayerJoin', root, function()
	local name = getPlayerName(source)
    originalName[source] = name
	setPlayerName(source, "Guest_"..counter)
    counter = counter + 1
end)

addEventHandler('onPlayerLogin', root, function()
    setPlayerName(source, originalName[source])
end)

On player join you need to save the player's original name to a table and you get back this name from the table, when the player is logged in.

  • Thanks 1
Link to comment
  • Moderators
3 minutes ago, TheGrimReaper said:

i did but it just stops the nick change dialog from showing nun else :(

 

The player can't change her name, but on the chat you got the info?

Edited by Patrick2562
Link to comment
1 hour ago, Patrick2562 said:

The player can't change her name, but on the chat you got the info?

Well on Chat it used to show when the play changed his name, But when i add the cancel event function , its just doesnt show on chat but the player can change his or her name :(

i used this 

 addEventHandler('onPlayerChangeNick', getRootElement(), function() cancelEvent() end ) 

Link to comment
  • Moderators

You have a default MTA resource in your resource folder, what name is: joinquit

In this script you can find a 'onClientPlayerChangeNick' event. You need to delete this event, because this function create the info to the chat.

(You still need to cancel this event somewhere.)

Link to comment

 

2 hours ago, Patrick2562 said:

You have a default MTA resource in your resource folder, what name is: joinquit

In this script you can find a 'onClientPlayerChangeNick' event. You need to delete this event, because this function create the info to the chat.

(You still need to cancel this event somewhere.)

thnx

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