Jump to content

Scoreboard bug


Recommended Posts

I am creating a custom scoreboard. But i'm quite stuck at the moment.

Since I don't find any bugs in debugscript 3 I thought someone here might know the problem.

It draws some part of it but not all.

xfe.png

Here is the client side:

  
local scrX,scrY = guiGetScreenSize();
local g_Me = getLocalPlayer();
local players = {};
 
addEvent("spl",true)
addEventHandler("spl",root,
function(arg)
    players = arg;
end)
 
local scroll = 1;
 
local anim_x = 0;
local anim_y = 20;
 
local board_x = 360;
local size_info = 60;
local size_title = 20;
local p_space = 20;
 
local function init_scoreboard()
    local pcount = #players+3;
    local y = pcount*p_space+size_info;
    local fits = pcount;
    if scrY-300 < y then
        y = scrY-300;
        fits = (y-size_info)/p_space;
    end
    fits = math.floor(fits);
 
    dxDrawRectangle(scrX/2-anim_x,scrY/2-anim_y/2,anim_x*2,anim_y,tocolor(0,0,0,130));
    if anim_x < board_x then
        anim_x = anim_x + p_space;
    else
        if anim_y < y then
            anim_y = anim_y + p_space;
        else
            --// Info
            dxDrawRectangle(scrX/2-anim_x,scrY/2-y/2,anim_x*2,size_info-size_title,tocolor(5,25,40,255));
            dxDrawText("The Insane Players gaming server.",0,scrY/2-y/2,scrX,0,tocolor(220,220,220,255),1,"default-bold","center");
            dxDrawText("Players: "..#getElementsByType("player").."/100",scrX/2-anim_x+5,scrY/2-y/2,0,0,tocolor(220,220,220,255),1,"default-bold");
            dxDrawText("Website: [url=http://www.insaneplayers.eu]http://www.insaneplayers.eu[/url]",scrX/2-anim_x+5,scrY/2-y/2+20,0,0,tocolor(220,220,220,255),1,"default-bold");
            --// Player info
            local function draw_player_info(arg,x,y,v,k,room)
                if (arg == "player") then
                    dxDrawRectangle(x,y,22,20,tocolor(0,0,0,130));
                    local color = tocolor(255,255,255,255);
                    if (v == g_Me) then
                        color = tocolor(100,180,255,255);
                    end
                    dxDrawText(k,x+5,y,0,0,color,1,"default-bold","left","top",false,false,false,true);
                    dxDrawText(getPlayerName(v):gsub("#%x%x%x%x%x%x", ""),x+31,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                    dxDrawText(getPlayerName(v),x+30,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                    if (room ~= "lobby") then
                        if (room == "dm") then
                            dxDrawText(getElementData(v,"State") or "Not ready",x+166,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                            dxDrawText(getElementData(v,"State") or "Not ready",x+165,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                            dxDrawText(getElementData(v,"Map"):sub(1,50) or "No map",x+230,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                            dxDrawText(getElementData(v,"Map"):sub(1,50) or "No map",x+230,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                        else
                            dxDrawText(getElementData(v,"Map") or "No map",x+166,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                            dxDrawText(getElementData(v,"Map") or "No map",x+165,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                        end
                    end
                    if getElementData(v,"Country") then
                        dxDrawText(getElementData(v,"Country"):upper(),x+626,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                        dxDrawText(getElementData(v,"Country"):upper(),x+625,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                        dxDrawImage(x+605,y+1, 17, 13, ":admin/client/images/flags/"..getElementData(v,"Country"):lower()..".png")
                    else
                        dxDrawText("?",x+605,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                    end
                    dxDrawText(getElementData(v,"FPS") or math.random(40,44),x+661,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                    dxDrawText(getElementData(v,"FPS") or math.random(40,44),x+660,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                    dxDrawText(getPlayerPing(v),x+691,y+1,1,1,tocolor(0,0,0,200),1,"default-bold","left","top",false,false,false,true);
                    dxDrawText(getPlayerPing(v),x+690,y,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true);
                elseif (arg == "hunterinfo") then
                    dxDrawRectangle(x,y,anim_x*2,20,tocolor(10,10,10,255));
                    dxDrawText("ID",x+5,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Name",x+30,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Map",x+165,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Country",x+605,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("FPS",x+660,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Ping",x+690,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                elseif (arg == "traininginfo") then
                    dxDrawRectangle(x,y,anim_x*2,20,tocolor(10,10,10,255));
                    dxDrawText("ID",x+5,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Name",x+30,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Map",x+165,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Country",x+605,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("FPS",x+660,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Ping",x+690,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                elseif (arg == "dminfo") then
                    dxDrawRectangle(x,y,anim_x*2,20,tocolor(10,10,10,255));
                    dxDrawText("ID",x+5,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Name",x+30,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("State",x+165,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Map",x+230,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Country",x+605,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("FPS",x+660,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Ping",x+690,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                elseif (arg == "lobbyinfo") then
                    dxDrawRectangle(x,y,anim_x*2,20,tocolor(10,10,10,255));
                    dxDrawText("ID",x+5,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Name",x+30,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Country",x+605,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("FPS",x+660,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                    dxDrawText("Ping",x+690,y,0,0,tocolor(140,140,140,255),1,"default-bold");
                elseif (arg == "team") then
                    dxDrawRectangle(x,y,anim_x*2,20,tocolor(15,15,15,200));
                    dxDrawText(v,x+5,y,0,0,tocolor(220,220,220,255),1,"default-bold");
                else
                    dxDrawRectangle(x,y,anim_x*2,20,tocolor(10,10,10,255));
                    dxDrawText(arg,0,y,scrX,0,tocolor(220,220,220,255),1,"default-bold","center");
                end
            end
           
            local drawList = {};
           
            drawList[1] = {false,false,""}; --hunter
            drawList[2] = {false,false,"hunterinfo"};
           
            local teamPlayersA = {}; --//modsH
            local teamPlayersB = {}; --//adminsH
           
            local teamPlayersAT = {}; --//modsTraining
            local teamPlayersBT = {}; --//adminsTraining
           
            local teamPlayersAD = {}; --//modsDM
            local teamPlayersBD = {}; --//adminsDM
           
            local teamPlayersAM = {}; --//modsDD
            local teamPlayersBM = {}; --//adminsDD
           
            local teamPlayersAO = {}; --//modsOS
            local teamPlayersBO = {}; --//adminsOS
           
            local TrainingPlayers = {};
            local DMPlayers = {};
            local DDPlayers = {};
            local OSPlayers = {};
            local LobbyPlayers = {};
            for k,v in ipairs(players) do
                if isElement(v) then
                    local room = getElementData(v,"room");
                    if room then
                        local team = getPlayerTeam(v);
                        if team then
                            if (getTeamName(team) == "Admins") then
                                if (room == 1) then
                                    teamPlayersB[#teamPlayersB+1] = {v,k};
                                elseif (room == 2) then
                                    teamPlayersBT[#teamPlayersBT+1] = {v,k};
                                elseif (room == 4) then
                                    teamPlayersBD[#teamPlayersBD+1] = {v,k};
                                elseif (room == 5) then
                                    teamPlayersBM[#teamPlayersBM+1] = {v,k};
                                elseif (room == 6) then
                                    teamPlayersBO[#teamPlayersBO+1] = {v,k};
                                end
                            else
                                if (room == 1) then
                                    teamPlayersA[#teamPlayersA+1] = {v,k};
                                elseif (room == 2) then
                                    teamPlayersAT[#teamPlayersAT+1] = {v,k};
                                elseif (room == 4) then
                                    teamPlayersAD[#teamPlayersAD+1] = {v,k};
                                elseif (room == 5) then
                                    teamPlayersAM[#teamPlayersAM+1] = {v,k};
                                elseif (room == 6) then
                                    teamPlayersAO[#teamPlayersAO+1] = {v,k};
                                end
                            end
                        else
                            if (room == 1) then
                                drawList[#drawList+1] = {v,k};
                            elseif (room == 2) then
                                TrainingPlayers[#TrainingPlayers+1] = {v,k};
                            elseif (room == 4) then
                                DMPlayers[#DMPlayers+1] = {v,k};
                            elseif (room == 5) then
                                DDPlayers[#DDPlayers+1] = {v,k};
                            elseif (room == 6) then
                                OSPlayers[#OSPlayers+1] = {v,k};
                            end
                        end
                    else
                        LobbyPlayers[#LobbyPlayers+1] = {v,k};
                    end
                else
                    triggerServerEvent("gpl",getLocalPlayer());
                end
            end
           
            drawList[1] = {false,false,"Hunter (Players: "..(#drawList-2)..")"};
           
            drawList[#drawList+1] = {"team","Moderator(s)  |  Players: ("..#teamPlayersA..")"};
            for k,v in ipairs(teamPlayersA) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            drawList[#drawList+1] = {"team","Administrator(s)  |  Players: ("..#teamPlayersB..")"};
            for k,v in ipairs(teamPlayersB) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            --//TRAINING
            drawList[#drawList+1] = {false,false,"Training (Players: "..#TrainingPlayers + #teamPlayersBT + #teamPlayersAT..")"};
            drawList[#drawList+1] = {false,false,"traininginfo"};
           
            for k,v in ipairs(TrainingPlayers) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            drawList[#drawList+1] = {"team","Moderator(s)  |  Players: ("..#teamPlayersAT..")"};
            for k,v in ipairs(teamPlayersAT) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            drawList[#drawList+1] = {"team","Administrator(s)  |  Players: ("..#teamPlayersBT..")"};
            for k,v in ipairs(teamPlayersBT) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            --//DEATHMATCH
            drawList[#drawList+1] = {false,false,"Deathmatch (Players: "..#DMPlayers + #teamPlayersBD + #teamPlayersAD..")"};
            drawList[#drawList+1] = {false,false,"dminfo"};
           
            for k,v in ipairs(DMPlayers) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            drawList[#drawList+1] = {"team","Moderator(s)  |  Players: ("..#teamPlayersAD..")"};
            for k,v in ipairs(teamPlayersAD) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            drawList[#drawList+1] = {"team","Administrator(s)  |  Players: ("..#teamPlayersBD..")"};
            for k,v in ipairs(teamPlayersBD) do
                drawList[#drawList+1] = {v[1],v[2]};
            end
           
            --//DERBY
            drawList[#drawList+1] = {false,false,"Destruction Derby (Players: "..#DDPlayers + #teamPlayersBM + #teamPlayersAM..")"};
            drawList[#drawList+1] = {false,false,"dminfo"};
           
            for k,v in ipairs(DDPlayers) do
                drawList[#drawList+1] = {v[1],v[2],"dm"};
            end
           
            drawList[#drawList+1] = {"team","Moderator(s)  |  Players: ("..#teamPlayersAM..")"};
           
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...