Jump to content

Doesnt work at all.


Sex*

Recommended Posts

It doesnt create debug errors and doesnt work:

local gRoot = getRootElement() 
local gMe = getLocalPlayer()
local sW , sH = guiGetScreenSize ()
local TextScale = sH/1800
--if TextScale < 1.0 then TextScale = 1.0 end
local TextFont = "bankgothic"
local maxPlayers = 10
local slideFlag = false
 
local elements = {}
local places = {}
local numbers = {}
local alpha = {}
local slide = {}
 
function startResource ()
    for i=1,maxPlayers do      
        numbers[i] = ""
        places[i] = ""
        elements[i] = nil
        alpha[i] = 1
        slide[i] = 0
    end
    addEventHandler ( "onClientRender", gRoot, RankingBoardDrawing )
    end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), startResource )
 
addEvent("onPlayerWasted", true)
addEventHandler("onPlayerWasted", getRootElement(), function(state)
    if(state)then
        removeEventHandler ( "onClientRender", gRoot, RankingBoardDrawing )
        addEventHandler ( "onClientRender", gRoot, RankingBoardDrawing )
    else
        removeEventHandler ( "onClientRender", gRoot, RankingBoardDrawing )
    end
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
 
function RankingBoardDrawing ()
        local deathList = {}
        for i=1, maxPlayers do
            local name = places[i]
            if(isElement(elements[i]))then
                local tColor = ""
                local team = getPlayerTeam(elements[i])
                if(team)then
                local r,g,b = getTeamColor ( team )
                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
                tColor = "#"..n1..""..n2..""..n3
                end
           
                name = tColor..getPlayerName(elements[i])
                places[i] = name
            end
           
            if(#(tostring(i)) == 1)then
                deathList[i] = "  "..numbers[i].."  "..name
            else
                deathList[i] = numbers[i].."  "..name
            end
        end
       
        dxDrawColorTextPuma(deathList, sW*0.00875, sH*0.325, sW , sH, tocolor(255,255,255,200), TextScale, TextFont , "left", "top")
    end
end
 
 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
function Adding (s,nameS, element, moveing)
    local name = nameS
    local pos = s/2
    local color = "#FF4000"
   
    if(pos == 1)then
        color = "#ff4000"
    elseif(pos == 2)then
        color = "#ff4000"
    elseif(pos == 3)then
        color = "#ff4000"
    end
   
    numbers[pos] = "#FFFFFF["..color..pos.."#FFFFFF]"
    if not moveing then
        setTimer(function()
            if numbers[pos] == "#FFFFFF["..color..pos.."#FFFFFF]" then
                numbers[pos] = "#FFFFFF["..color..pos.."#FFFFFF]"
            else
                numbers[pos] = "#FFFFFF["..color..pos.."#FFFFFF]"--"#FFFFFF )"
            end
        end, 100, 5)
    else
        numbers[pos] = "#FFFFFF["..color..pos.."#FFFFFF]"
    end
    --local nameFix = string.gsub(name, "\\", "\\\\")
    places[pos] = name
    elements[pos] = element
    alpha[pos] = 0
    slide[pos] = 0
   
    -- over range fix
    local co = 0
    for i=1,maxPlayers do
        if not(places[i] == "")then
            co = co + 1
        end
    end
   
    local index = 0
    for i=1,maxPlayers do
        if not(places[maxPlayers-i+1] == "")then
            index = maxPlayers-i+1
            break
        end
    end
    index = maxPlayers - index
   
    if(co > 16)then
        local nr = co - 16
        nr = nr + index
        local off = maxPlayers
        for i=1,nr do
            numbers[off] = ""
            places[off] = ""
            elements[off] = nil
            off = off - 1
        end
    end
end
addEvent( "showPlayersOnRankingBoard", true )
addEventHandler( "showPlayersOnRankingBoard", gRoot, Adding )
 
function hideAll ()
    resetVariables()
    for i=1,maxPlayers do      
        numbers[i] = ""
        places[i] = ""
        elements[i] = nil
        alpha[i] = 0
        slide[i] = 0
    end
end
addEvent( "hideAll", true )
addEventHandler( "hideAll", gRoot, hideAll )
 
function resetVariables()
    places =  nil
    numbers = nil
    alpha = nil
    slide = nil
    elements = nil
    places = {}
    elements = {}
    numbers = {}
    alpha = {}
    slide = {}
    slideFlag = false
end
 
addEvent("onSlideList", true)
addEventHandler("onSlideList", getRootElement(), function()
    slideFlag = true
end)
 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
function getScale(w)
    local scale = (w*(1/900))
    --scale = math.max(scale, 0.4)
    return scale
end
 
local limitY = 450/900*sW
 
local block = (sW/28)
local inc = 0.00925*sW
local spaceHeight = 6/900*sW
function dxDrawColorTextPuma(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
    local Texts = {}
    --Texts = string.explode(str,"/newline/")
    Texts = str
    local index = 1
    for i=1,#Texts do
        if not(places[i] == "")then
        local alphaS = math.min(alpha[i],225)
        local offset = math.max(0, (255 - alpha[i])/3)
        if((ay+(dxGetFontHeight ( scale, font ))*(index-1)) - offset > limitY)then break end
        alpha[i] = alpha[i] + 3
        local sl = 0
        local slY = 0
        if slideFlag then
            if(index == 1)then
                sl = slide[index] + inc
                slide[index] = sl
            else
                if((slide[index - 1] - slide[index]) > block)then
                    sl = slide[index] + inc
                    slide[index] = sl
                end
            end
            if(index == 1 or index == 6 or index == 11 or index == 16 or index == 21)then
                slY = sl/2
            elseif(index == 2 or index == 7 or index == 12 or index == 17 or index == 22)then
                slY = - sl/2
            elseif(index == 3 or index == 8 or index == 13 or index == 18 or index == 23)then
                slY = sl/4
            elseif(index == 4 or index == 9 or index == 14 or index == 19 or index == 24)then
                slY = - sl/4
            else
                slY = 0
            end
        end
       
        local shadow = string.gsub(Texts[i],"#%x%x%x%x%x%x","#000000")
        dxDrawColorTextNext(shadow, ax + 1 + sl, ((ay)+(dxGetFontHeight ( scale, font ))*(index-1)) - offset + slY + spaceHeight + 1, bx+2, bx+2, tocolor(255,255,255,50), scale, font, alignX, alignY, alphaS)
       
        dxDrawColorTextNext(Texts[i], ax + sl, (ay+(dxGetFontHeight ( scale, font ))*(index-1)) - offset + slY + spaceHeight, bx, by, color, scale, font, alignX, alignY, alphaS)
       
        index = index + 1
        end
    end
end
 
function dxDrawColorTextNext(str, ax, ay, bx, by, color, scale, font, alignX, alignY, alpha)
  if alignX then
    if alignX == "center" then
      local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
      ax = ax + (bx-ax)/2 - w/2
    elseif alignX == "right" then
      local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
      ax = bx - w
    end
  end
 
  if alignY then
    if alignY == "center" then
      local h = dxGetFontHeight(scale, font)
      ay = ay + (by-ay)/2 - h/2
   
Link to comment

Maybe the problem is in the server side?

gRoot = getRootElement() 
  
Places = {} 
PlayersOnRankingBoard = {} 
  
function beforeCountDown (stateName,currentRaceStateName) 
    if stateName == "NoMap" then 
        destroyRankingBoard() 
        MapIsRunning = nil 
        PlayersOnRankingBoard = {} 
    elseif stateName == "Running" then 
        MapIsRunning = 1 
    end 
end 
addEvent("onRaceStateChanging",true) 
addEventHandler('onRaceStateChanging', gRoot, beforeCountDown) 
  
function hideRankingBoard() 
    triggerClientEvent("hideAll", gRoot) 
end 
function destroyRankingBoard() 
    for i=1,32 do        
        Places[i] = nil 
    end 
    triggerClientEvent("hideAll", gRoot) 
end 
function showRankingBoard() 
    for i=1,32 do 
        if Places[i] then 
            triggerClientEvent("showPlayersOnRankingBoard", gRoot, i,getPlayerName(Places[i]),true) 
        end 
    end 
end 
function showRankingBoardToPlayer(who) 
    for i=1,32 do 
        if Places[i] then 
            triggerClientEvent(who,"showPlayersOnRankingBoard", gRoot, i,getPlayerName(Places[i]),true) 
        end 
    end 
end 
function moveRankingBoard() 
    for j=1,32 do 
        local i = 33-j 
        if Places[i] then 
            Places[i+1] = Places[i] 
            Places[i] = nil 
        end 
    end 
end 
function playerJoin() 
    showRankingBoardToPlayer(source) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) 
  
  
function addPlayersToDeathList () 
    for i=1,#PlayersOnRankingBoard do 
        if PlayersOnRankingBoard[i] == source then return end 
    end 
    table.insert(PlayersOnRankingBoard,source) 
    AddNewPlayer(source) 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), addPlayersToDeathList ) 
addEventHandler ( "onPlayerWasted", getRootElement(), addPlayersToDeathList ) 
  
function AddNewPlayer(thePlayer)  
    if MapIsRunning then 
        PlayerName = addTeamColor(thePlayer) 
        local alivePlayersCount = countAlivePlayersInRace(thePlayer) 
        -- Sprawdzanie czy sa juz na tym miejscu jacys ludzie 
        if Places[alivePlayersCount+1] == nil then 
            Places[alivePlayersCount+1] = thePlayer 
            triggerClientEvent("showPlayersOnRankingBoard", gRoot, alivePlayersCount+1,PlayerName) 
            triggerEvent("onPlayerDeadInRace", gRoot, alivePlayersCount+1,thePlayer) 
        -- Ktos jest na tym samym miejscu, ktos dolaczyl do servera i gra w mapie a nie byl liczony po smierci tego pierwszego, wiec przesun all w dol 
        else 
            moveRankingBoard() 
            hideRankingBoard() 
            showRankingBoard() 
            Places[alivePlayersCount+1] = PlayerName 
            triggerClientEvent("showPlayersOnRankingBoard", gRoot, alivePlayersCount+1,PlayerName) 
            triggerEvent("onPlayerDeadInRace", gRoot, alivePlayersCount+1,thePlayer) 
        end 
        -- Jezeli zginal gracz drugi 
        if alivePlayersCount == 1 then 
            for i,player in ipairs (getElementsByType("player")) do 
                local state = getElementData(player,"state") 
                if state then 
                    if state == "alive" or state == "not ready" or state == "joined" then 
                        if thePlayer == player then else 
                            Winner = player 
                        end 
                    end 
                end 
            end 
            WinnerName = addTeamColor(Winner) 
            Places[1] = Winner 
            triggerClientEvent("showPlayersOnRankingBoard", gRoot, 1,WinnerName) 
            triggerEvent("onPlayerDeadInRace", gRoot, 1,Winner) 
            MapIsRunning = nil 
        end 
    end 
end 
  
------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  
function countAlivePlayersInRace(thePlayer) 
    AlivePlayersCounter = 0 
    for i,player in ipairs (getElementsByType("player")) do 
        local state = getElementData(player,"state") 
        if state then 
            if state == "alive" or state == "not ready" or state == "joined" then 
                if thePlayer == player then else 
                    AlivePlayersCounter = AlivePlayersCounter + 1 
                end 
            end 
        end 
    end 
    return AlivePlayersCounter 
end 
  
function addTeamColor(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 
        return "#"..n1..""..n2..""..n3..""..getPlayerName(player) 
    else 
        return getPlayerName(player) 
    end 
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 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

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