Jump to content

Country flag scoreboard


No4NaMe

Recommended Posts

How to make the country flag of a player in scoreboard?

 

Country flag

countryNames = {
    ["IT"]="Italy",
    ["MX"]="Mexico",
    ["SA"]="SAUDI ARBIA",
    ["PK"]="Pakistan",
    ["AF"]="Afghanistan",
    ["DZ"]="Algeria",
    ["AS"]="American samoa",
    ["AU"]="Australlia",
    ["AO"]="Anqola",
    ["AI"]="Anquilla",
    ["AQ"]="Antarctica",
    ["AG"]="Antigua and Barbuda",
    ["AR"]="Argentina",
    ["AM"]="Armenia",
    ["AW"]="Aruba",
    ["AT"]="Austria",
    ["AZ"]="Azerbaijan",
    ["BS"]="Bahamas",
    ["BH"]="Bahrain",
    ["BD"]="Bangladesh",
    ["BB"]="Barbados",
    ["BY"]="Belarus",
    ["BE"]="Belgium",
    ["BZ"]="Belize",
    ["BJ"]="Benin",
    ["BM"]="Bermuda",
    ["BT"]="Bhutan",
    ["BO"]="Bolivia",
    ["BA"]="Bosnia",
    ["BH"]="Herzegovina",
    ["BW"]="Botswana",
    ["BR"]="Brazil",
    ["IO"]="British Indian Ocean Territory",
    ["VG"]="British Virgin Islands",
    ["BN"]="Brunei",
    ["BG"]="Bulgaria",
    ["BF"]="Burkina Faso",
    ["MM"]="Burma (Myanmar)",
    ["BI"]="Burundi",
    ["KH"]="Cambodia",
    ["CM"]="Cameroon",
    ["CA"]="Canada",
    ["CV"]="Cape Verde",
    ["KY"]="Cayman Islands",
    ["CF"]="Central African Republic",
    ["TD"]="Chad",
    ["CL"]="Chile",
    ["CN"]="China",
    ["CX"]="Christmas Island",
    ["CC"]="Cocos (Keeling) Islands",
    ["CO"]="Colombia",
    ["KM"]="Comoros",
    ["CK"]="Cook Islands",
    ["CR"]="Costa Rica",
    ["HR"]="Croatia",
    ["CU"]="Cuba",
    ["CY"]="Cyprus",
    ["CZ"]="Czech Republic",
    ["CD"]="Democratic Republic of the Congo",
    ["DK"]="Denmark",
    ["DJ"]="Djibouti",
    ["DM"]="Dominica",
    ["DO"]="Dominican Republic",
    ["EC"]="Ecuador",
    ["SV"]="El Salvador",
    ["GQ"]="Equatorial Guinea",
    ["ER"]="Eritrea",
    ["EE"]="Estonia",
    ["ET"]="Ethiopia",
    ["FK"]="Falkland Islands",
    ["FO"]="Faroe Islands",
    ["FJ"]="Fiji",
    ["FI"]="Finland",
    ["FR"]="France",
    ["PF"]="French Polynesia",
    ["GA"]="Gabon",
    ["GM"]="Gambia",
    ["GE"]="Georgia",
    ["DE"]="Germany",
    ["GH"]="Ghana",
    ["GI"]="Gibraltar",
    ["GR"]="Greece",
    ["GL"]="Greenland",
    ["GD"]="Grenada",
    ["GU"]="Guam",
    ["GT"]="Guatemala",
    ["GN"]="Guinea",
    ["GW"]="Guinea-Bissau",
    ["GY"]="Guyana",
    ["HT"]="Haiti",
    ["VA"]="Holy See (Vatican City)",
    ["HN"]="Honduras",
    ["HK"]="Hong Kong",
    ["HU"]="Hungary",
    ["IS"]="Iceland",
    ["IN"]="India",
    ["ID"]="Indonesia",
    ["IR"]="Iran",
    ["IQ"]="Iraq",
    ["IE"]="Ireland",
    ["IM"]="Isle of Man",
    ["IL"]="Israel",
    ["IT"]="Italy",
    ["CI"]="Ivory Coast",
    ["JM"]="Jamaica",
    ["JP"]="Japan",
    ["JE"]="Jersey",
    ["JO"]="Jordan",
    ["KZ"]="Kazakhstan",
    ["KE"]="Kenya",
    ["KI"]="Kiribati",
    ["KO"]="Kosovo",
    ["KW"]="Kuwait",
    ["KG"]="Kyrgyzstan",
    ["LA"]="Laos",
    ["LV"]="Latvia",
    ["LB"]="Lebanon",
    ["LS"]="Lesotho",
    ["LR"]="Liberia",
    ["LY"]="Libya",
    ["LI"]="Liechtenstein",
    ["LT"]="Lithuania",
    ["LU"]="Luxembourg",
    ["MO"]="Macau",
    ["MK"]="Macedonia",
    ["MG"]="Madagascar",
    ["MW"]="Malawi",
    ["MY"]="Malaysia",
    ["MV"]="Maldives",
    ["ML"]="Mali",
    ["MT"]="Malta",
    ["MH"]="Marshall Islands",
    ["MR"]="Mauritania",
    ["MU"]="Mauritius",
    ["YT"]="Mayotte",
    ["MX"]="Mexico",
    ["FM"]="Micronesia",
    ["MD"]="Moldova",
    ["MC"]="Monaco",
    ["MN"]="Mongolia",
    ["ME"]="Montenegro",    
    ["MS"]="Montserrat",
    ["MA"]="Morocco",
    ["MZ"]="Mozambique",
    ["NA"]="Namibia",
    ["NR"]="Nauru",
    ["NP"]="Nepal",
    ["NL"]="Netherlands",
    ["AN"]="Netherlands Antilles",
    ["NC"]="New Caledonia",
    ["NZ"]="New Zealand",
    ["NI"]="Nicaragua",
    ["NE"]="Niger",
    ["NG"]="Nigeria",
    ["NU"]="Niue",
    ["NI"]="Norfolk Island",
    ["KP"]="North Korea",
    ["MP"]="Northern Mariana Islands",
    ["NO"]="Norway",
    ["OM"]="Oman",
    ["PK"]="Pakistan",
    ["PW"]="Palau",
    ["PA"]="Panama",
    ["PG"]="Papua New Guinea",
    ["PY"]="Paraguay",
    ["PE"]="Peru",
    ["PH"]="Philippines",
    ["PN"]="Pitcairn Islands",
    ["PL"]="Poland",
    ["PT"]="Portugal",
    ["PR"]="Puerto Rico",
    ["QA"]="Qatar",
    ["CG"]="Republic of the Congo",
    ["RO"]="Romania",
    ["RU"]="Russia",
    ["RW"]="Rwanda",
    ["BL"]="Saint Barthelemy",
    ["SH"]="Saint Helena",
    ["KN"]="Saint Kitts and Nevis",
    ["LC"]="Saint Lucia",
    ["MF"]="Saint Martin",
    ["PM"]="Saint Pierre and Miquelon",
    ["VC"]="Saint Vincent and the Grenadines",
    ["WS"]="Samoa",
    ["SM"]="San Marino",
    ["ST"]="Sao Tome and Principe",
    ["SA"]="Saudi Arabia",
    ["SN"]="Senegal",
    ["RS"]="Serbia",
    ["SC"]="Seychelles",
    ["SL"]="Sierra Leone",
    ["SG"]="Singapore",
    ["SK"]="Slovakia",
    ["SI"]="Slovenia",
    ["SB"]="Solomon Islands",
    ["SO"]="Somalia",
    ["ZA"]="South Africa",
    ["KR"]="South Korea",
    ["ES"]="Spain",
    ["LK"]="Sri Lanka",
    ["SD"]="Sudan",
    ["SR"]="Suriname",
    ["SJ"]="Svalbard",
    ["SZ"]="Swaziland",
    ["SE"]="Sweden",
    ["CH"]="Switzerland",
    ["SY"]="Syria",
    ["TW"]="Taiwan",
    ["TJ"]="Tajikistan",
    ["TZ"]="Tanzania",
    ["TH"]="Thailand",
    ["TL"]="Timor-Leste",
    ["TG"]="Togo",
    ["TK"]="Tokelau",
    ["TO"]="Tonga",
    ["TT"]="Trinidad and Tobago",
    ["TN"]="Tunisia",
    ["TR"]="Turkey",
    ["TM"]="Turkmenistan",
    ["TC"]="Turks and Caicos Islands",
    ["TV"]="Tuvalu",
    ["UG"]="Uganda",
    ["UA"]="Ukraine",
    ["AE"]="United Arab Emirates",
    ["GB"]="United Kingdom",
    ["US"]="United States",
    ["UY"]="Uruguay",
    ["VI"]="US Virgin Islands",
    ["UZ"]="Uzbekistan",
    ["VU"]="Vanuatu",
    ["VE"]="Venezuela",
    ["VN"]="Vietnam",
    ["WF"]="Wallis and Futuna",
    ["WB"]="West Bank",
    ["EH"]="Western Sahara",
    ["YE"]="Yemen",
    ["ZM"]="Zambia",
    ["ZW"]="Zimbabwe"
}

function OnResourceStart()
	call(getResourceFromName("scoreboard"),"addScoreboardColumn","Country", getRootElement(), 10, 150)

	call(getResourceFromName("scoreboard"),"addScoreboardColumn","          flag", getRootElement(), 9, 16)

    local tPlayers = getElementsByType('player')
    for _,uPlayer in ipairs(tPlayers) do
		local countryCode = exports["admin"]:getPlayerCountry(uPlayer)
		local name = "Unknown"
			
		if countryCode and countryNames[countryCode] then
			name = countryNames[countryCode]
			
			local sFlagImagePath = ':'..getResourceName( getThisResource() )..'/flags/'..string.lower(countryCode)..'.png'
			if fileExists(sFlagImagePath) then
				setElementData(uPlayer, "countryFlagImage", sFlagImagePath )
			else
				setElementData(uPlayer, "countryFlagImage", "??" )
			end
		end
		setElementData(uPlayer, "Country", name )
	end
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), OnResourceStart)

 

and scoreboard

local sw, sh = guiGetScreenSize()
local fps = getPlayerPing(getLocalPlayer())
ColumnName = {{ name = "", width = 100, data = function (element) return getPlayerName ( element) end },}
ColumnStats = { 
{ name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },
{ name = "Zombies", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },
{ name = "Alive", width = 100, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },
{ name = "Ping", width = 80, data = function (element) return getPlayerPing ( element, "ping" ) or 99 end },
{ name = "Group", width = 100, data = function (element) return getElementData ( element, "Group" ) or "None" end },
}

local serverName = "Server"
local topsize = 60
local playersize = topsize-30
local panelsize = playersize*1

function calculateWidth()
	local width = 0
	for key, value in ipairs( ColumnName ) do
		width = width + value.width
	end
	for key, value in ipairs( ColumnStats ) do
		width = width + value.width
	end	
	return width + 60
end 

local max_players = 50
local ploff = 0
local width = calculateWidth()
local baseX = sw/2-width/2
local baseY = sh/2-(panelsize+topsize)/0.5
 
addEventHandler( "onClientRender", root,
function()
	if getKeyState( "tab" ) == false then ploff = 0; return end
	if getElementData(getLocalPlayer(),"logedin") then
		dxDrawRectangle ( baseX, baseY-40, width, topsize+10, tocolor(0, 0, 0, 80) )
		dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(0, 0, 0, 40) )		
		dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(255,255,255,60), 2.6, "bankgothic" )
		dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0, 0, 0, 40) )			
		dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100,50),0.8 )			
		local xoff = 60
		for i, v in ipairs ( ColumnName ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end			
		for i, v in ipairs ( ColumnStats ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end
		local playersTable = getElementsByType ( "player" )
		dxDrawText ( "Players:  "..tostring(#playersTable).."/"..tostring(max_players), baseX -550, baseY+60, baseX+width, baseY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )	
		local maxNum = #playersTable
		if maxNum > 10 then
			maxNum = 10
		end
		for i = 1, maxNum do
			dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(0, 0, 0, 40),0.5 )
			dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 1, "default-bold", "center", "center" )
			if playersTable[i+ploff] == localPlayer then
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 60) )
				else
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 30) )					
			end
			local xoff = 60		
			for c, d in ipairs ( ColumnName ) do
				local data = d.data(playersTable[i+ploff])
				--local r,g,b = 255,255,255,50
				dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
				for c, d in ipairs ( ColumnStats ) do
				local data = d.data(playersTable[i+ploff])
				local r,g,b = 255, 255, 255,255
				if d.name == "Group" and data == "None" then
					r,g,b = 249,41,0
					data = "None"
				end
				dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
		end
	end
end
)

function PlayerScrollMenu (key,keyState,arg)
	if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then
		if ( keyState == "down" ) then
			if arg == "up" then
				if ploff > 0 then
					ploff=ploff-1
				end
			elseif arg == "down" then
				local playersTable = getElementsByType ( "player" )
				if ploff < #playersTable-10 then
					ploff = ploff+1
				end
			end
		end
	end
end
bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )

function formatTimeFromMinutes(value)
	if value then
		local hours = math.floor(value/60)
		local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
		if hours then
		if hours == 0 then
		value = minutes.." min"
		end
		elseif hours >= 1 then
		value = hours.." ч	"..minutes.." min"
		end
		return value
	end
	return false
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function sendMaxPlayersOnServer (players)
	max_players = players
end
addEvent("sendMaxPlayersOnServer",true)
addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

 

Please help me!

Link to comment
1 hour ago, No4NaMe said:

How to make the country flag of a player in scoreboard?

 

Country flag


countryNames = {
    ["IT"]="Italy",
    ["MX"]="Mexico",
    ["SA"]="SAUDI ARBIA",
    ["PK"]="Pakistan",
    ["AF"]="Afghanistan",
    ["DZ"]="Algeria",
    ["AS"]="American samoa",
    ["AU"]="Australlia",
    ["AO"]="Anqola",
    ["AI"]="Anquilla",
    ["AQ"]="Antarctica",
    ["AG"]="Antigua and Barbuda",
    ["AR"]="Argentina",
    ["AM"]="Armenia",
    ["AW"]="Aruba",
    ["AT"]="Austria",
    ["AZ"]="Azerbaijan",
    ["BS"]="Bahamas",
    ["BH"]="Bahrain",
    ["BD"]="Bangladesh",
    ["BB"]="Barbados",
    ["BY"]="Belarus",
    ["BE"]="Belgium",
    ["BZ"]="Belize",
    ["BJ"]="Benin",
    ["BM"]="Bermuda",
    ["BT"]="Bhutan",
    ["BO"]="Bolivia",
    ["BA"]="Bosnia",
    ["BH"]="Herzegovina",
    ["BW"]="Botswana",
    ["BR"]="Brazil",
    ["IO"]="British Indian Ocean Territory",
    ["VG"]="British Virgin Islands",
    ["BN"]="Brunei",
    ["BG"]="Bulgaria",
    ["BF"]="Burkina Faso",
    ["MM"]="Burma (Myanmar)",
    ["BI"]="Burundi",
    ["KH"]="Cambodia",
    ["CM"]="Cameroon",
    ["CA"]="Canada",
    ["CV"]="Cape Verde",
    ["KY"]="Cayman Islands",
    ["CF"]="Central African Republic",
    ["TD"]="Chad",
    ["CL"]="Chile",
    ["CN"]="China",
    ["CX"]="Christmas Island",
    ["CC"]="Cocos (Keeling) Islands",
    ["CO"]="Colombia",
    ["KM"]="Comoros",
    ["CK"]="Cook Islands",
    ["CR"]="Costa Rica",
    ["HR"]="Croatia",
    ["CU"]="Cuba",
    ["CY"]="Cyprus",
    ["CZ"]="Czech Republic",
    ["CD"]="Democratic Republic of the Congo",
    ["DK"]="Denmark",
    ["DJ"]="Djibouti",
    ["DM"]="Dominica",
    ["DO"]="Dominican Republic",
    ["EC"]="Ecuador",
    ["SV"]="El Salvador",
    ["GQ"]="Equatorial Guinea",
    ["ER"]="Eritrea",
    ["EE"]="Estonia",
    ["ET"]="Ethiopia",
    ["FK"]="Falkland Islands",
    ["FO"]="Faroe Islands",
    ["FJ"]="Fiji",
    ["FI"]="Finland",
    ["FR"]="France",
    ["PF"]="French Polynesia",
    ["GA"]="Gabon",
    ["GM"]="Gambia",
    ["GE"]="Georgia",
    ["DE"]="Germany",
    ["GH"]="Ghana",
    ["GI"]="Gibraltar",
    ["GR"]="Greece",
    ["GL"]="Greenland",
    ["GD"]="Grenada",
    ["GU"]="Guam",
    ["GT"]="Guatemala",
    ["GN"]="Guinea",
    ["GW"]="Guinea-Bissau",
    ["GY"]="Guyana",
    ["HT"]="Haiti",
    ["VA"]="Holy See (Vatican City)",
    ["HN"]="Honduras",
    ["HK"]="Hong Kong",
    ["HU"]="Hungary",
    ["IS"]="Iceland",
    ["IN"]="India",
    ["ID"]="Indonesia",
    ["IR"]="Iran",
    ["IQ"]="Iraq",
    ["IE"]="Ireland",
    ["IM"]="Isle of Man",
    ["IL"]="Israel",
    ["IT"]="Italy",
    ["CI"]="Ivory Coast",
    ["JM"]="Jamaica",
    ["JP"]="Japan",
    ["JE"]="Jersey",
    ["JO"]="Jordan",
    ["KZ"]="Kazakhstan",
    ["KE"]="Kenya",
    ["KI"]="Kiribati",
    ["KO"]="Kosovo",
    ["KW"]="Kuwait",
    ["KG"]="Kyrgyzstan",
    ["LA"]="Laos",
    ["LV"]="Latvia",
    ["LB"]="Lebanon",
    ["LS"]="Lesotho",
    ["LR"]="Liberia",
    ["LY"]="Libya",
    ["LI"]="Liechtenstein",
    ["LT"]="Lithuania",
    ["LU"]="Luxembourg",
    ["MO"]="Macau",
    ["MK"]="Macedonia",
    ["MG"]="Madagascar",
    ["MW"]="Malawi",
    ["MY"]="Malaysia",
    ["MV"]="Maldives",
    ["ML"]="Mali",
    ["MT"]="Malta",
    ["MH"]="Marshall Islands",
    ["MR"]="Mauritania",
    ["MU"]="Mauritius",
    ["YT"]="Mayotte",
    ["MX"]="Mexico",
    ["FM"]="Micronesia",
    ["MD"]="Moldova",
    ["MC"]="Monaco",
    ["MN"]="Mongolia",
    ["ME"]="Montenegro",    
    ["MS"]="Montserrat",
    ["MA"]="Morocco",
    ["MZ"]="Mozambique",
    ["NA"]="Namibia",
    ["NR"]="Nauru",
    ["NP"]="Nepal",
    ["NL"]="Netherlands",
    ["AN"]="Netherlands Antilles",
    ["NC"]="New Caledonia",
    ["NZ"]="New Zealand",
    ["NI"]="Nicaragua",
    ["NE"]="Niger",
    ["NG"]="Nigeria",
    ["NU"]="Niue",
    ["NI"]="Norfolk Island",
    ["KP"]="North Korea",
    ["MP"]="Northern Mariana Islands",
    ["NO"]="Norway",
    ["OM"]="Oman",
    ["PK"]="Pakistan",
    ["PW"]="Palau",
    ["PA"]="Panama",
    ["PG"]="Papua New Guinea",
    ["PY"]="Paraguay",
    ["PE"]="Peru",
    ["PH"]="Philippines",
    ["PN"]="Pitcairn Islands",
    ["PL"]="Poland",
    ["PT"]="Portugal",
    ["PR"]="Puerto Rico",
    ["QA"]="Qatar",
    ["CG"]="Republic of the Congo",
    ["RO"]="Romania",
    ["RU"]="Russia",
    ["RW"]="Rwanda",
    ["BL"]="Saint Barthelemy",
    ["SH"]="Saint Helena",
    ["KN"]="Saint Kitts and Nevis",
    ["LC"]="Saint Lucia",
    ["MF"]="Saint Martin",
    ["PM"]="Saint Pierre and Miquelon",
    ["VC"]="Saint Vincent and the Grenadines",
    ["WS"]="Samoa",
    ["SM"]="San Marino",
    ["ST"]="Sao Tome and Principe",
    ["SA"]="Saudi Arabia",
    ["SN"]="Senegal",
    ["RS"]="Serbia",
    ["SC"]="Seychelles",
    ["SL"]="Sierra Leone",
    ["SG"]="Singapore",
    ["SK"]="Slovakia",
    ["SI"]="Slovenia",
    ["SB"]="Solomon Islands",
    ["SO"]="Somalia",
    ["ZA"]="South Africa",
    ["KR"]="South Korea",
    ["ES"]="Spain",
    ["LK"]="Sri Lanka",
    ["SD"]="Sudan",
    ["SR"]="Suriname",
    ["SJ"]="Svalbard",
    ["SZ"]="Swaziland",
    ["SE"]="Sweden",
    ["CH"]="Switzerland",
    ["SY"]="Syria",
    ["TW"]="Taiwan",
    ["TJ"]="Tajikistan",
    ["TZ"]="Tanzania",
    ["TH"]="Thailand",
    ["TL"]="Timor-Leste",
    ["TG"]="Togo",
    ["TK"]="Tokelau",
    ["TO"]="Tonga",
    ["TT"]="Trinidad and Tobago",
    ["TN"]="Tunisia",
    ["TR"]="Turkey",
    ["TM"]="Turkmenistan",
    ["TC"]="Turks and Caicos Islands",
    ["TV"]="Tuvalu",
    ["UG"]="Uganda",
    ["UA"]="Ukraine",
    ["AE"]="United Arab Emirates",
    ["GB"]="United Kingdom",
    ["US"]="United States",
    ["UY"]="Uruguay",
    ["VI"]="US Virgin Islands",
    ["UZ"]="Uzbekistan",
    ["VU"]="Vanuatu",
    ["VE"]="Venezuela",
    ["VN"]="Vietnam",
    ["WF"]="Wallis and Futuna",
    ["WB"]="West Bank",
    ["EH"]="Western Sahara",
    ["YE"]="Yemen",
    ["ZM"]="Zambia",
    ["ZW"]="Zimbabwe"
}

function OnResourceStart()
	call(getResourceFromName("scoreboard"),"addScoreboardColumn","Country", getRootElement(), 10, 150)

	call(getResourceFromName("scoreboard"),"addScoreboardColumn","          flag", getRootElement(), 9, 16)

    local tPlayers = getElementsByType('player')
    for _,uPlayer in ipairs(tPlayers) do
		local countryCode = exports["admin"]:getPlayerCountry(uPlayer)
		local name = "Unknown"
			
		if countryCode and countryNames[countryCode] then
			name = countryNames[countryCode]
			
			local sFlagImagePath = ':'..getResourceName( getThisResource() )..'/flags/'..string.lower(countryCode)..'.png'
			if fileExists(sFlagImagePath) then
				setElementData(uPlayer, "countryFlagImage", sFlagImagePath )
			else
				setElementData(uPlayer, "countryFlagImage", "??" )
			end
		end
		setElementData(uPlayer, "Country", name )
	end
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), OnResourceStart)

 

and scoreboard


local sw, sh = guiGetScreenSize()
local fps = getPlayerPing(getLocalPlayer())
ColumnName = {{ name = "", width = 100, data = function (element) return getPlayerName ( element) end },}
ColumnStats = { 
{ name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },
{ name = "Zombies", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },
{ name = "Alive", width = 100, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },
{ name = "Ping", width = 80, data = function (element) return getPlayerPing ( element, "ping" ) or 99 end },
{ name = "Group", width = 100, data = function (element) return getElementData ( element, "Group" ) or "None" end },
}

local serverName = "Server"
local topsize = 60
local playersize = topsize-30
local panelsize = playersize*1

function calculateWidth()
	local width = 0
	for key, value in ipairs( ColumnName ) do
		width = width + value.width
	end
	for key, value in ipairs( ColumnStats ) do
		width = width + value.width
	end	
	return width + 60
end 

local max_players = 50
local ploff = 0
local width = calculateWidth()
local baseX = sw/2-width/2
local baseY = sh/2-(panelsize+topsize)/0.5
 
addEventHandler( "onClientRender", root,
function()
	if getKeyState( "tab" ) == false then ploff = 0; return end
	if getElementData(getLocalPlayer(),"logedin") then
		dxDrawRectangle ( baseX, baseY-40, width, topsize+10, tocolor(0, 0, 0, 80) )
		dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(0, 0, 0, 40) )		
		dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(255,255,255,60), 2.6, "bankgothic" )
		dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0, 0, 0, 40) )			
		dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100,50),0.8 )			
		local xoff = 60
		for i, v in ipairs ( ColumnName ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end			
		for i, v in ipairs ( ColumnStats ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end
		local playersTable = getElementsByType ( "player" )
		dxDrawText ( "Players:  "..tostring(#playersTable).."/"..tostring(max_players), baseX -550, baseY+60, baseX+width, baseY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )	
		local maxNum = #playersTable
		if maxNum > 10 then
			maxNum = 10
		end
		for i = 1, maxNum do
			dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(0, 0, 0, 40),0.5 )
			dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 1, "default-bold", "center", "center" )
			if playersTable[i+ploff] == localPlayer then
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 60) )
				else
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 30) )					
			end
			local xoff = 60		
			for c, d in ipairs ( ColumnName ) do
				local data = d.data(playersTable[i+ploff])
				--local r,g,b = 255,255,255,50
				dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
				for c, d in ipairs ( ColumnStats ) do
				local data = d.data(playersTable[i+ploff])
				local r,g,b = 255, 255, 255,255
				if d.name == "Group" and data == "None" then
					r,g,b = 249,41,0
					data = "None"
				end
				dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
		end
	end
end
)

function PlayerScrollMenu (key,keyState,arg)
	if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then
		if ( keyState == "down" ) then
			if arg == "up" then
				if ploff > 0 then
					ploff=ploff-1
				end
			elseif arg == "down" then
				local playersTable = getElementsByType ( "player" )
				if ploff < #playersTable-10 then
					ploff = ploff+1
				end
			end
		end
	end
end
bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )

function formatTimeFromMinutes(value)
	if value then
		local hours = math.floor(value/60)
		local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
		if hours then
		if hours == 0 then
		value = minutes.." min"
		end
		elseif hours >= 1 then
		value = hours.." ч	"..minutes.." min"
		end
		return value
	end
	return false
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function sendMaxPlayersOnServer (players)
	max_players = players
end
addEvent("sendMaxPlayersOnServer",true)
addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

 

Please help me!

is that the original scoreboard ?

if it was the original u should edit it to make it accept drawing image  

Link to comment

try this am didn't test it really but try it

local sw, sh = guiGetScreenSize()
local fps = getPlayerPing(getLocalPlayer())
ColumnName = {{ name = "", width = 100, data = function (element) return getPlayerName ( element) end },}
ColumnStats = { 
{ name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },
{ name = "Zombies", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },
{ name = "Alive", width = 100, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },
{ name = "Ping", width = 80, data = function (element) return getPlayerPing ( element, "ping" ) or 99 end },
{ name = "Country", width = 100, data = function (element) return getElementData ( element, "Country" ) or 'N/A' end },
 { name = "Flag", width = 100, data = function (element) return getElementData ( element, "countryFlagImage" ) or 'N/A' end },
{ name = "Group", width = 100, data = function (element) return getElementData ( element, "Group" ) or "None" end },
}


local serverName = "Server"
local topsize = 60
local playersize = topsize-30
local panelsize = playersize*1

function calculateWidth()
	local width = 0
	for key, value in ipairs( ColumnName ) do
		width = width + value.width
	end
	for key, value in ipairs( ColumnStats ) do
		width = width + value.width
	end	
	return width + 60
end 

local max_players = 50
local ploff = 0
local width = calculateWidth()
local baseX = sw/2-width/2
local baseY = sh/2-(panelsize+topsize)/0.5
 


addEventHandler( "onClientRender", root,
function()
	if getKeyState( "tab" ) == false then ploff = 0; return end
	if getElementData(getLocalPlayer(),"logedin") then
		dxDrawRectangle ( baseX, baseY-40, width, topsize+10, tocolor(0, 0, 0, 80) )
		dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(0, 0, 0, 40) )		
		dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(255,255,255,60), 2.6, "bankgothic" )
		dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0, 0, 0, 40) )			
		dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100,50),0.8 )			
		local xoff = 60
		for i, v in ipairs ( ColumnName ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end			
		for i, v in ipairs ( ColumnStats ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end
		local playersTable = getElementsByType ( "player" )
		dxDrawText ( "Players:  "..tostring(#playersTable).."/"..tostring(max_players), baseX -550, baseY+60, baseX+width, baseY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )	
		local maxNum = #playersTable
		if maxNum > 10 then
			maxNum = 10
		end
		for i = 1, maxNum do
			dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(0, 0, 0, 40),0.5 )
			dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 1, "default-bold", "center", "center" )
			if playersTable[i+ploff] == localPlayer then
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 60) )
				else
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 30) )					
			end
			local xoff = 60		
			for c, d in ipairs ( ColumnName ) do
				local data = d.data(playersTable[i+ploff])
				--local r,g,b = 255,255,255,50
				dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
				for c, d in ipairs ( ColumnStats ) do
				local data = d.data(playersTable[i+ploff])
				local r,g,b = 255, 255, 255,255
				if d.name == "Group" and data == "None" then
					r,g,b = 249,41,0
					data = "None"
				end
          if d.name~='Flag' then
				dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
            else
            if data~='??' then
          	  dxDrawImage ( baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, data )
              else
            	dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
            end
          end
				xoff = xoff+d.width
			end
		end
	end
end
)


function PlayerScrollMenu (key,keyState,arg)
	if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then
		if ( keyState == "down" ) then
			if arg == "up" then
				if ploff > 0 then
					ploff=ploff-1
				end
			elseif arg == "down" then
				local playersTable = getElementsByType ( "player" )
				if ploff < #playersTable-10 then
					ploff = ploff+1
				end
			end
		end
	end
end
bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )

function formatTimeFromMinutes(value)
	if value then
		local hours = math.floor(value/60)
		local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
		if hours then
		if hours == 0 then
		value = minutes.." min"
		end
		elseif hours >= 1 then
		value = hours.." ч	"..minutes.." min"
		end
		return value
	end
	return false
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function sendMaxPlayersOnServer (players)
	max_players = players
end
addEvent("sendMaxPlayersOnServer",true)
addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

============================================

countryNames = {
    ["IT"]="Italy",
    ["MX"]="Mexico",
    ["SA"]="SAUDI ARBIA",
    ["PK"]="Pakistan",
    ["AF"]="Afghanistan",
    ["DZ"]="Algeria",
    ["AS"]="American samoa",
    ["AU"]="Australlia",
    ["AO"]="Anqola",
    ["AI"]="Anquilla",
    ["AQ"]="Antarctica",
    ["AG"]="Antigua and Barbuda",
    ["AR"]="Argentina",
    ["AM"]="Armenia",
    ["AW"]="Aruba",
    ["AT"]="Austria",
    ["AZ"]="Azerbaijan",
    ["BS"]="Bahamas",
    ["BH"]="Bahrain",
    ["BD"]="Bangladesh",
    ["BB"]="Barbados",
    ["BY"]="Belarus",
    ["BE"]="Belgium",
    ["BZ"]="Belize",
    ["BJ"]="Benin",
    ["BM"]="Bermuda",
    ["BT"]="Bhutan",
    ["BO"]="Bolivia",
    ["BA"]="Bosnia",
    ["BH"]="Herzegovina",
    ["BW"]="Botswana",
    ["BR"]="Brazil",
    ["IO"]="British Indian Ocean Territory",
    ["VG"]="British Virgin Islands",
    ["BN"]="Brunei",
    ["BG"]="Bulgaria",
    ["BF"]="Burkina Faso",
    ["MM"]="Burma (Myanmar)",
    ["BI"]="Burundi",
    ["KH"]="Cambodia",
    ["CM"]="Cameroon",
    ["CA"]="Canada",
    ["CV"]="Cape Verde",
    ["KY"]="Cayman Islands",
    ["CF"]="Central African Republic",
    ["TD"]="Chad",
    ["CL"]="Chile",
    ["CN"]="China",
    ["CX"]="Christmas Island",
    ["CC"]="Cocos (Keeling) Islands",
    ["CO"]="Colombia",
    ["KM"]="Comoros",
    ["CK"]="Cook Islands",
    ["CR"]="Costa Rica",
    ["HR"]="Croatia",
    ["CU"]="Cuba",
    ["CY"]="Cyprus",
    ["CZ"]="Czech Republic",
    ["CD"]="Democratic Republic of the Congo",
    ["DK"]="Denmark",
    ["DJ"]="Djibouti",
    ["DM"]="Dominica",
    ["DO"]="Dominican Republic",
    ["EC"]="Ecuador",
    ["SV"]="El Salvador",
    ["GQ"]="Equatorial Guinea",
    ["ER"]="Eritrea",
    ["EE"]="Estonia",
    ["ET"]="Ethiopia",
    ["FK"]="Falkland Islands",
    ["FO"]="Faroe Islands",
    ["FJ"]="Fiji",
    ["FI"]="Finland",
    ["FR"]="France",
    ["PF"]="French Polynesia",
    ["GA"]="Gabon",
    ["GM"]="Gambia",
    ["GE"]="Georgia",
    ["DE"]="Germany",
    ["GH"]="Ghana",
    ["GI"]="Gibraltar",
    ["GR"]="Greece",
    ["GL"]="Greenland",
    ["GD"]="Grenada",
    ["GU"]="Guam",
    ["GT"]="Guatemala",
    ["GN"]="Guinea",
    ["GW"]="Guinea-Bissau",
    ["GY"]="Guyana",
    ["HT"]="Haiti",
    ["VA"]="Holy See (Vatican City)",
    ["HN"]="Honduras",
    ["HK"]="Hong Kong",
    ["HU"]="Hungary",
    ["IS"]="Iceland",
    ["IN"]="India",
    ["ID"]="Indonesia",
    ["IR"]="Iran",
    ["IQ"]="Iraq",
    ["IE"]="Ireland",
    ["IM"]="Isle of Man",
    ["IL"]="Israel",
    ["IT"]="Italy",
    ["CI"]="Ivory Coast",
    ["JM"]="Jamaica",
    ["JP"]="Japan",
    ["JE"]="Jersey",
    ["JO"]="Jordan",
    ["KZ"]="Kazakhstan",
    ["KE"]="Kenya",
    ["KI"]="Kiribati",
    ["KO"]="Kosovo",
    ["KW"]="Kuwait",
    ["KG"]="Kyrgyzstan",
    ["LA"]="Laos",
    ["LV"]="Latvia",
    ["LB"]="Lebanon",
    ["LS"]="Lesotho",
    ["LR"]="Liberia",
    ["LY"]="Libya",
    ["LI"]="Liechtenstein",
    ["LT"]="Lithuania",
    ["LU"]="Luxembourg",
    ["MO"]="Macau",
    ["MK"]="Macedonia",
    ["MG"]="Madagascar",
    ["MW"]="Malawi",
    ["MY"]="Malaysia",
    ["MV"]="Maldives",
    ["ML"]="Mali",
    ["MT"]="Malta",
    ["MH"]="Marshall Islands",
    ["MR"]="Mauritania",
    ["MU"]="Mauritius",
    ["YT"]="Mayotte",
    ["MX"]="Mexico",
    ["FM"]="Micronesia",
    ["MD"]="Moldova",
    ["MC"]="Monaco",
    ["MN"]="Mongolia",
    ["ME"]="Montenegro",    
    ["MS"]="Montserrat",
    ["MA"]="Morocco",
    ["MZ"]="Mozambique",
    ["NA"]="Namibia",
    ["NR"]="Nauru",
    ["NP"]="Nepal",
    ["NL"]="Netherlands",
    ["AN"]="Netherlands Antilles",
    ["NC"]="New Caledonia",
    ["NZ"]="New Zealand",
    ["NI"]="Nicaragua",
    ["NE"]="Niger",
    ["NG"]="Nigeria",
    ["NU"]="Niue",
    ["NI"]="Norfolk Island",
    ["KP"]="North Korea",
    ["MP"]="Northern Mariana Islands",
    ["NO"]="Norway",
    ["OM"]="Oman",
    ["PK"]="Pakistan",
    ["PW"]="Palau",
    ["PA"]="Panama",
    ["PG"]="Papua New Guinea",
    ["PY"]="Paraguay",
    ["PE"]="Peru",
    ["PH"]="Philippines",
    ["PN"]="Pitcairn Islands",
    ["PL"]="Poland",
    ["PT"]="Portugal",
    ["PR"]="Puerto Rico",
    ["QA"]="Qatar",
    ["CG"]="Republic of the Congo",
    ["RO"]="Romania",
    ["RU"]="Russia",
    ["RW"]="Rwanda",
    ["BL"]="Saint Barthelemy",
    ["SH"]="Saint Helena",
    ["KN"]="Saint Kitts and Nevis",
    ["LC"]="Saint Lucia",
    ["MF"]="Saint Martin",
    ["PM"]="Saint Pierre and Miquelon",
    ["VC"]="Saint Vincent and the Grenadines",
    ["WS"]="Samoa",
    ["SM"]="San Marino",
    ["ST"]="Sao Tome and Principe",
    ["SA"]="Saudi Arabia",
    ["SN"]="Senegal",
    ["RS"]="Serbia",
    ["SC"]="Seychelles",
    ["SL"]="Sierra Leone",
    ["SG"]="Singapore",
    ["SK"]="Slovakia",
    ["SI"]="Slovenia",
    ["SB"]="Solomon Islands",
    ["SO"]="Somalia",
    ["ZA"]="South Africa",
    ["KR"]="South Korea",
    ["ES"]="Spain",
    ["LK"]="Sri Lanka",
    ["SD"]="Sudan",
    ["SR"]="Suriname",
    ["SJ"]="Svalbard",
    ["SZ"]="Swaziland",
    ["SE"]="Sweden",
    ["CH"]="Switzerland",
    ["SY"]="Syria",
    ["TW"]="Taiwan",
    ["TJ"]="Tajikistan",
    ["TZ"]="Tanzania",
    ["TH"]="Thailand",
    ["TL"]="Timor-Leste",
    ["TG"]="Togo",
    ["TK"]="Tokelau",
    ["TO"]="Tonga",
    ["TT"]="Trinidad and Tobago",
    ["TN"]="Tunisia",
    ["TR"]="Turkey",
    ["TM"]="Turkmenistan",
    ["TC"]="Turks and Caicos Islands",
    ["TV"]="Tuvalu",
    ["UG"]="Uganda",
    ["UA"]="Ukraine",
    ["AE"]="United Arab Emirates",
    ["GB"]="United Kingdom",
    ["US"]="United States",
    ["UY"]="Uruguay",
    ["VI"]="US Virgin Islands",
    ["UZ"]="Uzbekistan",
    ["VU"]="Vanuatu",
    ["VE"]="Venezuela",
    ["VN"]="Vietnam",
    ["WF"]="Wallis and Futuna",
    ["WB"]="West Bank",
    ["EH"]="Western Sahara",
    ["YE"]="Yemen",
    ["ZM"]="Zambia",
    ["ZW"]="Zimbabwe"
}

function OnResourceStart()

    local tPlayers = getElementsByType('player')
    for _,uPlayer in ipairs(tPlayers) do
		local countryCode = exports["admin"]:getPlayerCountry(uPlayer)
		local name = "Unknown"
			
		if countryCode and countryNames[countryCode] then
			name = countryNames[countryCode]
			
			local sFlagImagePath = ':'..getResourceName( getThisResource() )..'/flags/'..string.lower(countryCode)..'.png'
			if fileExists(sFlagImagePath) then
				setElementData(uPlayer, "countryFlagImage", sFlagImagePath )
			else
				setElementData(uPlayer, "countryFlagImage", "??" )
			end
		end
		setElementData(uPlayer, "Country", name )
	end
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), OnResourceStart)

 

Edited by Master_MTA
  • Like 1
Link to comment
7 hours ago, Master_MTA said:

try this am didn't test it really but try it


local sw, sh = guiGetScreenSize()local fps = getPlayerPing(getLocalPlayer())ColumnName = {{ name = "", width = 100, data = function (element) return getPlayerName ( element) end },}ColumnStats = { { name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },{ name = "Zombies", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },{ name = "Alive", width = 100, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },{ name = "Ping", width = 80, data = function (element) return getPlayerPing ( element, "ping" ) or 99 end },{ name = "Country", width = 100, data = function (element) return getElementData ( element, "Country" ) or 'N/A' end }, { name = "Flag", width = 100, data = function (element) return getElementData ( element, "countryFlagImage" ) or 'N/A' end },{ name = "Group", width = 100, data = function (element) return getElementData ( element, "Group" ) or "None" end },}local serverName = "Server"local topsize = 60local playersize = topsize-30local panelsize = playersize*1function calculateWidth()	local width = 0	for key, value in ipairs( ColumnName ) do		width = width + value.width	end	for key, value in ipairs( ColumnStats ) do		width = width + value.width	end		return width + 60end local max_players = 50local ploff = 0local width = calculateWidth()local baseX = sw/2-width/2local baseY = sh/2-(panelsize+topsize)/0.5 addEventHandler( "onClientRender", root,function()	if getKeyState( "tab" ) == false then ploff = 0; return end	if getElementData(getLocalPlayer(),"logedin") then		dxDrawRectangle ( baseX, baseY-40, width, topsize+10, tocolor(0, 0, 0, 80) )		dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(0, 0, 0, 40) )				dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(255,255,255,60), 2.6, "bankgothic" )		dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0, 0, 0, 40) )					dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100,50),0.8 )					local xoff = 60		for i, v in ipairs ( ColumnName ) do			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )			dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )			xoff = xoff+v.width		end					for i, v in ipairs ( ColumnStats ) do			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )			dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )			xoff = xoff+v.width		end		local playersTable = getElementsByType ( "player" )		dxDrawText ( "Players:  "..tostring(#playersTable).."/"..tostring(max_players), baseX -550, baseY+60, baseX+width, baseY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )			local maxNum = #playersTable		if maxNum > 10 then			maxNum = 10		end		for i = 1, maxNum do			dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(0, 0, 0, 40),0.5 )			dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 1, "default-bold", "center", "center" )			if playersTable[i+ploff] == localPlayer then				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 60) )				else				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 30) )								end			local xoff = 60					for c, d in ipairs ( ColumnName ) do				local data = d.data(playersTable[i+ploff])				--local r,g,b = 255,255,255,50				dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 0.9, "default-bold", "center", "center" )				xoff = xoff+d.width			end				for c, d in ipairs ( ColumnStats ) do				local data = d.data(playersTable[i+ploff])				local r,g,b = 255, 255, 255,255				if d.name == "Group" and data == "None" then					r,g,b = 249,41,0					data = "None"				end          if d.name~='Flag' then				dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )            else            if data~='??' then          	  dxDrawImage ( baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, data )              else            	dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )            end          end				xoff = xoff+d.width			end		end	endend)function PlayerScrollMenu (key,keyState,arg)	if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then		if ( keyState == "down" ) then			if arg == "up" then				if ploff > 0 then					ploff=ploff-1				end			elseif arg == "down" then				local playersTable = getElementsByType ( "player" )				if ploff < #playersTable-10 then					ploff = ploff+1				end			end		end	endendbindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )function formatTimeFromMinutes(value)	if value then		local hours = math.floor(value/60)		local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))		if hours then		if hours == 0 then		value = minutes.." min"		end		elseif hours >= 1 then		value = hours.." ч	"..minutes.." min"		end		return value	end	return falseendfunction math.round(number, decimals, method)    decimals = decimals or 0    local factor = 10 ^ decimals    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor    else return tonumber(("%."..decimals.."f"):format(number)) endendfunction sendMaxPlayersOnServer (players)	max_players = playersendaddEvent("sendMaxPlayersOnServer",true)addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

============================================


countryNames = {    ["IT"]="Italy",    ["MX"]="Mexico",    ["SA"]="SAUDI ARBIA",    ["PK"]="Pakistan",    ["AF"]="Afghanistan",    ["DZ"]="Algeria",    ["AS"]="American samoa",    ["AU"]="Australlia",    ["AO"]="Anqola",    ["AI"]="Anquilla",    ["AQ"]="Antarctica",    ["AG"]="Antigua and Barbuda",    ["AR"]="Argentina",    ["AM"]="Armenia",    ["AW"]="Aruba",    ["AT"]="Austria",    ["AZ"]="Azerbaijan",    ["BS"]="Bahamas",    ["BH"]="Bahrain",    ["BD"]="Bangladesh",    ["BB"]="Barbados",    ["BY"]="Belarus",    ["BE"]="Belgium",    ["BZ"]="Belize",    ["BJ"]="Benin",    ["BM"]="Bermuda",    ["BT"]="Bhutan",    ["BO"]="Bolivia",    ["BA"]="Bosnia",    ["BH"]="Herzegovina",    ["BW"]="Botswana",    ["BR"]="Brazil",    ["IO"]="British Indian Ocean Territory",    ["VG"]="British Virgin Islands",    ["BN"]="Brunei",    ["BG"]="Bulgaria",    ["BF"]="Burkina Faso",    ["MM"]="Burma (Myanmar)",    ["BI"]="Burundi",    ["KH"]="Cambodia",    ["CM"]="Cameroon",    ["CA"]="Canada",    ["CV"]="Cape Verde",    ["KY"]="Cayman Islands",    ["CF"]="Central African Republic",    ["TD"]="Chad",    ["CL"]="Chile",    ["CN"]="China",    ["CX"]="Christmas Island",    ["CC"]="Cocos (Keeling) Islands",    ["CO"]="Colombia",    ["KM"]="Comoros",    ["CK"]="Cook Islands",    ["CR"]="Costa Rica",    ["HR"]="Croatia",    ["CU"]="Cuba",    ["CY"]="Cyprus",    ["CZ"]="Czech Republic",    ["CD"]="Democratic Republic of the Congo",    ["DK"]="Denmark",    ["DJ"]="Djibouti",    ["DM"]="Dominica",    ["DO"]="Dominican Republic",    ["EC"]="Ecuador",    ["SV"]="El Salvador",    ["GQ"]="Equatorial Guinea",    ["ER"]="Eritrea",    ["EE"]="Estonia",    ["ET"]="Ethiopia",    ["FK"]="Falkland Islands",    ["FO"]="Faroe Islands",    ["FJ"]="Fiji",    ["FI"]="Finland",    ["FR"]="France",    ["PF"]="French Polynesia",    ["GA"]="Gabon",    ["GM"]="Gambia",    ["GE"]="Georgia",    ["DE"]="Germany",    ["GH"]="Ghana",    ["GI"]="Gibraltar",    ["GR"]="Greece",    ["GL"]="Greenland",    ["GD"]="Grenada",    ["GU"]="Guam",    ["GT"]="Guatemala",    ["GN"]="Guinea",    ["GW"]="Guinea-Bissau",    ["GY"]="Guyana",    ["HT"]="Haiti",    ["VA"]="Holy See (Vatican City)",    ["HN"]="Honduras",    ["HK"]="Hong Kong",    ["HU"]="Hungary",    ["IS"]="Iceland",    ["IN"]="India",    ["ID"]="Indonesia",    ["IR"]="Iran",    ["IQ"]="Iraq",    ["IE"]="Ireland",    ["IM"]="Isle of Man",    ["IL"]="Israel",    ["IT"]="Italy",    ["CI"]="Ivory Coast",    ["JM"]="Jamaica",    ["JP"]="Japan",    ["JE"]="Jersey",    ["JO"]="Jordan",    ["KZ"]="Kazakhstan",    ["KE"]="Kenya",    ["KI"]="Kiribati",    ["KO"]="Kosovo",    ["KW"]="Kuwait",    ["KG"]="Kyrgyzstan",    ["LA"]="Laos",    ["LV"]="Latvia",    ["LB"]="Lebanon",    ["LS"]="Lesotho",    ["LR"]="Liberia",    ["LY"]="Libya",    ["LI"]="Liechtenstein",    ["LT"]="Lithuania",    ["LU"]="Luxembourg",    ["MO"]="Macau",    ["MK"]="Macedonia",    ["MG"]="Madagascar",    ["MW"]="Malawi",    ["MY"]="Malaysia",    ["MV"]="Maldives",    ["ML"]="Mali",    ["MT"]="Malta",    ["MH"]="Marshall Islands",    ["MR"]="Mauritania",    ["MU"]="Mauritius",    ["YT"]="Mayotte",    ["MX"]="Mexico",    ["FM"]="Micronesia",    ["MD"]="Moldova",    ["MC"]="Monaco",    ["MN"]="Mongolia",    ["ME"]="Montenegro",        ["MS"]="Montserrat",    ["MA"]="Morocco",    ["MZ"]="Mozambique",    ["NA"]="Namibia",    ["NR"]="Nauru",    ["NP"]="Nepal",    ["NL"]="Netherlands",    ["AN"]="Netherlands Antilles",    ["NC"]="New Caledonia",    ["NZ"]="New Zealand",    ["NI"]="Nicaragua",    ["NE"]="Niger",    ["NG"]="Nigeria",    ["NU"]="Niue",    ["NI"]="Norfolk Island",    ["KP"]="North Korea",    ["MP"]="Northern Mariana Islands",    ["NO"]="Norway",    ["OM"]="Oman",    ["PK"]="Pakistan",    ["PW"]="Palau",    ["PA"]="Panama",    ["PG"]="Papua New Guinea",    ["PY"]="Paraguay",    ["PE"]="Peru",    ["PH"]="Philippines",    ["PN"]="Pitcairn Islands",    ["PL"]="Poland",    ["PT"]="Portugal",    ["PR"]="Puerto Rico",    ["QA"]="Qatar",    ["CG"]="Republic of the Congo",    ["RO"]="Romania",    ["RU"]="Russia",    ["RW"]="Rwanda",    ["BL"]="Saint Barthelemy",    ["SH"]="Saint Helena",    ["KN"]="Saint Kitts and Nevis",    ["LC"]="Saint Lucia",    ["MF"]="Saint Martin",    ["PM"]="Saint Pierre and Miquelon",    ["VC"]="Saint Vincent and the Grenadines",    ["WS"]="Samoa",    ["SM"]="San Marino",    ["ST"]="Sao Tome and Principe",    ["SA"]="Saudi Arabia",    ["SN"]="Senegal",    ["RS"]="Serbia",    ["SC"]="Seychelles",    ["SL"]="Sierra Leone",    ["SG"]="Singapore",    ["SK"]="Slovakia",    ["SI"]="Slovenia",    ["SB"]="Solomon Islands",    ["SO"]="Somalia",    ["ZA"]="South Africa",    ["KR"]="South Korea",    ["ES"]="Spain",    ["LK"]="Sri Lanka",    ["SD"]="Sudan",    ["SR"]="Suriname",    ["SJ"]="Svalbard",    ["SZ"]="Swaziland",    ["SE"]="Sweden",    ["CH"]="Switzerland",    ["SY"]="Syria",    ["TW"]="Taiwan",    ["TJ"]="Tajikistan",    ["TZ"]="Tanzania",    ["TH"]="Thailand",    ["TL"]="Timor-Leste",    ["TG"]="Togo",    ["TK"]="Tokelau",    ["TO"]="Tonga",    ["TT"]="Trinidad and Tobago",    ["TN"]="Tunisia",    ["TR"]="Turkey",    ["TM"]="Turkmenistan",    ["TC"]="Turks and Caicos Islands",    ["TV"]="Tuvalu",    ["UG"]="Uganda",    ["UA"]="Ukraine",    ["AE"]="United Arab Emirates",    ["GB"]="United Kingdom",    ["US"]="United States",    ["UY"]="Uruguay",    ["VI"]="US Virgin Islands",    ["UZ"]="Uzbekistan",    ["VU"]="Vanuatu",    ["VE"]="Venezuela",    ["VN"]="Vietnam",    ["WF"]="Wallis and Futuna",    ["WB"]="West Bank",    ["EH"]="Western Sahara",    ["YE"]="Yemen",    ["ZM"]="Zambia",    ["ZW"]="Zimbabwe"}function OnResourceStart()    local tPlayers = getElementsByType('player')    for _,uPlayer in ipairs(tPlayers) do		local countryCode = exports["admin"]:getPlayerCountry(uPlayer)		local name = "Unknown"					if countryCode and countryNames[countryCode] then			name = countryNames[countryCode]						local sFlagImagePath = ':'..getResourceName( getThisResource() )..'/flags/'..string.lower(countryCode)..'.png'			if fileExists(sFlagImagePath) then				setElementData(uPlayer, "countryFlagImage", sFlagImagePath )			else				setElementData(uPlayer, "countryFlagImage", "??" )			end		end		setElementData(uPlayer, "Country", name )	endendaddEventHandler("onResourceStart", getResourceRootElement(getThisResource()), OnResourceStart)

No image flag

XlvKf69.jpg

 

Edited by No4NaMe
Link to comment
12 hours ago, No4NaMe said:

344 error loading image @ 'dxdrawimage'  N/A

local sw, sh = guiGetScreenSize()
local fps = getPlayerPing(getLocalPlayer())
ColumnName = {{ name = "", width = 100, data = function (element) return getPlayerName ( element) end },}
ColumnStats = { 
{ name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },
{ name = "Zombies", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },
{ name = "Alive", width = 100, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },
{ name = "Ping", width = 80, data = function (element) return getPlayerPing ( element, "ping" ) or 99 end },
{ name = "Country", width = 100, data = function (element) return getElementData ( element, "Country" ) or 'N/A' end },
 { name = "Flag", width = 100, data = function (element) return getElementData ( element, "Flag" ) or '??' end },
{ name = "Group", width = 100, data = function (element) return getElementData ( element, "Group" ) or "None" end },
}
local serverName = "Server"
local topsize = 60
local playersize = topsize-30
local panelsize = playersize*1
function calculateWidth()
	local width = 0
	for key, value in ipairs( ColumnName ) do
		width = width + value.width
	end
	for key, value in ipairs( ColumnStats ) do
		width = width + value.width
	end	
	return width + 60
end 
local max_players = 50
local ploff = 0
local width = calculateWidth()
local baseX = sw/2-width/2
local baseY = sh/2-(panelsize+topsize)/0.5
 
addEventHandler( "onClientRender", root,
function()
	if getKeyState( "tab" ) == false then ploff = 0; return end
	if getElementData(getLocalPlayer(),"logedin") then
		dxDrawRectangle ( baseX, baseY-40, width, topsize+10, tocolor(0, 0, 0, 80) )
		dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(0, 0, 0, 40) )		
		dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(255,255,255,60), 2.6, "bankgothic" )
		dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0, 0, 0, 40) )			
		dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100,50),0.8 )			
		local xoff = 60
		for i, v in ipairs ( ColumnName ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end			
		for i, v in ipairs ( ColumnStats ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end
		local playersTable = getElementsByType ( "player" )
		dxDrawText ( "Players:  "..tostring(#playersTable).."/"..tostring(max_players), baseX -550, baseY+60, baseX+width, baseY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )	
		local maxNum = #playersTable
		if maxNum > 10 then
			maxNum = 10
		end
		for i = 1, maxNum do
			dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(0, 0, 0, 40),0.5 )
			dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 1, "default-bold", "center", "center" )
			if playersTable[i+ploff] == localPlayer then
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 60) )
				else
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 30) )					
			end
			local xoff = 60		
			for c, d in ipairs ( ColumnName ) do
				local data = d.data(playersTable[i+ploff])
				--local r,g,b = 255,255,255,50
				dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
				for c, d in ipairs ( ColumnStats ) do
				local data = d.data(playersTable[i+ploff])
				local r,g,b = 255, 255, 255,255
				if d.name == "Group" and data == "None" then
					r,g,b = 249,41,0
					data = "None"
				end
          if d.name~='Flag' then
				dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
            else
            if data~='??'  then
          	  dxDrawImage ( baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, data )
              else
            	dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
            end
          end
				xoff = xoff+d.width
			end
		end
	end
end
)
function PlayerScrollMenu (key,keyState,arg)
	if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then
		if ( keyState == "down" ) then
			if arg == "up" then
				if ploff > 0 then
					ploff=ploff-1
				end
			elseif arg == "down" then
				local playersTable = getElementsByType ( "player" )
				if ploff < #playersTable-10 then
					ploff = ploff+1
				end
			end
		end
	end
end
bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )
function formatTimeFromMinutes(value)
	if value then
		local hours = math.floor(value/60)
		local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
		if hours then
		if hours == 0 then
		value = minutes.." min"
		end
		elseif hours >= 1 then
		value = hours.." ч	"..minutes.." min"
		end
		return value
	end
	return false
end
function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end
function sendMaxPlayersOnServer (players)
	max_players = players
end
addEvent("sendMaxPlayersOnServer",true)
addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

&

countryNames = {
    ["IT"]="Italy",
    ["MX"]="Mexico",
    ["SA"]="SAUDI ARBIA",
    ["PK"]="Pakistan",
    ["AF"]="Afghanistan",
    ["DZ"]="Algeria",
    ["AS"]="American samoa",
    ["AU"]="Australlia",
    ["AO"]="Anqola",
    ["AI"]="Anquilla",
    ["AQ"]="Antarctica",
    ["AG"]="Antigua and Barbuda",
    ["AR"]="Argentina",
    ["AM"]="Armenia",
    ["AW"]="Aruba",
    ["AT"]="Austria",
    ["AZ"]="Azerbaijan",
    ["BS"]="Bahamas",
    ["BH"]="Bahrain",
    ["BD"]="Bangladesh",
    ["BB"]="Barbados",
    ["BY"]="Belarus",
    ["BE"]="Belgium",
    ["BZ"]="Belize",
    ["BJ"]="Benin",
    ["BM"]="Bermuda",
    ["BT"]="Bhutan",
    ["BO"]="Bolivia",
    ["BA"]="Bosnia",
    ["BH"]="Herzegovina",
    ["BW"]="Botswana",
    ["BR"]="Brazil",
    ["IO"]="British Indian Ocean Territory",
    ["VG"]="British Virgin Islands",
    ["BN"]="Brunei",
    ["BG"]="Bulgaria",
    ["BF"]="Burkina Faso",
    ["MM"]="Burma (Myanmar)",
    ["BI"]="Burundi",
    ["KH"]="Cambodia",
    ["CM"]="Cameroon",
    ["CA"]="Canada",
    ["CV"]="Cape Verde",
    ["KY"]="Cayman Islands",
    ["CF"]="Central African Republic",
    ["TD"]="Chad",
    ["CL"]="Chile",
    ["CN"]="China",
    ["CX"]="Christmas Island",
    ["CC"]="Cocos (Keeling) Islands",
    ["CO"]="Colombia",
    ["KM"]="Comoros",
    ["CK"]="Cook Islands",
    ["CR"]="Costa Rica",
    ["HR"]="Croatia",
    ["CU"]="Cuba",
    ["CY"]="Cyprus",
    ["CZ"]="Czech Republic",
    ["CD"]="Democratic Republic of the Congo",
    ["DK"]="Denmark",
    ["DJ"]="Djibouti",
    ["DM"]="Dominica",
    ["DO"]="Dominican Republic",
    ["EC"]="Ecuador",
    ["SV"]="El Salvador",
    ["GQ"]="Equatorial Guinea",
    ["ER"]="Eritrea",
    ["EE"]="Estonia",
    ["ET"]="Ethiopia",
    ["FK"]="Falkland Islands",
    ["FO"]="Faroe Islands",
    ["FJ"]="Fiji",
    ["FI"]="Finland",
    ["FR"]="France",
    ["PF"]="French Polynesia",
    ["GA"]="Gabon",
    ["GM"]="Gambia",
    ["GE"]="Georgia",
    ["DE"]="Germany",
    ["GH"]="Ghana",
    ["GI"]="Gibraltar",
    ["GR"]="Greece",
    ["GL"]="Greenland",
    ["GD"]="Grenada",
    ["GU"]="Guam",
    ["GT"]="Guatemala",
    ["GN"]="Guinea",
    ["GW"]="Guinea-Bissau",
    ["GY"]="Guyana",
    ["HT"]="Haiti",
    ["VA"]="Holy See (Vatican City)",
    ["HN"]="Honduras",
    ["HK"]="Hong Kong",
    ["HU"]="Hungary",
    ["IS"]="Iceland",
    ["IN"]="India",
    ["ID"]="Indonesia",
    ["IR"]="Iran",
    ["IQ"]="Iraq",
    ["IE"]="Ireland",
    ["IM"]="Isle of Man",
    ["IL"]="Israel",
    ["IT"]="Italy",
    ["CI"]="Ivory Coast",
    ["JM"]="Jamaica",
    ["JP"]="Japan",
    ["JE"]="Jersey",
    ["JO"]="Jordan",
    ["KZ"]="Kazakhstan",
    ["KE"]="Kenya",
    ["KI"]="Kiribati",
    ["KO"]="Kosovo",
    ["KW"]="Kuwait",
    ["KG"]="Kyrgyzstan",
    ["LA"]="Laos",
    ["LV"]="Latvia",
    ["LB"]="Lebanon",
    ["LS"]="Lesotho",
    ["LR"]="Liberia",
    ["LY"]="Libya",
    ["LI"]="Liechtenstein",
    ["LT"]="Lithuania",
    ["LU"]="Luxembourg",
    ["MO"]="Macau",
    ["MK"]="Macedonia",
    ["MG"]="Madagascar",
    ["MW"]="Malawi",
    ["MY"]="Malaysia",
    ["MV"]="Maldives",
    ["ML"]="Mali",
    ["MT"]="Malta",
    ["MH"]="Marshall Islands",
    ["MR"]="Mauritania",
    ["MU"]="Mauritius",
    ["YT"]="Mayotte",
    ["MX"]="Mexico",
    ["FM"]="Micronesia",
    ["MD"]="Moldova",
    ["MC"]="Monaco",
    ["MN"]="Mongolia",
    ["ME"]="Montenegro",    
    ["MS"]="Montserrat",
    ["MA"]="Morocco",
    ["MZ"]="Mozambique",
    ["NA"]="Namibia",
    ["NR"]="Nauru",
    ["NP"]="Nepal",
    ["NL"]="Netherlands",
    ["AN"]="Netherlands Antilles",
    ["NC"]="New Caledonia",
    ["NZ"]="New Zealand",
    ["NI"]="Nicaragua",
    ["NE"]="Niger",
    ["NG"]="Nigeria",
    ["NU"]="Niue",
    ["NI"]="Norfolk Island",
    ["KP"]="North Korea",
    ["MP"]="Northern Mariana Islands",
    ["NO"]="Norway",
    ["OM"]="Oman",
    ["PK"]="Pakistan",
    ["PW"]="Palau",
    ["PA"]="Panama",
    ["PG"]="Papua New Guinea",
    ["PY"]="Paraguay",
    ["PE"]="Peru",
    ["PH"]="Philippines",
    ["PN"]="Pitcairn Islands",
    ["PL"]="Poland",
    ["PT"]="Portugal",
    ["PR"]="Puerto Rico",
    ["QA"]="Qatar",
    ["CG"]="Republic of the Congo",
    ["RO"]="Romania",
    ["RU"]="Russia",
    ["RW"]="Rwanda",
    ["BL"]="Saint Barthelemy",
    ["SH"]="Saint Helena",
    ["KN"]="Saint Kitts and Nevis",
    ["LC"]="Saint Lucia",
    ["MF"]="Saint Martin",
    ["PM"]="Saint Pierre and Miquelon",
    ["VC"]="Saint Vincent and the Grenadines",
    ["WS"]="Samoa",
    ["SM"]="San Marino",
    ["ST"]="Sao Tome and Principe",
    ["SA"]="Saudi Arabia",
    ["SN"]="Senegal",
    ["RS"]="Serbia",
    ["SC"]="Seychelles",
    ["SL"]="Sierra Leone",
    ["SG"]="Singapore",
    ["SK"]="Slovakia",
    ["SI"]="Slovenia",
    ["SB"]="Solomon Islands",
    ["SO"]="Somalia",
    ["ZA"]="South Africa",
    ["KR"]="South Korea",
    ["ES"]="Spain",
    ["LK"]="Sri Lanka",
    ["SD"]="Sudan",
    ["SR"]="Suriname",
    ["SJ"]="Svalbard",
    ["SZ"]="Swaziland",
    ["SE"]="Sweden",
    ["CH"]="Switzerland",
    ["SY"]="Syria",
    ["TW"]="Taiwan",
    ["TJ"]="Tajikistan",
    ["TZ"]="Tanzania",
    ["TH"]="Thailand",
    ["TL"]="Timor-Leste",
    ["TG"]="Togo",
    ["TK"]="Tokelau",
    ["TO"]="Tonga",
    ["TT"]="Trinidad and Tobago",
    ["TN"]="Tunisia",
    ["TR"]="Turkey",
    ["TM"]="Turkmenistan",
    ["TC"]="Turks and Caicos Islands",
    ["TV"]="Tuvalu",
    ["UG"]="Uganda",
    ["UA"]="Ukraine",
    ["AE"]="United Arab Emirates",
    ["GB"]="United Kingdom",
    ["US"]="United States",
    ["UY"]="Uruguay",
    ["VI"]="US Virgin Islands",
    ["UZ"]="Uzbekistan",
    ["VU"]="Vanuatu",
    ["VE"]="Venezuela",
    ["VN"]="Vietnam",
    ["WF"]="Wallis and Futuna",
    ["WB"]="West Bank",
    ["EH"]="Western Sahara",
    ["YE"]="Yemen",
    ["ZM"]="Zambia",
    ["ZW"]="Zimbabwe"
}
function OnResourceStart()
    local tPlayers = getElementsByType('player')
    for _,uPlayer in ipairs(tPlayers) do
		local countryCode = exports["admin"]:getPlayerCountry(uPlayer)
		local name = "Unknown"
			
		if countryCode and countryNames[countryCode] then
			name = countryNames[tostring(countryCode)]
			
			local sFlagImagePath = ':'..getResourceName( getThisResource() )..'/flags/'..string.lower(countryCode)..'.png'
			if fileExists(sFlagImagePath) then
				setElementData(uPlayer, "Flag", sFlagImagePath )
			else
				setElementData(uPlayer, "Flag", "??" )
			end
		end
		setElementData(uPlayer, "Country", name )
	end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), OnResourceStart)

test it and tell me the result

Edited by Master_MTA
Link to comment
41 minutes ago, Master_MTA said:

local sw, sh = guiGetScreenSize()
local fps = getPlayerPing(getLocalPlayer())
ColumnName = {{ name = "", width = 100, data = function (element) return getPlayerName ( element) end },}
ColumnStats = { 
{ name = "Murders", width = 100, data = function (element) return ( getElementData ( element, "murders" ) or 0 ) end },
{ name = "Zombies", width = 100, data = function (element) return ( getElementData ( element, "zombieskilled" ) or 0 ) end },
{ name = "Alive", width = 100, data = function (element) return formatTimeFromMinutes(getElementData ( element, "alivetime" ) or 1 ) end },
{ name = "Ping", width = 80, data = function (element) return getPlayerPing ( element, "ping" ) or 99 end },
{ name = "Country", width = 100, data = function (element) return getElementData ( element, "Country" ) or 'N/A' end },
 { name = "Flag", width = 100, data = function (element) return getElementData ( element, "Flag" ) or '??' end },
{ name = "Group", width = 100, data = function (element) return getElementData ( element, "Group" ) or "None" end },
}
local serverName = "Server"
local topsize = 60
local playersize = topsize-30
local panelsize = playersize*1
function calculateWidth()
	local width = 0
	for key, value in ipairs( ColumnName ) do
		width = width + value.width
	end
	for key, value in ipairs( ColumnStats ) do
		width = width + value.width
	end	
	return width + 60
end 
local max_players = 50
local ploff = 0
local width = calculateWidth()
local baseX = sw/2-width/2
local baseY = sh/2-(panelsize+topsize)/0.5
 
addEventHandler( "onClientRender", root,
function()
	if getKeyState( "tab" ) == false then ploff = 0; return end
	if getElementData(getLocalPlayer(),"logedin") then
		dxDrawRectangle ( baseX, baseY-40, width, topsize+10, tocolor(0, 0, 0, 80) )
		dxDrawRectangle ( baseX, baseY-40, width, topsize+40, tocolor(0, 0, 0, 40) )		
		dxDrawText ( serverName, baseX+53, baseY-45, baseX+width, baseY+topsize, tocolor(255,255,255,60), 2.6, "bankgothic" )
		dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0, 0, 0, 40) )			
		dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100,50),0.8 )			
		local xoff = 60
		for i, v in ipairs ( ColumnName ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+70, baseX+xoff+v.width+10, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end			
		for i, v in ipairs ( ColumnStats ) do
			dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize, tocolor(100,100,100),0.9 )
			dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )
			xoff = xoff+v.width
		end
		local playersTable = getElementsByType ( "player" )
		dxDrawText ( "Players:  "..tostring(#playersTable).."/"..tostring(max_players), baseX -550, baseY+60, baseX+width, baseY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center" )	
		local maxNum = #playersTable
		if maxNum > 10 then
			maxNum = 10
		end
		for i = 1, maxNum do
			dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(0, 0, 0, 40),0.5 )
			dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+25, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 1, "default-bold", "center", "center" )
			if playersTable[i+ploff] == localPlayer then
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 60) )
				else
				dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(0, 0, 0, 30) )					
			end
			local xoff = 60		
			for c, d in ipairs ( ColumnName ) do
				local data = d.data(playersTable[i+ploff])
				--local r,g,b = 255,255,255,50
				dxDrawText ( data, baseX+xoff-40, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-10, baseY+topsize+playersize*i, tocolor(255, 255, 255,255), 0.9, "default-bold", "center", "center" )
				xoff = xoff+d.width
			end
				for c, d in ipairs ( ColumnStats ) do
				local data = d.data(playersTable[i+ploff])
				local r,g,b = 255, 255, 255,255
				if d.name == "Group" and data == "None" then
					r,g,b = 249,41,0
					data = "None"
				end
          if d.name~='Flag' then
				dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
            else
            if data~='??'  then
          	  dxDrawImage ( baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, data )
              else
            	dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width-5, baseY+topsize+playersize*i, tocolor(r,g,b), 0.9, "default-bold", "center", "center" )
            end
          end
				xoff = xoff+d.width
			end
		end
	end
end
)
function PlayerScrollMenu (key,keyState,arg)
	if getElementData(localPlayer,"logedin") and getKeyState( "F4" ) then
		if ( keyState == "down" ) then
			if arg == "up" then
				if ploff > 0 then
					ploff=ploff-1
				end
			elseif arg == "down" then
				local playersTable = getElementsByType ( "player" )
				if ploff < #playersTable-10 then
					ploff = ploff+1
				end
			end
		end
	end
end
bindKey ( "mouse_wheel_up", "down", PlayerScrollMenu, "up" )
bindKey ( "mouse_wheel_down", "down", PlayerScrollMenu, "down" )
function formatTimeFromMinutes(value)
	if value then
		local hours = math.floor(value/60)
		local minutes = math.round(((value/60) - math.floor(value/60))*100/(100/60))
		if hours then
		if hours == 0 then
		value = minutes.." min"
		end
		elseif hours >= 1 then
		value = hours.." ч	"..minutes.." min"
		end
		return value
	end
	return false
end
function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end
function sendMaxPlayersOnServer (players)
	max_players = players
end
addEvent("sendMaxPlayersOnServer",true)
addEventHandler("sendMaxPlayersOnServer",getLocalPlayer(),sendMaxPlayersOnServer)

&


countryNames = {
    ["IT"]="Italy",
    ["MX"]="Mexico",
    ["SA"]="SAUDI ARBIA",
    ["PK"]="Pakistan",
    ["AF"]="Afghanistan",
    ["DZ"]="Algeria",
    ["AS"]="American samoa",
    ["AU"]="Australlia",
    ["AO"]="Anqola",
    ["AI"]="Anquilla",
    ["AQ"]="Antarctica",
    ["AG"]="Antigua and Barbuda",
    ["AR"]="Argentina",
    ["AM"]="Armenia",
    ["AW"]="Aruba",
    ["AT"]="Austria",
    ["AZ"]="Azerbaijan",
    ["BS"]="Bahamas",
    ["BH"]="Bahrain",
    ["BD"]="Bangladesh",
    ["BB"]="Barbados",
    ["BY"]="Belarus",
    ["BE"]="Belgium",
    ["BZ"]="Belize",
    ["BJ"]="Benin",
    ["BM"]="Bermuda",
    ["BT"]="Bhutan",
    ["BO"]="Bolivia",
    ["BA"]="Bosnia",
    ["BH"]="Herzegovina",
    ["BW"]="Botswana",
    ["BR"]="Brazil",
    ["IO"]="British Indian Ocean Territory",
    ["VG"]="British Virgin Islands",
    ["BN"]="Brunei",
    ["BG"]="Bulgaria",
    ["BF"]="Burkina Faso",
    ["MM"]="Burma (Myanmar)",
    ["BI"]="Burundi",
    ["KH"]="Cambodia",
    ["CM"]="Cameroon",
    ["CA"]="Canada",
    ["CV"]="Cape Verde",
    ["KY"]="Cayman Islands",
    ["CF"]="Central African Republic",
    ["TD"]="Chad",
    ["CL"]="Chile",
    ["CN"]="China",
    ["CX"]="Christmas Island",
    ["CC"]="Cocos (Keeling) Islands",
    ["CO"]="Colombia",
    ["KM"]="Comoros",
    ["CK"]="Cook Islands",
    ["CR"]="Costa Rica",
    ["HR"]="Croatia",
    ["CU"]="Cuba",
    ["CY"]="Cyprus",
    ["CZ"]="Czech Republic",
    ["CD"]="Democratic Republic of the Congo",
    ["DK"]="Denmark",
    ["DJ"]="Djibouti",
    ["DM"]="Dominica",
    ["DO"]="Dominican Republic",
    ["EC"]="Ecuador",
    ["SV"]="El Salvador",
    ["GQ"]="Equatorial Guinea",
    ["ER"]="Eritrea",
    ["EE"]="Estonia",
    ["ET"]="Ethiopia",
    ["FK"]="Falkland Islands",
    ["FO"]="Faroe Islands",
    ["FJ"]="Fiji",
    ["FI"]="Finland",
    ["FR"]="France",
    ["PF"]="French Polynesia",
    ["GA"]="Gabon",
    ["GM"]="Gambia",
    ["GE"]="Georgia",
    ["DE"]="Germany",
    ["GH"]="Ghana",
    ["GI"]="Gibraltar",
    ["GR"]="Greece",
    ["GL"]="Greenland",
    ["GD"]="Grenada",
    ["GU"]="Guam",
    ["GT"]="Guatemala",
    ["GN"]="Guinea",
    ["GW"]="Guinea-Bissau",
    ["GY"]="Guyana",
    ["HT"]="Haiti",
    ["VA"]="Holy See (Vatican City)",
    ["HN"]="Honduras",
    ["HK"]="Hong Kong",
    ["HU"]="Hungary",
    ["IS"]="Iceland",
    ["IN"]="India",
    ["ID"]="Indonesia",
    ["IR"]="Iran",
    ["IQ"]="Iraq",
    ["IE"]="Ireland",
    ["IM"]="Isle of Man",
    ["IL"]="Israel",
    ["IT"]="Italy",
    ["CI"]="Ivory Coast",
    ["JM"]="Jamaica",
    ["JP"]="Japan",
    ["JE"]="Jersey",
    ["JO"]="Jordan",
    ["KZ"]="Kazakhstan",
    ["KE"]="Kenya",
    ["KI"]="Kiribati",
    ["KO"]="Kosovo",
    ["KW"]="Kuwait",
    ["KG"]="Kyrgyzstan",
    ["LA"]="Laos",
    ["LV"]="Latvia",
    ["LB"]="Lebanon",
    ["LS"]="Lesotho",
    ["LR"]="Liberia",
    ["LY"]="Libya",
    ["LI"]="Liechtenstein",
    ["LT"]="Lithuania",
    ["LU"]="Luxembourg",
    ["MO"]="Macau",
    ["MK"]="Macedonia",
    ["MG"]="Madagascar",
    ["MW"]="Malawi",
    ["MY"]="Malaysia",
    ["MV"]="Maldives",
    ["ML"]="Mali",
    ["MT"]="Malta",
    ["MH"]="Marshall Islands",
    ["MR"]="Mauritania",
    ["MU"]="Mauritius",
    ["YT"]="Mayotte",
    ["MX"]="Mexico",
    ["FM"]="Micronesia",
    ["MD"]="Moldova",
    ["MC"]="Monaco",
    ["MN"]="Mongolia",
    ["ME"]="Montenegro",    
    ["MS"]="Montserrat",
    ["MA"]="Morocco",
    ["MZ"]="Mozambique",
    ["NA"]="Namibia",
    ["NR"]="Nauru",
    ["NP"]="Nepal",
    ["NL"]="Netherlands",
    ["AN"]="Netherlands Antilles",
    ["NC"]="New Caledonia",
    ["NZ"]="New Zealand",
    ["NI"]="Nicaragua",
    ["NE"]="Niger",
    ["NG"]="Nigeria",
    ["NU"]="Niue",
    ["NI"]="Norfolk Island",
    ["KP"]="North Korea",
    ["MP"]="Northern Mariana Islands",
    ["NO"]="Norway",
    ["OM"]="Oman",
    ["PK"]="Pakistan",
    ["PW"]="Palau",
    ["PA"]="Panama",
    ["PG"]="Papua New Guinea",
    ["PY"]="Paraguay",
    ["PE"]="Peru",
    ["PH"]="Philippines",
    ["PN"]="Pitcairn Islands",
    ["PL"]="Poland",
    ["PT"]="Portugal",
    ["PR"]="Puerto Rico",
    ["QA"]="Qatar",
    ["CG"]="Republic of the Congo",
    ["RO"]="Romania",
    ["RU"]="Russia",
    ["RW"]="Rwanda",
    ["BL"]="Saint Barthelemy",
    ["SH"]="Saint Helena",
    ["KN"]="Saint Kitts and Nevis",
    ["LC"]="Saint Lucia",
    ["MF"]="Saint Martin",
    ["PM"]="Saint Pierre and Miquelon",
    ["VC"]="Saint Vincent and the Grenadines",
    ["WS"]="Samoa",
    ["SM"]="San Marino",
    ["ST"]="Sao Tome and Principe",
    ["SA"]="Saudi Arabia",
    ["SN"]="Senegal",
    ["RS"]="Serbia",
    ["SC"]="Seychelles",
    ["SL"]="Sierra Leone",
    ["SG"]="Singapore",
    ["SK"]="Slovakia",
    ["SI"]="Slovenia",
    ["SB"]="Solomon Islands",
    ["SO"]="Somalia",
    ["ZA"]="South Africa",
    ["KR"]="South Korea",
    ["ES"]="Spain",
    ["LK"]="Sri Lanka",
    ["SD"]="Sudan",
    ["SR"]="Suriname",
    ["SJ"]="Svalbard",
    ["SZ"]="Swaziland",
    ["SE"]="Sweden",
    ["CH"]="Switzerland",
    ["SY"]="Syria",
    ["TW"]="Taiwan",
    ["TJ"]="Tajikistan",
    ["TZ"]="Tanzania",
    ["TH"]="Thailand",
    ["TL"]="Timor-Leste",
    ["TG"]="Togo",
    ["TK"]="Tokelau",
    ["TO"]="Tonga",
    ["TT"]="Trinidad and Tobago",
    ["TN"]="Tunisia",
    ["TR"]="Turkey",
    ["TM"]="Turkmenistan",
    ["TC"]="Turks and Caicos Islands",
    ["TV"]="Tuvalu",
    ["UG"]="Uganda",
    ["UA"]="Ukraine",
    ["AE"]="United Arab Emirates",
    ["GB"]="United Kingdom",
    ["US"]="United States",
    ["UY"]="Uruguay",
    ["VI"]="US Virgin Islands",
    ["UZ"]="Uzbekistan",
    ["VU"]="Vanuatu",
    ["VE"]="Venezuela",
    ["VN"]="Vietnam",
    ["WF"]="Wallis and Futuna",
    ["WB"]="West Bank",
    ["EH"]="Western Sahara",
    ["YE"]="Yemen",
    ["ZM"]="Zambia",
    ["ZW"]="Zimbabwe"
}
function OnResourceStart()
    local tPlayers = getElementsByType('player')
    for _,uPlayer in ipairs(tPlayers) do
		local countryCode = exports["admin"]:getPlayerCountry(uPlayer)
		local name = "Unknown"
			
		if countryCode and countryNames[countryCode] then
			name = countryNames[tostring(countryCode)]
			
			local sFlagImagePath = ':'..getResourceName( getThisResource() )..'/flags/'..string.lower(countryCode)..'.png'
			if fileExists(sFlagImagePath) then
				setElementData(uPlayer, "Flag", sFlagImagePath )
			else
				setElementData(uPlayer, "Flag", "??" )
			end
		end
		setElementData(uPlayer, "Country", name )
	end
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), OnResourceStart)

test it and tell me the result

no display image flag and text display "??"

Link to comment
exports["scoreboard"]:addScoreboardColumn( "Country", getRootElement() , 5, 140, "Country")

function showcountry()
local flag = exports.admin:getPlayerCountry ( source )
local ip = getPlayerIP( source )
local serial = getPlayerSerial(source)
local random = math.random(2,9)
    if flag then
        setElementData(source,"",":flags/"..flag..".png")
    else
        flag = "N/A"
    end
end
addEventHandler("onPlayerJoin",getRootElement(), showcountry)


------------CHECK COUNTRY ------------------
countryNames = {
    ['AD'] = 'Andorra',
    ['AE'] = 'United Arab Emirates',
    ['AF'] = 'Afghanistan',
    ['AG'] = 'Antigua & Barbuda',
    ['AI'] = 'Anguilla',
    ['AL'] = 'Albania',
    ['AM'] = 'Armenia',
    ['AN'] = 'Netherlands Antilles',
    ['AO'] = 'Angola',
    ['AQ'] = 'Antarctica',
    ['AR'] = 'Argentina',
    ['AS'] = 'American Samoa',
    ['AT'] = 'Austria',
    ['AU'] = 'Australia',
    ['AW'] = 'Aruba',
    ['AZ'] = 'Azerbaijan',
    ['BA'] = 'Bosnia and Herzegovina',
    ['BB'] = 'Barbados',
    ['BD'] = 'Bangladesh',
    ['BE'] = 'Belgium',
    ['BF'] = 'Burkina Faso',
    ['BG'] = 'Bulgaria',
    ['BH'] = 'Bahrain',
    ['BI'] = 'Burundi',
    ['BJ'] = 'Benin',
    ['BM'] = 'Bermuda',
    ['BN'] = 'Brunei Darussalam',
    ['BO'] = 'Bolivia',
    ['BR'] = 'Brazil',
    ['BS'] = 'Bahama',
    ['BT'] = 'Bhutan',
    ['BU'] = 'Burma',
    ['BV'] = 'Bouvet Island',
    ['BW'] = 'Botswana',
    ['BY'] = 'Belarus',
    ['BZ'] = 'Belize',
    ['CA'] = 'Canada',
    ['CC'] = 'Cocos (Keeling) Islands',
    ['CF'] = 'Central African Republic',
    ['CG'] = 'Congo',
    ['CH'] = 'Switzerland',
    ['CI'] = "C“te D'ivoire (Ivory Coast)",
    ['CK'] = 'Cook Iislands',
    ['CL'] = 'Chile',
    ['CM'] = 'Cameroon',
    ['CN'] = 'China',
    ['CO'] = 'Colombia',
    ['CR'] = 'Costa Rica',
    ['CS'] = 'Czechoslovakia',
    ['CU'] = 'Cuba',
    ['CV'] = 'Cape Verde',
    ['CX'] = 'Christmas Island',
    ['CY'] = 'Cyprus',
    ['CZ'] = 'Czech Republic',
    ['DD'] = 'German Democratic Republic',
    ['DE'] = 'Germany',
    ['DJ'] = 'Djibouti',
    ['DK'] = 'Denmark',
    ['DM'] = 'Dominica',
    ['DO'] = 'Dominican Republic',
    ['DZ'] = 'Algeria',
    ['EC'] = 'Ecuador',
    ['EE'] = 'Estonia',
    ['EG'] = 'Egypt',
    ['EH'] = 'Western Sahara',
    ['ER'] = 'Eritrea',
    ['ES'] = 'Spain',
    ['ET'] = 'Ethiopia',
    ['FI'] = 'Finland',
    ['FJ'] = 'Fiji',
    ['FK'] = 'Falkland Islands (Malvinas)',
    ['FM'] = 'Micronesia',
    ['FO'] = 'Faroe Islands',
    ['FR'] = 'France',
    ['FX'] = '"France, Metropolitan"',
    ['GA'] = 'Gabon',
    ['GB'] = 'United Kingdom',
    ['GD'] = 'Grenada',
    ['GE'] = 'Georgia',
    ['GF'] = 'French Guiana',
    ['GH'] = 'Ghana',
    ['GI'] = 'Gibraltar',
    ['GL'] = 'Greenland',
    ['GM'] = 'Gambia',
    ['GN'] = 'Guinea',
    ['GP'] = 'Guadeloupe',
    ['GQ'] = 'Equatorial Guinea',
    ['GR'] = 'Greece',
    ['GS'] = 'South Georgia and the South Sandwich Islands',
    ['GT'] = 'Guatemala',
    ['GU'] = 'Guam',
    ['GW'] = 'Guinea-Bissau',
    ['GY'] = 'Guyana',
    ['HK'] = 'Hong Kong',
    ['HM'] = 'Heard & McDonald Islands',
    ['HN'] = 'Honduras',
    ['HR'] = 'Croatia',
    ['HT'] = 'Haiti',
    ['HU'] = 'Hungary',
    ['ID'] = 'Indonesia',
    ['IE'] = 'Ireland',
    ['IL'] = 'Israel',
    ['IN'] = 'India',
    ['IO'] = 'British Indian Ocean Territory',
    ['IQ'] = 'Iraq',
    ['IR'] = 'Islamic Republic of Iran',
    ['IS'] = 'Iceland',
    ['IT'] = 'Italy',
    ['JM'] = 'Jamaica',
    ['JO'] = 'Jordan',
    ['JP'] = 'Japan',
    ['KE'] = 'Kenya',
    ['KG'] = 'Kyrgyzstan',
    ['KH'] = 'Cambodia',
    ['KI'] = 'Kiribati',
    ['KM'] = 'Comoros',
    ['KN'] = 'St. Kitts and Nevis',
    ['KP'] = "Korea, Democratic People's Republic of'",
    ['KR'] = '"Korea, Republic of"',
    ['KW'] = 'Kuwait',
    ['KY'] = 'Cayman Islands',
    ['KZ'] = 'Kazakhstan',
    ['LA'] = "Lao People's Democratic Republic",
    ['LB'] = 'Lebanon',
    ['LC'] = 'Saint Lucia',
    ['LI'] = 'Liechtenstein',
    ['LK'] = 'Sri Lanka',
    ['LR'] = 'Liberia',
    ['LS'] = 'Lesotho',
    ['LT'] = 'Lithuania',
    ['LU'] = 'Luxembourg',
    ['LV'] = 'Latvia',
    ['LY'] = 'Libyan Arab Jamahiriya',
    ['MA'] = 'Morocco',
    ['MC'] = 'Monaco',
    ['MD'] = '"Moldova, Republic of"',
    ['MG'] = 'Madagascar',
    ['MH'] = 'Marshall Islands',
    ['ML'] = 'Mali',
    ['MM'] = 'Myanmar',
    ['MN'] = 'Mongolia',
    ['MO'] = 'Macau',
    ['MP'] = 'Northern Mariana Islands',
    ['MQ'] = 'Martinique',
    ['MR'] = 'Mauritania',
    ['MS'] = 'Monserrat',
    ['MT'] = 'Malta',
    ['MU'] = 'Mauritius',
    ['MV'] = 'Maldives',
    ['MW'] = 'Malawi',
    ['MX'] = 'Mexico',
    ['MY'] = 'Malaysia',
    ['MZ'] = 'Mozambique',
    ['NA'] = 'Nambia',
    ['NC'] = 'New Caledonia',
    ['NE'] = 'Niger',
    ['NF'] = 'Norfolk Island',
    ['NG'] = 'Nigeria',
    ['NI'] = 'Nicaragua',
    ['NL'] = 'Netherlands',
    ['NO'] = 'Norway',
    ['NP'] = 'Nepal',
    ['NR'] = 'Nauru',
    ['NT'] = 'Neutral Zone',
    ['NU'] = 'Niue',
    ['NZ'] = 'New Zealand',
    ['OM'] = 'Oman',
    ['PA'] = 'Panama',
    ['PE'] = 'Peru',
    ['PF'] = 'French Polynesia',
    ['PG'] = 'Papua New Guinea',
    ['PH'] = 'Philippines',
    ['PK'] = 'Pakistan',
    ['PL'] = 'Poland',
    ['PM'] = 'St. Pierre & Miquelon',
    ['PN'] = 'Pitcairn',
    ['PR'] = 'Puerto Rico',
    ['PT'] = 'Portugal',
    ['PW'] = 'Palau',
    ['PY'] = 'Paraguay',
    ['QA'] = 'Qatar',
    ['RE'] = 'R‚union',
    ['RO'] = 'Romania',
    ['RU'] = 'Russian Federation',
    ['RW'] = 'Rwanda',
    ['SA'] = 'Saudi Arabia',
    ['SB'] = 'Solomon Islands',
    ['SC'] = 'Seychelles',
    ['SD'] = 'Sudan',
    ['SE'] = 'Sweden',
    ['SG'] = 'Singapore',
    ['SH'] = 'St. Helena',
    ['SI'] = 'Slovenia',
    ['SJ'] = 'Svalbard & Jan Mayen Islands',
    ['SK'] = 'Slovakia',
    ['SL'] = 'Sierra Leone',
    ['SM'] = 'San Marino',
    ['SN'] = 'Senegal',
    ['SO'] = 'Somalia',
    ['SR'] = 'Suriname',
    ['ST'] = 'Sao Tome & Principe',
    ['SU'] = 'Union of Soviet Socialist Republics (no longer exi',
    ['SV'] = 'El Salvador',
    ['SY'] = 'Syrian Arab Republic',
    ['SZ'] = 'Swaziland',
    ['TC'] = 'Turks & Caicos Islands',
    ['TD'] = 'Chad',
    ['TF'] = 'French Southern Territories',
    ['TG'] = 'Togo',
    ['TH'] = 'Thailand',
    ['TJ'] = 'Tajikistan',
    ['TK'] = 'Tokelau',
    ['TM'] = 'Turkmenistan',
    ['TN'] = 'Tunisia',
    ['TO'] = 'Tonga',
    ['TP'] = 'East Timor',
    ['TR'] = 'Turkey',
    ['TT'] = 'Trinidad & Tobago',
    ['TV'] = 'Tuvalu',
    ['TW'] = '"Taiwan, Province of China"',
    ['TZ'] = '"Tanzania, United Republic of"',
    ['UA'] = 'Ukraine',
    ['UG'] = 'Uganda',
    ['UM'] = 'United States Minor Outlying Islands',
    ['US'] = 'United States of America',
    ['UY'] = 'Uruguay',
    ['UZ'] = 'Uzbekistan',
    ['VA'] = 'Vatican City State (Holy See)',
    ['VC'] = 'St. Vincent & the Grenadines',
    ['VE'] = 'Venezuela',
    ['VG'] = 'British Virgin Islands',
    ['VI'] = 'United States Virgin Islands',
    ['VN'] = 'Viet Nam',
    ['VU'] = 'Vanuatu',
    ['WF'] = 'Wallis & Futuna Islands',
    ['WS'] = 'Samoa',
    ['YD'] = 'Democratic Yemen',
    ['YE'] = 'Yemen',
    ['YT'] = 'Mayotte',
    ['YU'] = 'Yugoslavia',
    ['ZA'] = 'South Africa',
    ['ZM'] = 'Zambia',
    ['ZR'] = 'Zaire',
    ['ZW'] = 'Zimbabwe',
    ['PS'] = 'Palestine',
        ['RS'] = 'Serbia',
        ['ME'] = 'Montenegro',
        ['MK'] = 'Macedonia',
    ['Unknown'] = 'Unknown'
    }
 
 
addEventHandler("onPlayerJoin", getRootElement(),
function()
local country = exports['admin']:getPlayerCountry(source)
local ip = getPlayerIP( source )
local serial = getPlayerSerial(source)
    if country then
        local thecountry = countryNames[country]
        setElementData(source, "Country", thecountry)
    else
        country = "Unknown"--setElementData(source, "Country", "UNKNW")
    end
end

 

Edited by [MTA]Weed
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...