Jump to content

dxscoreboard


yanvr

Recommended Posts

hello I need to teach me a little with the dxscoreboards i'm working with a experience system labels and i want to add some columns in the DXSCOREBOARD: experience and level. The problem is that the exp resource works when player when a player dies.

I can't work with zombies. Can anybody help?

Serverside

exports.dxscoreboard:scoreboardAddColumn("ExP")

exports.dxscoreboard:scoreboardAddColumn("Level")

exports.dxscoreboard:scoreboardAddColumn("Wanted")

local levels = {[30] = 1, [55] = 2, [75] = 3, [85] = 4, [95] = 5, [120] = 6, [150] = 7, [230] = 8, [350] = 9, [500] = 10}

function win(ammo, killer, weapon, bodypart)

if (killer and killer ~= source) then

local H = getElementData(killer, "ExP")

local S = getElementData(killer, "Level")

local killer1 = getPlayerName(killer)

local noob = getPlayerName(source)

setElementData(killer, "ExP", tonumber(H)+1)

if levels[tonumber(H)] then

setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .." !")

triggerClientEvent ( killer, "playSound", killer )

end

outputChatBox(killer1 .. "Killed " .. noob .. " and gained +1 Exp", getRootElement(), 255, 255, 0, false)

end

end

addEventHandler( "onPlayerWasted", getRootElement(), win)

function onLogin (_,account)

setElementData(source, "Level", getAccountData(account, "lvl") or "Level 0 !")

setElementData(source, "ExP", getAccountData(account, "exp") or "Exp 0 !")

end

addEventHandler ("onPlayerLogin", root, onLogin)

function saveData(thePlayer, theAccount)

if (theAccount and not isGuestAccount(theAccount)) then

setAccountData (theAccount, "lvl", getElementData(thePlayer, "Level"))

setAccountData (theAccount, "exp", getElementData(thePlayer, "ExP"))

end

end

addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end)

addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end)

function getwan()

local players = getElementsByType ( "player" )

for theKey,thePlayer in ipairs(players) do

local wanted = getPlayerWantedLevel(thePlayer)

local zero = ""

local one = "*"

local two = "**"

local three = "***"

local four = "****"

local five = "*****"

local six = "******"

if wanted == 0 then

setElementData ( thePlayer, "Wanted", zero )

else if wanted == 1 then

setElementData ( thePlayer, "Wanted", one )

else if wanted == 2 then

setElementData ( thePlayer, "Wanted", two )

else if wanted == 3 then

setElementData ( thePlayer, "Wanted", three )

else if wanted == 4 then

setElementData ( thePlayer, "Wanted", four )

else if wanted == 5 then

setElementData ( thePlayer, "Wanted", five )

else if wanted == 6 then

setElementData ( thePlayer, "Wanted", six )

end

end

end

end

end

end

end

end

end

setTimer(getwan,100,0)

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

Clientside

function levelup ()

local Exp = getElementData(localPlayer,"ExP")

local Level = getElementData(localPlayer,"Level")

if isElement(expLabel) then destroyElement(expLabel) end

expLabel = guiCreateLabel(0.600,0.10,0.1708,0.0963,"New exp: ??\nExperience: ".. tostring(Exp) .."\nLevel: ".. tostring(Level),true)

guiLabelSetColor(expLabel,0,255,0)

guiLabelSetVerticalAlign(expLabel,"top")

guiLabelSetHorizontalAlign(expLabel,"left",false)

guiSetFont(expLabel,"clear-normal")

setTimer ( levelup, 2000, 1)

end

setTimer ( levelup, 2000, 1)

Link to comment

Moved to "Scripting" section.

----------------------------------

function win ( killer ) 
    if ( killer and getElementType ( killer ) == "player" ) then 
        local H = tonumber ( getElementData ( killer, "ExP" ) ) or 0 
        local S = getElementData ( killer, "Level" ) 
        setElementData ( killer, "ExP", H + 1 ) 
        if ( levels [ H ] ) then 
            setElementData ( killer, "Level", "Lvl ".. tostring ( levels [ H ] ) .." !" ) 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
end 
addEvent ( "onZombieWasted", true ) 
addEventHandler ( "onZombieWasted", getRootElement(), win ) 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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