Jump to content

Save text from a row in scoreboard


Adde

Recommended Posts

Posted

Hello, how should I do if I want to save the text from scoreboardColumn "Class" onPlayerQuit and then set that text back in same scoreboardColumn onPlayerLogin? Is this near right?

function openClass() 
thePlayer = getPlayerAccount(source) 
if (thePlayer) then 
getAccountData(thePlayer, "theClass") 
setElementData(thePlayer, "theClass", Class) 
end 
end 
addEventHandler("onPlayerLogin",getRootElement(), openClass) 
  
function saveClass() 
thePlayer = getPlayerAccount(source) 
if (thePlayer) then 
local theClass = getElementData(source, "Class") 
setAccountData(thePlayer,"theClass", theClass) 
end 
end 
addEventHandler("onPlayerQuit",getRootElement(), saveClass) 

Thankfull for answears :)

My ingame nickname is: Mr.Snus

Posted
function openClass( _,acc ) 
    if not isGuestAccount( acc ) then 
        local class = getAccountData(thePlayer, "theClass") 
        if class then 
            setElementData( source, "theClass", class ) 
        end 
    end 
end 
addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) 
  
function saveClass( ) 
    local thePlayer = getPlayerAccount( source ) 
    if not isGuestAccount( thePlayer ) then 
        local theClass = getElementData( source, "Class" ) 
        setAccountData( thePlayer, "theClass", theClass ) 
    end 
end 
addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) 

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
function openClass() 
local thePlayer = getPlayerAccount(source) 
    if (thePlayer) then 
        local Class = getAccountData(thePlayer, "theClass") 
        setElementData(source, "theClass", Class) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(), openClass) 
  
function saveClass( ) 
if (isGuestAccount ( getPlayerAccount ( source ) ) ) then 
  
  else 
    local account = getPlayerAccount (source) 
    if (account) then 
        local theClass = getElementData(source, "Class") 
        setAccountData(thePlayer,"theClass", theClass) 
    end 
end 
addEventHandler("onPlayerQuit", root, saveClass) 

Giving a Fuck? Nope, That isn't in My Skill Set

castie11.png

Posted (edited)
function openClass( _,acc ) 
    if not isGuestAccount( acc ) then 
        local class = getAccountData(thePlayer, "theClass") 
        if class then 
            setElementData( source, "theClass", class ) 
        end 
    end 
end 
addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) 
  
function saveClass( ) 
    local thePlayer = getPlayerAccount( source ) 
    if not isGuestAccount( thePlayer ) then 
        local theClass = getElementData( source, "Class" ) 
        setAccountData( thePlayer, "theClass", theClass ) 
    end 
end 
addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) 

thePlayer O_o = acc There's no need to check guest account.

Edited by Guest

  

Posted

I had an error at line 3, Re-read the code thePlayer is the account .

Corrected code :

function openClass( _,acc ) 
    if not isGuestAccount( acc ) then 
        local class = getAccountData( acc, "theClass" ) 
        if class then 
            setElementData( source, "theClass", class ) 
        end 
    end 
end 
addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) 
  
function saveClass( ) 
    local acc = getPlayerAccount( source ) 
    if not isGuestAccount( acc ) then 
        local theClass = getElementData( source, "Class" ) 
        setAccountData( acc, "theClass", theClass ) 
    end 
end 
addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) 

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
I had an error at line 3, Re-read the code thePlayer is the account .

Corrected code :

function openClass( _,acc ) 
    if not isGuestAccount( acc ) then 
        local class = getAccountData( acc, "theClass" ) 
        if class then 
            setElementData( source, "theClass", class ) 
        end 
    end 
end 
addEventHandler( "onPlayerLogin", getRootElement( ), openClass ) 
  
function saveClass( ) 
    local acc = getPlayerAccount( source ) 
    if not isGuestAccount( acc ) then 
        local theClass = getElementData( source, "Class" ) 
        setAccountData( acc, "theClass", theClass ) 
    end 
end 
addEventHandler( "onPlayerQuit", getRootElement( ), saveClass ) 

It doesn´t work :/ The scoreboardColumn "Class" is still empty for me when I log on to the server after I left it with text in that column.

My ingame nickname is: Mr.Snus

Posted

I left MTA 4-5 month ago but i am planning to come back in 2-3 week's. But if i remember well you can't use Account Data with "onPlayerQuit" it will return NULL (it's to late when the function is called the player already left the server so you can't get his account). If i am wrong then somebody corect me how i told it was long time ago :D

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

@ bandi94 :

You can use it with onPlayerQuit ( as far as i know )

@Adde :

I don't see where you're adding the scoreboard column in that code, Post your full code .

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

  • 3 weeks later...
Posted
@ bandi94 :

You can use it with onPlayerQuit ( as far as i know )

@Adde :

I don't see where you're adding the scoreboard column in that code, Post your full code .

I have a whole spawn script with that column, and I add your suggestion into that script.

My ingame nickname is: Mr.Snus

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...