Jump to content

Scoreboard flag+namecountry


Dany Alex

Recommended Posts

Posted

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) 

Posted

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" 

Posted

For adding the image to the scoreboard, you'll have to edit the scoreboard resource and add the image path there or you can set a different element data which describes the path and then get it using getElementData. Then add dxDrawImage in scoreboard.

  • Like 1

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