Hat sich geklärt wodurch auch immer, habe das neu eingefügt und jetzt gehts.
#closerequested
Hat sich geklärt wodurch auch immer, habe das neu eingefügt und jetzt gehts.
#closerequested
Ja aber wo muss ich das ändern? Welches der Scripte ist das denn?
edit: Habe die beiden dateien gelöscht aus dem Script und neue als addon eingefügt, der selbe fehler immernoch :o
edit2: Habe gar keine mehr drinne und es ist immernoch eine da :o
edit3: Habe ein neues Script gefunden was anscheinend mein Rankingboard Managed
Clientside:
local sx, sy = guiGetScreenSize()
function unfuck(text)
return string.gsub(text, "(#%x%x%x%x%x%x)", function(colorString)
return ""
end)
end
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, seila1, seila2)
local pat = "(.-)#(%x%x%x%x%x%x)"
local s, e, cap, col = str:find(pat, 1)
local last = 1
while s do
if cap == "" and col then
color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255)
end
if s ~= 1 or cap ~= "" then
local w = dxGetTextWidth(unfuck(cap), scale, font)
dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, seila1, seila2)
ax = ax + w
color = tocolor(tonumber("0x" .. col:sub(1, 2)), tonumber("0x" .. col:sub(3, 4)), tonumber("0x" .. col:sub(5, 6)), 255)
end
last = e + 1
s, e, cap, col = str:find(pat, last)
end
if last <= #str then
cap = str:sub(last)
local w = dxGetTextWidth(unfuck(cap), scale, font)
dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, seila1, seila2)
end
end
AllDeadPlayers = {}
function sendData(data)
AllDeadPlayers = {}
AllDeadPlayers = data
end
addEvent("sendData", true)
addEventHandler("sendData", getRootElement(), sendData)
_dxDrawRectangle = dxDrawRectangle
_dxDrawText = dxDrawText
function dxDrawText(text, x, y, w, h, color, size, font, seila, seila2, boardacolor)
_dxDrawText(text, x + 0.5, y + 0.5, w - 1, h - 1, tocolor(0, 0, 0, 255), size, font, seila, seila2)
_dxDrawText(text, x, y, w, h, color, size, font, seila, seila2)
end
function dxDrawRectangle(x, y, w, h, color)
_dxDrawRectangle(x, y, w, h, color)
end
playersColor = {}
count = 5
handledScroolUp = "false"
handledScroolDown = "false"
openList = "false"
addEventHandler("onClientRender", getRootElement(), function()
for i = 1, count do
if AllDeadPlayers[i] then
playerName = AllDeadPlayers[i].playerName
nameUnfucked = unfuck(playerName)
playerPos = AllDeadPlayers[i].pos
playersColor[nameUnfucked] = {}
playersColor[nameUnfucked].Color1 = tocolor(0,170,70, 255)
playersColor[nameUnfucked].Color2 = tocolor(0, 0, 0, 180)
playersColor[nameUnfucked].Color3 = tocolor(255, 255, 255, 255)
if nameUnfucked == unfuck(getPlayerName(getLocalPlayer())) then
playersColor[nameUnfucked].Color1 = tocolor(0,170,70, 255)
playersColor[nameUnfucked].Color2 = tocolor(0, 0, 0, 180)
playersColor[nameUnfucked].Color3 = tocolor(255, 255, 255, 255)
end
dxDrawRectangle(sx - 170, -19 + 25 * i, 35, 25, tocolor(0, 0, 0, 255))
dxDrawRectangle(sx - 135, -19 + 25 * i, sx - sx + 130, 25, playersColor[nameUnfucked].Color2)
dxDrawText(tostring(AllDeadPlayers[i].pos), sx - 140, -35 + 50 * i, sx - 165, 25, playersColor[nameUnfucked].Color1, 1, "default-bold", "center", "center", "center")
dxDrawColorText(unfuck(playerName), sx - 120, -35 + 50 * i, sx - 70, 25, playersColor[nameUnfucked].Color3, 1, "default-bold", "center", "center", "center")
end
end
if openList == "false" then
for k, players in ipairs(AllDeadPlayers) do
if unfuck(players.playerName) == unfuck(getPlayerName(getLocalPlayer())) and k >= 5 then
count = 4
dxDrawRectangle(sx - 170, 109.75, 35, 25, tocolor(0, 0, 0, 255))
dxDrawRectangle(sx - 135, 109.75, sx - sx + 130, 25, tocolor(0, 0, 0, 180))
dxDrawText(tostring(players.pos), sx - 140, 222.5, sx - 165, 25, tocolor(0,170,70, 255), 1, "default-bold", "center", "center", "center")
dxDrawColorText(players.playerName, sx - 120, 222.5, sx - 70, 25, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center", "center")
end
end
end
end)
function scroolUp()
if not tickScroolUp then
tickScroolUp = getTickCount()
end
tickScroolUpNow = getTickCount()
tickScroolUpCalc = tickScroolUpNow - tickScroolUp
if tickScroolUpCalc > 700 then
if count > #AllDeadPlayers then
return
end
count = count + 1
end
handledScroolUp = "true"
openList = "true"
end
function scroolDown()
if not tickScroolDown then
tickScroolDown = getTickCount()
end
tickScroolDownNow = getTickCount()
tickScroolDownCalc = tickScroolDownNow - tickScroolDown
if tickScroolDownCalc > 700 then
if count <= 5 then
openList = "false"
return
end
count = count - 1
end
handledScroolDown = "true"
end
bindKey("r", "down", function()
if handledScroolUp == "false" then
addEventHandler("onClientRender", getRootElement(), scroolUp)
end
if handledScroolDown == "true" then
handledScroolDown = "false"
removeEventHandler("onClientRender", getRootElement(), scroolDown)
end
end)
bindKey("r", "up", function()
if handledScroolDown == "false" then
addEventHandler("onClientRender", getRootElement(), scroolDown)
end
if handledScroolUp == "true" then
handledScroolUp = "false"
removeEventHandler("onClientRender", getRootElement(), scroolUp)
end
end)
function reset()
AllDeadPlayers = {}
end
addEvent("resetDeathList", true)
addEventHandler("resetDeathList", getRootElement(), reset)
Alles anzeigen
Serverside
playersWasted = {}
function getPlayerPos(player)
return exports.Race:getPlayerRank(player) + 1
end
function sendinfos()
if getElementData(source, "PlayerDeadDeathList") == "sim" then
return
end
if getElementData(source, "Winner") and getElementData(source, "Winner") == "sim" then
return
end
setElementData(source, "PlayerDeadDeathList", "sim")
playerRank = getPlayerPos(source)
if playerRank == 1 then
for i, v in ipairs(getElementsByType("player")) do
if getElementData(v, "state") == "alive" then
table.insert(playersWasted, {
playerName = addTeamColor(v),
pos = 1
})
setElementData(v, "Winner", "sim")
end
end
end
table.insert(playersWasted, {
playerName = addTeamColor(source),
pos = playerRank
})
table.sort(playersWasted, function(a, b)
if tonumber(a.pos) == tonumber(b.pos) then
return tonumber(a.pos or 0) > tonumber(b.pos or 0)
else
return tonumber(a.pos or 0) < tonumber(b.pos or 0)
end
end)
triggerClientEvent("sendData", getRootElement(), playersWasted)
end
addEventHandler("onPlayerWasted", getRootElement(), sendinfos)
function sendinfos()
local state = getElementData(source, "state")
if state and (state == "alive" or state == "not ready" or state == "joined") then
playerRank = getPlayerPos(source)
table.insert(playersWasted, {
playerName = addTeamColor(source),
pos = getPlayerCount()
})
table.sort(playersWasted, function(a, b)
if tonumber(a.pos) == tonumber(b.pos) then
return tonumber(a.pos or 0) > tonumber(b.pos or 0)
else
return tonumber(a.pos or 0) < tonumber(b.pos or 0)
end
end)
triggerClientEvent("sendData", getRootElement(), playersWasted)
end
end
addEventHandler("onPlayerQuit", getRootElement(), sendinfos)
addEvent("onGamemodeMapStop", true)
addEventHandler("onGamemodeMapStop", getRootElement(), function()
for i, v in ipairs(getElementsByType("player")) do
setElementData(v, "Winner", "nao")
setElementData(v, "PlayerDeadDeathList", "nao")
triggerClientEvent("resetDeathList", getRootElement())
playersWasted = {}
end
end)
function addTeamColor(player)
local playerTeam = getPlayerTeam(player)
if playerTeam then
do
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)
end
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
Alles anzeigen
Nur Ingame in der deathlist, sie fängt nicht bei 1 an sondern bei 2, keine errors
Yo leute, habe mal wieder ein problem undzwar geht mein Rankingboard nicht richtig, es werden nur alle Ränge von 2 bis halt ende angezeigt. Ich packe euch mal einen quellcode von meinem Script in den anhang.
Clientside
local sx,sy = guiGetScreenSize()
RankingBoard = {}
RankingBoard.__index = RankingBoard
RankingBoard.instances = {}
local screenWidth, screenHeight = guiGetScreenSize()
local topDistance = 250
local bottomDistance = 0.26*screenHeight
local posLeftDistance = 30
local nameLeftDistance = 60
local labelHeight = 16
local maxPositions = math.floor((screenHeight - topDistance - bottomDistance)/labelHeight)
posLabel = {}
playerLabel = {}
function RankingBoard.create(id)
RankingBoard.instances[id] = setmetatable({ id = id, direction = 'down', labels = {}, position = 0 }, RankingBoard)
posLabel = {}
playerLabel = {}
end
function RankingBoard.call(id, fn, ...)
RankingBoard[fn](RankingBoard.instances[id], ...)
end
function RankingBoard:setDirection(direction, plrs)
self.direction = direction
if direction == 'up' then
self.highestPos = plrs
self.position = self.highestPos + 1
end
end
function RankingBoard:add(name, time)
local position
local y
local doBoardScroll = false
if self.direction == 'down' then
--self.position = self.position + 1
if self.position > maxPositions then
return
end
y = topDistance + (self.position-1)*labelHeight
elseif self.direction == 'up' then
self.position = self.position - 1
local labelPosition = self.position
if self.highestPos > maxPositions then
labelPosition = labelPosition - (self.highestPos - maxPositions)
if labelPosition < 1 then
labelPosition = 0
doBoardScroll = true
end
elseif labelPosition < 1 then
return
end
y = topDistance + (labelPosition-1)*labelHeight
end
--posLabel[name], posLabelShadow = createShadowedLabelFromSpare(posLeftDistance, y, 20, labelHeight, tostring(self.position) .. ')', 'right')
if time then
if not self.firsttime then
self.firsttime = time
time = '' .. msToTimeStr(time)
else
time = '' .. msToTimeStr(time)
end
else
time = ''
end
--playerLabel[name], playerLabelShadow = createShadowedLabelFromSpare(nameLeftDistance, y, 250, labelHeight, name)
table.insert(self.labels, posLabel[name])
table.insert(self.labels, posLabelShadow)
table.insert(self.labels, playerLabel[name])
table.insert(self.labels, playerLabelShadow)
--playSoundFrontEnd(7)
--if doBoardScroll then
--guiSetAlpha(posLabel[name], 0)
--guiSetAlpha(posLabelShadow, 0)
--guiSetAlpha(playerLabel[name], 0)
--guiSetAlpha(playerLabelShadow, 0)
--local anim = Animation.createNamed('race.boardscroll', self)
--anim:addPhase({ from = 0, to = 1, time = 700, fn = RankingBoard.scroll, firstLabel = posLabel[name] })
--anim:addPhase({ fn = RankingBoard.destroyLastLabel, firstLabel = posLabel[name] })
--anim:play()
--end
end
function RankingBoard:scroll(param, phase)
local firstLabelIndex = table.find(self.labels, phase.firstLabel)
for i=firstLabelIndex,firstLabelIndex+3 do
guiSetAlpha(self.labels[i], param)
end
local x, y
for i=0,#self.labels/4-1 do
for j=1,4 do
x = (j <= 2 and posLeftDistance or nameLeftDistance)
y = topDistance + ((maxPositions - i - 1) + param)*labelHeight
if j % 2 == 0 then
x = x + 1
y = y + 1
end
guiSetPosition(self.labels[i*4+j], sx + x, y, false)
end
end
for i=1,4 do
guiSetAlpha(self.labels[i], 1 - param)
end
end
function RankingBoard:destroyLastLabel(phase)
for i=1,4 do
destroyElementToSpare(self.labels[1])
guiSetVisible(self.labels[1],false)
table.remove(self.labels, 1)
end
local firstLabelIndex = table.find(self.labels, phase.firstLabel)
for i=firstLabelIndex,firstLabelIndex+3 do
guiSetAlpha(self.labels[i], 1)
end
end
function RankingBoard:addMultiple(items)
for i,item in ipairs(items) do
self:add(item.name, item.time)
end
end
function RankingBoard:clear()
table.each(self.labels, destroyElementToSpare)
self.labels = {}
end
function RankingBoard:destroy()
self:clear()
RankingBoard.instances[self.id] = nil
end
--
-- Label cache
--
local spareElems = {}
local donePrecreate = false
function RankingBoard.precreateLabels(count)
donePrecreate = false
while #spareElems/4 < count do
local label, shadow = createShadowedLabel(10, 1, 20, 10, 'a' )
--guiSetAlpha(label,0)
guiSetAlpha(shadow,0)
guiSetVisible(label, false)
guiSetVisible(shadow, false)
destroyElementToSpare(label)
destroyElementToSpare(shadow)
end
donePrecreate = true
end
function destroyElementToSpare(elem)
table.insertUnique( spareElems, elem )
guiSetVisible(elem, false)
end
dxTextCache = {}
dxTextShadowCache = {}
function dxDrawColoredLabel(str, ax, ay, bx, by, color,tcolor,scale, font)
local rax = ax
if not dxTextShadowCache[str] then
dxTextShadowCache[str] = string.gsub( str, '#%x%x%x%x%x%x', '' )
end
--dxDrawText(dxTextShadowCache[str], ax+1,ay+1,ax+1,by,tocolor(0,0,0, 0 * tcolor[0.1]),scale,font, "left", "center", false,false,false)
if dxTextCache[str] then
for id, text in ipairs(dxTextCache[str]) do
local w = text[2] * ( scale / text[4] )
--dxDrawText(text[1], ax + w, ay, ax + w, by, tocolor(text[3][1],text[3][2],text[3][3],tcolor[0]), scale, font, "left", "center", false,false,false)
end
else
dxTextCache[str] = {}
local pat = "(.-)#(%x%x%x%x%x%x)"
local s, e, cap, col = str:find(pat, 1)
local last = 1
local r = tcolor[1]
local g = tcolor[2]
local b = tcolor[3]
local textalpha = tcolor[4]
while s do
if cap == "" and col then
r = tonumber("0x"..col:sub(1, 2))
g = tonumber("0x"..col:sub(3, 4))
b = tonumber("0x"..col:sub(5, 6))
color = tocolor(r, g, b, textalpha)
end
if s ~= 1 or cap ~= "" then
local w = dxGetTextWidth(cap, scale, font)
--dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "left", "center")
table.insert(dxTextCache[str], { cap, ax-rax, {r,g,b}, scale } )
ax = ax + w
r = tonumber("0x"..col:sub(1, 2))
g = tonumber("0x"..col:sub(3, 4))
b = tonumber("0x"..col:sub(5, 6))
color = tocolor( r, g, b, textalpha)
end
last = e + 1
s, e, cap, col = str:find(pat, last)
end
if last <= #str then
cap = str:sub(last)
local w = dxGetTextWidth(cap, scale, font)
--dxDrawText(cap, ax, ay, ax + w, by, color, scale, font, "left", "center")
table.insert(dxTextCache[str], { cap, ax-rax, {r,g,b}, scale } )
end
end
end
local font = "bankgothic"
addEventHandler("onClientRender", getRootElement(),
function()
for id, elem in pairs(playerLabel) do
if guiGetVisible(elem) and string.len(guiGetText(elem)) > 4 then
local x,y = guiGetPosition(elem, false)
local a = guiGetAlpha(elem) * 255
if not getKeyState("tab") then
dxDrawColoredLabel(string.gsub(guiGetText(elem)," ", " ",1), 50,y,200,y+20, tocolor(255,255,255,a*0.8),{255,255,255,a*0.8}, 0.5, font, "left", "center", false,false,false)
end
if x < 100 then guiSetPosition(elem, sx+100,y,false) end
end
end
for id, elem in pairs(posLabel) do
if guiGetVisible(elem) and string.len(guiGetText(elem)) <= 4 then
local x,y = guiGetPosition(elem, false )
local a = guiGetAlpha(elem) * 255
if not getKeyState("tab") then
--dxDrawText(guiGetText(elem), 1,y+1,41,y+21, tocolor(0,0,0,math.floor(a*0.8)), 0.5, font, "right", "center", false,false,false)
--dxDrawText(guiGetText(elem), 0,y,40,y+20, tocolor(255,255,255,a*0.85), 0.5, font, "right", "center", false,false,false)
end
if x < 100 then guiSetPosition(elem, sx+100,y,false) end
end
end
end)
function createShadowedLabelFromSpare(x, y, width, height, text, align)
if #spareElems < 2 then
if not donePrecreate then
outputDebug( 'OPTIMIZATION', 'createShadowedLabel' )
end
return createShadowedLabel(x, y, width, height, text, align)
else
local shadow = table.popLast( spareElems )
guiSetSize(shadow, width, height, false)
guiSetText(shadow, text)
--guiLabelSetColor(shadow, 0, 0, 0)
guiSetPosition(shadow, sx + x + 1, y + 1, false)
guiSetVisible(shadow, false)
local label = table.popLast( spareElems )
guiSetSize(label, width, height, false)
guiSetText(label, text)
--guiLabelSetColor(label, 255, 255, 255)
guiSetPosition(label, sx + x, y, false)
guiSetVisible(label, true)
if align then
guiLabelSetHorizontalAlign(shadow, align)
guiLabelSetHorizontalAlign(label, align)
else
guiLabelSetHorizontalAlign(shadow, 'left')
guiLabelSetHorizontalAlign(label, 'left')
end
return label, shadow
end
end
fileDelete("rankingboard_client.lua")
Alles anzeigen
Serverside
RankingBoard = {}
RankingBoard.__index = RankingBoard
RankingBoard.clientInstances = {}
function addTeamColor(player)
local playerTeam = getPlayerNametagText ( 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..""..getPlayerNametagText(player)
else
return getPlayerNametagText(player)
end
end
function RankingBoard:create()
local result = { id = #RankingBoard.clientInstances --[[+ 1]], items = {} }
RankingBoard.clientInstances[result.id] = true
clientCall(g_Root, 'RankingBoard.create', result.id)
result.joinHandler = function() result:playerJoined(source) end
addEventHandler('onPlayerJoin', getRootElement(), result.joinHandler)
return setmetatable(result, self)
end
function RankingBoard:clientCall(player, fn, ...)
clientCall(player, 'RankingBoard.call', self.id, fn, ...)
end
local savedplrcount = 1
function RankingBoard:setDirection(direction, plrcount)
savedplrcount = plrcount
if direction == 'up' or direction == 'down' then
self.direction = direction
self:clientCall(g_Root, 'setDirection', direction, plrcount )
end
end
function RankingBoard:add(player, time)
--local playerName = getPlayerNametagText(player)
--if table.find(self.items, 'name', playerName) then
-- return
--end
--table.insert(self.items, { name = playerName, time = time, player = player })
--self:clientCall(g_Root, 'add', playerName, time, player)
end
function RankingBoard:playerJoined(player)
--clientCall(player, 'RankingBoard.create', self.id)
--if self.direction then
-- self:clientCall(player, 'setDirection', self.direction, savedplrcount )
--end
--self:clientCall(player, 'addMultiple', self.items)
end
function RankingBoard:clear()
self:clientCall(g_Root, 'clear')
self.items = {}
end
function RankingBoard:destroy()
self:clientCall(g_Root, 'destroy')
removeEventHandler('onPlayerJoin', getRootElement(), self.joinHandler)
RankingBoard.clientInstances[self.id] = nil
end
Alles anzeigen
#closerequested
Moin Leute,
habe jetzt ein Racescript, nur das problem ist wenn ich das einfüge (gamemodes/race) dann wird der Gamemode Race nicht mehr gefunden. Ich weiß nicht was ich da falsch gemacht habe..