SinaAmp Posted March 3, 2021 Share Posted March 3, 2021 hello guys i need to show player account name instaead nikname in server or if you can show me a example script that can save player nickname and after login set player nickname to saved nikname i found this code but this can't change player nickname to account name after login 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) Link to comment
nikitafloy Posted March 3, 2021 Share Posted March 3, 2021 (edited) Set account name instead nickname: addEventHandler('onPlayerLogin', root, function(_,account) setPlayerName(source, getAccountName(account)) end) Save account name on first server login and loading: addEventHandler('onPlayerLogin', root, function(_,account) local accName = getAccountData(account, 'savedName') if not accName then accName = getAccountName(account) setAccountData(account, 'savedName', accName) end setPlayerName(source, accName) end) Edited March 3, 2021 by nikitafloy 1 Link to comment
Scripting Moderators xLive Posted March 3, 2021 Scripting Moderators Share Posted March 3, 2021 12 minutes ago, nikitafloy said: Save account name on first server login and loading: addEventHandler('onPlayerLogin', root, function(_,account) local accName = getAccountData(account, 'savedName') if not accName then accName = getAccountName(account) setAccountData(account, 'savedName', accName) end setPlayerName(source, accName) end) Can you please explain this? why are you saving the account name? you can always use getAccountName? Link to comment
nikitafloy Posted March 3, 2021 Share Posted March 3, 2021 1 hour ago, xLive said: Can you please explain this? why are you saving the account name? you can always use getAccountName? "i need ... player account name instaead nikname ... example script that can save player nickname and after login set player nickname to saved nikname" @sinakh want that If he want to save nickname (player), not nickname (which was account name and was saved in accountData): addEventHandler('onPlayerLogin', root, function(_,account) local name = getAccountData(account, 'savedName') if not name then name = getPlayerName(source) setAccountData(account, 'savedName', name) end setPlayerName(source, name) end) 1 Link to comment
Scripting Moderators xLive Posted March 3, 2021 Scripting Moderators Share Posted March 3, 2021 (edited) 48 minutes ago, nikitafloy said: "i need ... player account name instaead nikname ... example script that can save player nickname and after login set player nickname to saved nikname" @sinakh want that If he want to save nickname (player), not nickname (which was account name and was saved in accountData): addEventHandler('onPlayerLogin', root, function(_,account) local name = getAccountData(account, 'savedName') if not name then name = getPlayerName(source) setAccountData(account, 'savedName', name) end setPlayerName(source, name) end) Oh sorry! i thought you saving the account name not the player name. Edited March 3, 2021 by xLive 1 Link to comment
SinaAmp Posted March 4, 2021 Author Share Posted March 4, 2021 (edited) thank you so much bro that worked do you know how i can prevent random name after player join and login ? i mean my login panel get username and pasword for login and register but how it can get nick name from player and prevent random nickname? i dont know usually rp servers how they get nickname and which default script make onjoin random nick name Edited March 4, 2021 by sinakh Link to comment
nikitafloy Posted March 5, 2021 Share Posted March 5, 2021 (edited) @sinakh i dont know ur mta mod U need to find script which use 'setPlayerName' function and remove this Example: setPlayerName(player, 'nickname' .. math.random(99999)) Edited March 5, 2021 by nikitafloy 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