EugenMForelli Posted July 27, 2019 Share Posted July 27, 2019 https://imgur.com/a/BHckHzc Why my country does wont display? I also have all country flags + flag folder. function onCountryStart() for i,thePlayer in pairs(getElementsByType("player")) do getPlayerCountry(thePlayer) end end addEventHandler("onResourceStart",resourceRoot,onCountryStart) function getPlayerCountry(thePlayer) if thePlayer then local playerIP = getPlayerIP(thePlayer) if playerIP then fetchRemote("http://www.geoplugin.net/json.gp?ip="..playerIP, setPlayerCountry, "", false, thePlayer ) end end end function setPlayerCountry(countryTable,errorCode,thePlayer) if thePlayer and countryTable and errorCode == 0 then local countryTable = fromJSON("["..countryTable.."]") if countryTable then setElementData(thePlayer,"country",countryTable.geoplugin_countryCode) setElementData(thePlayer,"countryName",countryTable.geoplugin_countryName) end end end function onPlayerJoinGetCountry() getPlayerCountry(source) end onPlayerJoinGetCountry() addEventHandler("onPlayerJoin",root,onPlayerJoinGetCountry) local ids = {} function assignID() for i=1,getMaxPlayers() do if not ids[i] then ids[i] = source setElementData(source,"id",i) break end end end addEventHandler("onPlayerJoin",root,assignID) function startup() ids = {} for k, v in ipairs(getElementsByType("player")) do local id = setElementData(v,"id",k) ids[k] = v end end addEventHandler("onResourceStart",resourceRoot,startup) function freeID() local id = getElementData(source,"id") if not id then return end ids[id] = nil end addEventHandler("onPlayerQuit",root,freeID) addEvent("getMaxPlayer",true) addEventHandler("getMaxPlayer",root, function (player) max = getMaxPlayers() triggerClientEvent(player,"getMaxPlayers",root,max) end ) Where is the error? Link to comment
' A F . Posted July 27, 2019 Share Posted July 27, 2019 put your scoreboard client code 1 Link to comment
EugenMForelli Posted July 27, 2019 Author Share Posted July 27, 2019 outputDebugString("scoreboard ligado") sX,sY = guiGetScreenSize() sor = dxCreateFont("font.ttf",14) or "arial" font = dxCreateFont("font_.ttf",17) or "arial" maxPlayer = "nil" function _dxText(text,x,y,w,h,red,green,blue,alpha,scale,font,a,b,c,d,e,f) dxDrawText(string.gsub(text,"(#%x%x%x%x%x%x)",""),x+1,y+1,w+1,h+1,tocolor(0,0,0,alpha),scale,font,a,b,c,d,e,f) dxDrawText(text,x,y,w,h,tocolor(red,green,blue,alpha),scale,font,a,b,c,d,e,f) end function dxDrawRecLine(x,y,w,h,color) dxDrawRectangle(x,y,w,1,color) -- h dxDrawRectangle(x,y+h,w,1,color) -- h dxDrawRectangle(x,y,1,h,color) -- v dxDrawRectangle(x+w-1,y,1,h,color) -- v end function dxDrawRectangleRounded(x,y,w,h,tocolor) dxDrawRectangle(x,y,w,h,tocolor) dxDrawRectangle(x+1,y-1,w-2,1,tocolor) dxDrawRectangle(x+1,y+h,w-2,1,tocolor) dxDrawRectangle(x+w,y+1,1,h-2,tocolor) dxDrawRectangle(x-1,y+1,1,h-2,tocolor) end scoreboard = {} function playersShow() scoreboard = {} for i,player in ipairs(getElementsByType("player")) do if not getPlayerTeam(player) then table.insert(scoreboard,{"player",player}) end end for i,team in ipairs(getElementsByType("team")) do if (tonumber(countPlayersInTeam(team))>=1) then table.insert(scoreboard,{"teamName",team}) for i,playerTeam in ipairs (getPlayersInTeam(team)) do table.insert(scoreboard,{"player",playerTeam}) end end end end rowNow = 0 rowsCount = math.floor(sY/22)-6 function drawScoreboard() playersShow() count = math.min(#scoreboard,rowsCount) local x = sX/2 - 320 local y = sY/2 - count*20 / 2 local cx, cy = 0,0 if isCursorShowing() then cx, cy = getCursorPosition() cx = cx * sX cy = cy * sY end showCursor(getKeyState("mouse2")) dxDrawRectangleRounded(x,y-52,640,count*22+52,tocolor(0,0,0,255)) dxDrawRectangleRounded(x,y-22,640,20,tocolor(0,0,0,200)) _dxText("uW' United Warriors",x+10,y-51,sX,sY,255,255,255,255,1,font,"left","top",true,false,false,false) _dxText(#getElementsByType("player").." / "..maxPlayer,x,y-50,x+632,y-28,255,255,255,255,1,font,"right","center",true,false,false,false) _dxText("Ping",x,y-22,x+35,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("Name",x+40,y-22,sX,y,255,255,255,255,1,"arial","left","center",true,false,false,false) _dxText("Country",x+178,y-22,x+244,y,255,255,255,255,1,"arial","left","center",true,false,false,false) _dxText("Money",x+244,y-22,x+310,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("Points",x+310,y-22,x+376,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("Rank",x+376,y-22,x+442,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("State",x+442,y-22,x+508,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("FPS",x+508,y-22,x+574,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("ID",x+574,y-22,x+640,y,255,255,255,255,1,"arial","center","center",true,false,false,false) for i=1,count do posY = y+(i-1)*22 if scoreboard[i+rowNow][1] == "player" then if scoreboard[i+rowNow][2] == localPlayer then dxDrawRectangleRounded(x,posY,640,22,tocolor(255,255,255,15)) end if isCursorShowing() and cx > x and cx < x + 640 and cy > posY and cy < posY + 22 then dxDrawRectangleRounded(x,posY,640,22,tocolor(255,255,255,20)) end _dxText(getElementData(scoreboard[i+rowNow][2],"id")or"?",x+574,posY,x+640,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) if getElementData(scoreboard[i+rowNow][2],"AFK") then afk="#FF0000AFK " else afk="" end _dxText(afk.._getPlayerName(scoreboard[i+rowNow][2]),x+40,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",false,false,false,true) country = getElementData(scoreboard[i+rowNow][2],"country") or "?" if country == "" then country = "?" end _dxText(string.upper(country),x+204,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",true,false,false,false) if country == "?" then country = "World" end if country and fileExists("flags/"..country..".png") then dxDrawImage(x+184,posY+2,16,16,"flags/"..country..".png",0,0,0,tocolor(255,255,255,255)) end _dxText(getElementData(scoreboard[i+rowNow][2],"Cash")or"Guest",x+244,posY,x+310,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"Points")or"Guest",x+310,posY,x+376,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"Rank")or"Guest",x+376,posY,x+442,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"state")or"?",x+442,posY,x+508,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"FPS")or"?",x+508,posY,x+574,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getPlayerPing(scoreboard[i+rowNow][2]),x,posY,x+35,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) end if scoreboard[i+rowNow][1] == "teamName" then dxDrawRectangleRounded(x,posY,640,20,tocolor(r,g,b,50)) r,g,b = getTeamColor(scoreboard[i+rowNow][2]) _dxText(getTeamName(scoreboard[i+rowNow][2]),x+280,posY,sX,posY+22,r,g,b,255,1,"default-bold","left","center",false,false,false,true) end end if rowsCount < #scoreboard then size = rowsCount*22 _size = size/#scoreboard __size = _size*rowsCount dxDrawRectangleRounded(x+630,y,10,size,tocolor(255,255,255,20)) dxDrawRectangleRounded(x+630,y+rowNow*_size,10,__size,tocolor(0,0,0,180)) end end bindKey("tab","down", function() addEventHandler("onClientRender",root,drawScoreboard) end ) bindKey("tab","up", function() removeEventHandler("onClientRender",root,drawScoreboard) if isCursorShowing() then showCursor(false) end end ) addEventHandler("onClientMinimize",root, function() setElementData(localPlayer,"AFK",true) end ) addEventHandler("onClientRestore",root, function() setElementData(localPlayer,"AFK",false) end ) bindKey("mouse_wheel_down","down", function() if rowNow == 0 then return end rowNow = rowNow - 1 end ) bindKey("mouse_wheel_up","down", function() maxIndex = #scoreboard - rowsCount if #scoreboard < rowsCount then return end if rowNow == maxIndex then return end rowNow = rowNow + 1 end ) addEventHandler("onClientRender",root, function() if not fps then fps = 0 end fps = fps + 1 if not fpstick then fpstick = getTickCount() end fpscountertick = getTickCount() if fpscountertick - fpstick >= 1000 then setElementData(localPlayer,"FPS",fps) fps = 0 fpstick = false end end ) addEvent("getMaxPlayers",true) addEventHandler("getMaxPlayers",root, function (info) maxPlayer = info end ) function _getPlayerName(player) local playerTeam = getPlayerTeam(player) if (playerTeam) then local r,g,b = getTeamColor(playerTeam) local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) if r <= 16 then n1 = "0"..n1 end if g <= 16 then n2 = "0"..n2 end if b <= 16 then n3 = "0"..n3 end playerName = "#"..n1..n2..n3..getPlayerName(player) else playerName = "#FFFFFF"..getPlayerName(player) end return playerName end function toHex ( n ) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","A","B","C","D","E","F"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end triggerServerEvent("getMaxPlayer",localPlayer,localPlayer) fileDelete("scoreboard_client.Lua") Link to comment
' A F . Posted July 27, 2019 Share Posted July 27, 2019 outputDebugString("scoreboard ligado") sX,sY = guiGetScreenSize() sor = dxCreateFont("font.ttf",14) or "arial" font = dxCreateFont("font_.ttf",17) or "arial" maxPlayer = "nil" function _dxText(text,x,y,w,h,red,green,blue,alpha,scale,font,a,b,c,d,e,f) dxDrawText(string.gsub(text,"(#%x%x%x%x%x%x)",""),x+1,y+1,w+1,h+1,tocolor(0,0,0,alpha),scale,font,a,b,c,d,e,f) dxDrawText(text,x,y,w,h,tocolor(red,green,blue,alpha),scale,font,a,b,c,d,e,f) end function dxDrawRecLine(x,y,w,h,color) dxDrawRectangle(x,y,w,1,color) -- h dxDrawRectangle(x,y+h,w,1,color) -- h dxDrawRectangle(x,y,1,h,color) -- v dxDrawRectangle(x+w-1,y,1,h,color) -- v end function dxDrawRectangleRounded(x,y,w,h,tocolor) dxDrawRectangle(x,y,w,h,tocolor) dxDrawRectangle(x+1,y-1,w-2,1,tocolor) dxDrawRectangle(x+1,y+h,w-2,1,tocolor) dxDrawRectangle(x+w,y+1,1,h-2,tocolor) dxDrawRectangle(x-1,y+1,1,h-2,tocolor) end scoreboard = {} function playersShow() scoreboard = {} for i,player in ipairs(getElementsByType("player")) do if not getPlayerTeam(player) then table.insert(scoreboard,{"player",player}) end end for i,team in ipairs(getElementsByType("team")) do if (tonumber(countPlayersInTeam(team))>=1) then table.insert(scoreboard,{"teamName",team}) for i,playerTeam in ipairs (getPlayersInTeam(team)) do table.insert(scoreboard,{"player",playerTeam}) end end end end rowNow = 0 rowsCount = math.floor(sY/22)-6 function drawScoreboard() playersShow() count = math.min(#scoreboard,rowsCount) local x = sX/2 - 320 local y = sY/2 - count*20 / 2 local cx, cy = 0,0 if isCursorShowing() then cx, cy = getCursorPosition() cx = cx * sX cy = cy * sY end showCursor(getKeyState("mouse2")) dxDrawRectangleRounded(x,y-52,640,count*22+52,tocolor(0,0,0,255)) dxDrawRectangleRounded(x,y-22,640,20,tocolor(0,0,0,200)) _dxText("uW' United Warriors",x+10,y-51,sX,sY,255,255,255,255,1,font,"left","top",true,false,false,false) _dxText(#getElementsByType("player").." / "..maxPlayer,x,y-50,x+632,y-28,255,255,255,255,1,font,"right","center",true,false,false,false) _dxText("Ping",x,y-22,x+35,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("Name",x+40,y-22,sX,y,255,255,255,255,1,"arial","left","center",true,false,false,false) _dxText("Country",x+178,y-22,x+244,y,255,255,255,255,1,"arial","left","center",true,false,false,false) _dxText("Money",x+244,y-22,x+310,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("Points",x+310,y-22,x+376,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("Rank",x+376,y-22,x+442,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("State",x+442,y-22,x+508,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("FPS",x+508,y-22,x+574,y,255,255,255,255,1,"arial","center","center",true,false,false,false) _dxText("ID",x+574,y-22,x+640,y,255,255,255,255,1,"arial","center","center",true,false,false,false) for i=1,count do posY = y+(i-1)*22 if scoreboard[i+rowNow][1] == "player" then if scoreboard[i+rowNow][2] == localPlayer then dxDrawRectangleRounded(x,posY,640,22,tocolor(255,255,255,15)) end if isCursorShowing() and cx > x and cx < x + 640 and cy > posY and cy < posY + 22 then dxDrawRectangleRounded(x,posY,640,22,tocolor(255,255,255,20)) end _dxText(getElementData(scoreboard[i+rowNow][2],"id")or"?",x+574,posY,x+640,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) if getElementData(scoreboard[i+rowNow][2],"AFK") then afk="#FF0000AFK " else afk="" end _dxText(afk.._getPlayerName(scoreboard[i+rowNow][2]),x+40,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",false,false,false,true) country = getElementData(scoreboard[i+rowNow][2],"country"):lower() or "?" if country == "" then country = "?" end _dxText(string.upper(country),x+204,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",true,false,false,false) if country == "?" then country = "World" end if country and fileExists("flags/"..country..".png") then dxDrawImage(x+184,posY+2,16,16,"flags/"..country..".png",0,0,0,tocolor(255,255,255,255)) end _dxText(getElementData(scoreboard[i+rowNow][2],"Cash")or"Guest",x+244,posY,x+310,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"Points")or"Guest",x+310,posY,x+376,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"Rank")or"Guest",x+376,posY,x+442,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"state")or"?",x+442,posY,x+508,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getElementData(scoreboard[i+rowNow][2],"FPS")or"?",x+508,posY,x+574,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) _dxText(getPlayerPing(scoreboard[i+rowNow][2]),x,posY,x+35,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false) end if scoreboard[i+rowNow][1] == "teamName" then dxDrawRectangleRounded(x,posY,640,20,tocolor(r,g,b,50)) r,g,b = getTeamColor(scoreboard[i+rowNow][2]) _dxText(getTeamName(scoreboard[i+rowNow][2]),x+280,posY,sX,posY+22,r,g,b,255,1,"default-bold","left","center",false,false,false,true) end end if rowsCount < #scoreboard then size = rowsCount*22 _size = size/#scoreboard __size = _size*rowsCount dxDrawRectangleRounded(x+630,y,10,size,tocolor(255,255,255,20)) dxDrawRectangleRounded(x+630,y+rowNow*_size,10,__size,tocolor(0,0,0,180)) end end bindKey("tab","down", function() addEventHandler("onClientRender",root,drawScoreboard) end ) bindKey("tab","up", function() removeEventHandler("onClientRender",root,drawScoreboard) if isCursorShowing() then showCursor(false) end end ) addEventHandler("onClientMinimize",root, function() setElementData(localPlayer,"AFK",true) end ) addEventHandler("onClientRestore",root, function() setElementData(localPlayer,"AFK",false) end ) bindKey("mouse_wheel_down","down", function() if rowNow == 0 then return end rowNow = rowNow - 1 end ) bindKey("mouse_wheel_up","down", function() maxIndex = #scoreboard - rowsCount if #scoreboard < rowsCount then return end if rowNow == maxIndex then return end rowNow = rowNow + 1 end ) addEventHandler("onClientRender",root, function() if not fps then fps = 0 end fps = fps + 1 if not fpstick then fpstick = getTickCount() end fpscountertick = getTickCount() if fpscountertick - fpstick >= 1000 then setElementData(localPlayer,"FPS",fps) fps = 0 fpstick = false end end ) addEvent("getMaxPlayers",true) addEventHandler("getMaxPlayers",root, function (info) maxPlayer = info end ) function _getPlayerName(player) local playerTeam = getPlayerTeam(player) if (playerTeam) then local r,g,b = getTeamColor(playerTeam) local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) if r <= 16 then n1 = "0"..n1 end if g <= 16 then n2 = "0"..n2 end if b <= 16 then n3 = "0"..n3 end playerName = "#"..n1..n2..n3..getPlayerName(player) else playerName = "#FFFFFF"..getPlayerName(player) end return playerName end function toHex ( n ) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","A","B","C","D","E","F"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end triggerServerEvent("getMaxPlayer",localPlayer,localPlayer) fileDelete("scoreboard_client.Lua") try this Link to comment
EugenMForelli Posted July 27, 2019 Author Share Posted July 27, 2019 No. doesnt WORK https://imgur.com/a/Thp7fto Link to comment
HassoN Posted July 27, 2019 Share Posted July 27, 2019 27 minutes ago, EugenMForelli said: No. doesnt WORK https://imgur.com/a/Thp7fto Because your API that gets player's country is not working... Use the method that is being used in the default admin panel. And if you still use the default admin panel you could just use an export to get player's country. Link to comment
TRtam Posted July 28, 2019 Share Posted July 28, 2019 Did you give admin right to the scoreboard? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now