Jump to content

Scoreboard flag+namecountry


Dany Alex

Recommended Posts

no errors :|

server.lua

exports.rppscoreboard:addScoreboardColumn('Home') 
  
  
addEventHandler("onPlayerJoin", root, 
function() 
    local country = exports.admin:getPlayerCountry(source) 
    local flag = country and ":admin/client/images/flags/"..country..".png" 
    setElementData(source, "Home", flag and {type = "image", src =  flag, height = 12, width = 16} or "N/A") 
end) 

Link to comment

You can't use table on setElementData. Read https://wiki.multitheftauto.com/wiki/Element_data

Since not all datatypes can be packetized to be transferred, there are some restrictions. The types that cannot be stored as element data are non-element userdata (see MTA Classes), functions and threads. Also, you may not send tables which contain one or more values of any of these types.

The best way is using triggerClientEvent. Or if you really want to use setElementData. Only attach Country on Element Data, then declare another variable on Client Side.

Server Side

addEventHandler("onPlayerJoin", root, 
function() 
    local country = exports.admin:getPlayerCountry(source) 
    setElementData(source, "country", country) 
end) 

Client Side

  
local country = getElementData(localPlayer, "country") 
local imgpath = ":admin/client/images/flags/"..country..".png" 

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