justn Posted August 19, 2014 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 Datastore - Store data to a database quickly. (Useful for saving scripted tables)
xXMADEXx Posted August 19, 2014 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) The Ultimate Lua Tutorial! | MTA PHP SDK
justn Posted August 19, 2014 Author Posted August 19, 2014 Still not working.. Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Max+ Posted August 19, 2014 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 - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
justn Posted August 19, 2014 Author 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 ? Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Max+ Posted August 19, 2014 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 . - New , Kill System - New, GameMode Intro - Leve / Exp System - New nametag showing style - New , Hud For Players - Skin Selection from SA-MP - Money System / Buy Weapons - Drop Weapons - New, Flood System - New , Group Assign - Gun license For Weapons - Random Rule System For Money
justn Posted August 19, 2014 Author 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 Datastore - Store data to a database quickly. (Useful for saving scripted tables)
undefined Posted August 19, 2014 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)
justn Posted August 19, 2014 Author Posted August 19, 2014 Still doesn't work :c Datastore - Store data to a database quickly. (Useful for saving scripted tables)
justn Posted August 19, 2014 Author Posted August 19, 2014 Any help ? Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Et-win Posted August 19, 2014 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 ) ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
justn Posted August 19, 2014 Author Posted August 19, 2014 That wouldn't fix anything .. ^^ Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Et-win Posted August 19, 2014 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? ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Sasu Posted August 20, 2014 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. State: Inactive
justn Posted August 20, 2014 Author 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? Datastore - Store data to a database quickly. (Useful for saving scripted tables)
justn Posted August 20, 2014 Author Posted August 20, 2014 Any help ? :I Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Et-win Posted August 20, 2014 Posted August 20, 2014 https://wiki.multitheftauto.com/wiki/Se ... ame#Limits ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
justn Posted August 20, 2014 Author 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 Datastore - Store data to a database quickly. (Useful for saving scripted tables)
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