justn Posted August 19, 2014 Share Posted August 19, 2014 (edited) Hi there, I'm working on a supernick script... and I have a problem with it.. so the problem is.. when i leave the server.. with my supernick.. and i join and login again.. it doesn't set my supernick again.. code: CODE REMOVED SO PLAYERS CANNOT STEAL Edited August 21, 2014 by Guest Link to comment
xXMADEXx Posted August 19, 2014 Share Posted August 19, 2014 Try this: local setPlayerNewName = setPlayerName function getPlayerSuperNick( player ) local account = getPlayerAccount( player ) if ( account ) and ( not isGuestAccount( account ) ) then local accountSuperNick = getAccountData(account,"supernick") if ( accountSuperNick ) then local supernick = getElementData(player,"supernick") if ( supernick ) then setPlayerNewName(player,supernick) outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..getElementData(player,"supernick"),player,255,255,255,true) end end end end addEventHandler("onPlayerLogin",getRootElement(),function() getPlayerSuperNick ( source ) end ) function savePlayerSuperNick( player ) if ( player == source ) then local account = getPlayerAccount( player ) if ( account ) and ( not isGuestAccount( account ) ) then local supernick = getElementData(player,"supernick") if ( supernick ) then setAccountData(account,"supernick",supernick) end end end end addEventHandler("onPlayerQuit",getRootElement(),savePlayerSuperNick) Link to comment
Max+ Posted August 19, 2014 Share Posted August 19, 2014 (edited) addEventHandler('onPlayerLogin',resourceRoot, function ( player ) local account = getPlayerAccount (player ) if ( account ) and ( not isGuestAccount ( account )) then local SuperNick = getAccountData ( account, 'supernick' ) if ( SuperNick ) then setPlayerName ( player, SuperNick ) outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor.."", player, 255, 255, 255, true ) end end end ) addEventHandler('onPlayerQuit',resourceRoot, function ( player ) local account = getPlayerAccount (player ) if ( account ) and ( not isGuestAccount ( account )) then setAccountData ( account, 'supernick' ) end end ) Edited August 19, 2014 by Guest Link to comment
justn Posted August 19, 2014 Author Share Posted August 19, 2014 I know it's server-sided, there's only a server-side in the entire script and there's No errors and it still doesn't work.. should I just set the account data when the player sets his SuperNick ? Link to comment
Max+ Posted August 19, 2014 Share Posted August 19, 2014 I know it's server-sided, there's only a server-side in the entire script and there's No errors and it still doesn't work.. should I just set the account data when the player sets his SuperNick ? Yeah , i dont think you need to use accountData / elementdata both Select Only One of them , And i have Edited My Post , Copy it again . Link to comment
justn Posted August 19, 2014 Author Share Posted August 19, 2014 (edited) Ah here's my full code.. the only part which doesn't work is the saving part: CODE REMOVED SO PLAYERS CANNOT STEAL Edited August 21, 2014 by Guest Link to comment
undefined Posted August 19, 2014 Share Posted August 19, 2014 Try this. addEventHandler('onPlayerLogin',resourceRoot, function (_,account) local playerAccount = getPlayerAccount( source ) local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false if ( isAccount ) then local SuperNick = getAccountData ( account, 'supernick' ) if ( SuperNick ) then setPlayerName ( player, SuperNick ) outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..SuperNick, player, 255, 255, 255, true ) end end end) Link to comment
justn Posted August 19, 2014 Author Share Posted August 19, 2014 Still doesn't work :c Link to comment
Et-win Posted August 19, 2014 Share Posted August 19, 2014 outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..SuperNick, player, 255, 255, 255, true ) To: outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..""..SuperNick, player, 255, 255, 255, true ) Link to comment
justn Posted August 19, 2014 Author Share Posted August 19, 2014 That wouldn't fix anything .. ^^ Link to comment
Et-win Posted August 19, 2014 Share Posted August 19, 2014 That wouldn't fix anything .. ^^ Ow, sorry. Just tested it. I didn't knew you could do that too (stuff1..stuff2) And no debugscript 3 errors? Link to comment
Sasu Posted August 20, 2014 Share Posted August 20, 2014 local setPlayerNewName = setPlayerName function getPlayerSuperNick( ) local player = source local account = getPlayerAccount( player ) if ( account ) and ( not isGuestAccount( account ) ) then local accountSuperNick = getAccountData(account,"supernick") if ( accountSuperNick ) then local supernick = getElementData(player,"supernick") if ( supernick ) then setPlayerNewName(player,supernick) outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..getElementData(player,"supernick"),player,255,255,255,true) end end end end addEventHandler("onPlayerLogin",getRootElement(),getPlayerSuperNick) function savePlayerSuperNick( ) local player = source local account = getPlayerAccount( player ) if ( account ) and ( not isGuestAccount( account ) ) then local supernick = getElementData(player,"supernick") if ( supernick ) then setAccountData(account,"supernick",supernick) end end end addEventHandler("onPlayerQuit",getRootElement(),savePlayerSuperNick) The first variable that onPlayerLogin returns is the previous account so obviously it will never be the player and onPlayerQuit doesnt return variables. Link to comment
justn Posted August 20, 2014 Author Share Posted August 20, 2014 Too late Sasu I fixed the problem, but ty all. now I need help with 1 more thing.. i tried setting my supernick to this ♥ and my name did not change.. is there anyway, i can make those heart faces and stuff appear when i set my super-nick? Link to comment
Et-win Posted August 20, 2014 Share Posted August 20, 2014 https://wiki.multitheftauto.com/wiki/Se ... ame#Limits Link to comment
justn Posted August 20, 2014 Author Share Posted August 20, 2014 I saw a server.. where they would allow u to set hearts and stuff on ur name.. e.e This is what I'm trying to do with supernick.. EDIT: Nevermind, I have figured out how to close topic please. thanks 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