Jump to content

getAccountData ..


HoLsTeN

Recommended Posts

hi all

function getPlayerStats ( source, command, who ) 
    local targetPlayer = getPlayerFromName ( who )  
    if ( targetPlayer ) then    -- if find 
        local playeraccount = getPlayerAccount(targetPlayer)     
        local who_exp = getAccountData(playeraccount,"exp") 
        local who_lvl = getAccountData(playeraccount,"level") 
        local who_rank = getAccountData(playeraccount,"rank") 
        outputChatBox (getPlayerName(source) .." #0000FF Ask #FFFF00For  #FFFFFF".. getPlayerName(targetPlayer) .."  #0000FFStats : ",getRootElement(),255,255,255,true) 
        outputChatBox (getPlayerName(targetPlayer) .."  #0000FFHis EXP : #FFFF00".. who_exp .." #0000FF! ",getRootElement(),255,255,0,true) 
        outputChatBox (getPlayerName(targetPlayer) .."  #0000FFHis LEVEL :#FFFF00 ".. who_lvl .." #0000FF! ",getRootElement(),255,255,0,true) 
        outputChatBox (getPlayerName(targetPlayer) .."  #0000FFHis RANK NAME : #FFFF00".. who_rank .." #0000FF! ",getRootElement(),255,255,0,true) 
        else -- if he is not in the server 
        outputChatBox("No Player With This Name",source,255,0,0) 
    end 
end 
addCommandHandler ( "stats", getPlayerStats ) 

the code just show me my EXP but the others outputChatBox Not ShoW :roll:

Link to comment

probably some account data is not set:

  
        local who_exp = getAccountData(playeraccount,"exp") or "0" 
        local who_lvl = getAccountData(playeraccount,"level") or "0" 
        local who_rank = getAccountData(playeraccount,"rank") or "None" 
  

Link to comment
function getPlayerStats ( source, command, who ) 
    local targetPlayer = getPlayerFromName ( who )  
    if ( targetPlayer ) then 
        local playeraccount = getPlayerAccount(targetPlayer) 
        if ( playeraccount ) and not ( isGuestAccount ( playeraccount ) ) then   
            local who_exp = getAccountData(playeraccount,"exp") 
            local who_lvl = getAccountData(playeraccount,"level") 
            local who_rank = getAccountData(playeraccount,"rank") 
            if not ( who_exp ) then 
                who_exp = "0" 
            end 
            if not ( who_lvl ) then 
                who_lvl = "0" 
            end 
            if not ( who_rank ) then 
                who_rank = "0" 
            end 
            outputChatBox (getPlayerName(source) .." #0000FF Ask #FFFF00For  #FFFFFF".. getPlayerName(targetPlayer) .."  #0000FFStats : ",getRootElement(),255,255,255,true) 
            outputChatBox (getPlayerName(targetPlayer) .."  #0000FFHis EXP : #FFFF00".. who_exp .." #0000FF! ",getRootElement(),255,255,0,true) 
            outputChatBox (getPlayerName(targetPlayer) .."  #0000FFHis LEVEL :#FFFF00 ".. who_lvl .." #0000FF! ",getRootElement(),255,255,0,true) 
            outputChatBox (getPlayerName(targetPlayer) .."  #0000FFHis RANK NAME : #FFFF00".. who_rank .." #0000FF! ",getRootElement(),255,255,0,true) 
        else 
            outputChatBox(who.." doesn't have an account.",source,255,0,0)   
        end 
    else 
        outputChatBox("No Player With This Name",source,255,0,0) 
    end 
end 
addCommandHandler ( "stats", getPlayerStats ) 

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