Tokio Posted December 3, 2017 Share Posted December 3, 2017 This is the code: function onPlayerQuit ( thePlayer) local playeraccount = getPlayerAccount ( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local nametagszin = getPlayerNametagColor ( thePlayer ) setAccountData ( playeraccount, "ntszin", nametagszin ) end end end function onPlayerLogin (_, playeraccount ) local playeraccount = getPlayerAccount ( thePlayer ) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then if ( playeraccount ) then local nametagszin = getAccountData ( playeraccount, "ntszin" ) if ( nametagszin ) then setPlayerNametagColor ( thePlayer, r, g, b ) end end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) No error(s)/warning(s) in debugscript 3.. What wrong? Link to comment
Bonus Posted December 3, 2017 Share Posted December 3, 2017 I think one of the if-statements is false. Just put an outputDebugString/outputChatBox in every line, counting up. That way you can see where the script stops. Link to comment
DNL291 Posted December 3, 2017 Share Posted December 3, 2017 Use source instead of thePlayer. Also, getPlayerNametagColor returns 3 values (r, g, b), so you can't save the data this way. 1 Link to comment
Tokio Posted December 3, 2017 Author Share Posted December 3, 2017 12 minutes ago, DNL291 said: Use source instead of thePlayer. Also, getPlayerNametagColor returns 3 values (r, g, b), so you can't save the data this way. then how to save? Link to comment
iMr.WiFi..! Posted December 3, 2017 Share Posted December 3, 2017 3 minutes ago, 50cent said: then how to save? function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) local accName = getAccountName ( playeraccount ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then local r,g,b = getPlayerNametagColor ( source ) setAccountData ( playeraccount, "ntszin", r..","..g..","..b ) end end end function onPlayerLogin (_, playeraccount ) local accName = getAccountName ( playeraccount ) if ( playeraccount ) then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then local nametagszin = getAccountData ( playeraccount, "ntszin" ) if ( nametagszin ) then local r, g, b = unpack( split( nametagszin, "," ) ) setPlayerNametagColor ( source, r, g, b ) end end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 1 Link to comment
DNL291 Posted December 3, 2017 Share Posted December 3, 2017 (edited) You can also save this way: -- saving local r,g,b = getPlayerNametagColor( source ) setAccountData( playeraccount, "ntszin", toJSON({ r,g,b }) ) -- getting local nametagC = getAccountData( playeraccount, "ntszin" ) if nametagC then local r,g,b = unpack(fromJSON( nametagC )) end Also, you can remove the first if-statement in the "onPlayerLogin" event since the account parameter will always be returned. Edited December 3, 2017 by DNL291 1 Link to comment
Tokio Posted December 3, 2017 Author Share Posted December 3, 2017 16 minutes ago, iMr.WiFi..! said: function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) local accName = getAccountName ( playeraccount ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then local r,g,b = getPlayerNametagColor ( source ) setAccountData ( playeraccount, "ntszin", r..","..g..","..b ) end end end function onPlayerLogin (_, playeraccount ) local accName = getAccountName ( playeraccount ) if ( playeraccount ) then if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then local nametagszin = getAccountData ( playeraccount, "ntszin" ) if ( nametagszin ) then local r, g, b = unpack( split( nametagszin, "," ) ) setPlayerNametagColor ( source, r, g, b ) end end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Thank you 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