TheGrimReaper Posted June 15, 2018 Share Posted June 15, 2018 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 Patrick Posted June 15, 2018 Moderators Share Posted June 15, 2018 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. 1 Link to comment
TheGrimReaper Posted June 20, 2018 Author Share Posted June 20, 2018 @Patrick2562 is there a way that i can stop the guest from changing his nick?? Link to comment
Moderators Patrick Posted June 20, 2018 Moderators Share Posted June 20, 2018 5 minutes ago, TheGrimReaper said: @Patrick2562 is there a way that i can stop the guest from changing his nick?? You need to cancel this event:https://wiki.multitheftauto.com/wiki/OnPlayerChangeNick 1 Link to comment
TheGrimReaper Posted June 20, 2018 Author Share Posted June 20, 2018 i did but it just stops the nick change dialog from showing nun else Link to comment
Moderators Patrick Posted June 20, 2018 Moderators Share Posted June 20, 2018 (edited) 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 June 20, 2018 by Patrick2562 Link to comment
TheGrimReaper Posted June 20, 2018 Author Share Posted June 20, 2018 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 Patrick Posted June 20, 2018 Moderators Share Posted June 20, 2018 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
TheGrimReaper Posted June 20, 2018 Author Share Posted June 20, 2018 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
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