Jump to content

setAccountData problem


Miika

Recommended Posts

My "SaveNameColor" script not working. it does not save color.

[server]

function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
            local r, g, b = getPlayerNametagColor ( source ) 
            setAccountData ( playeraccount, "name.color", r, g, b ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      if ( playeraccount ) then 
            local namecolor = getAccountData ( playeraccount, "name.color" ) 
            if ( namecolor ) then 
                  setPlayerNametagColor ( source, namecolor ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 

Link to comment
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
            local r, g, b = getPlayerNametagColor ( source ) 
            setAccountData ( playeraccount, "name.color", tostring(r)..","..tostring(g)..","..tostring(b) ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
      if ( playeraccount ) then 
            local namecolor = getAccountData ( playeraccount, "name.color" ) 
            if ( namecolor ) then 
                  local s = split(namecolor, ",") 
                  setPlayerNametagColor ( source, s[1], s[2], s[3] ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...