Jump to content

Help with setTimer


Resto

Recommended Posts

You mean the progress bar in bottom of your screen that shows your current level and experience and required experience for the next level? if so, then that is not included in the "exp_system" resource, you need to make it yourself.

Yes i mean this.. and this is where? this have 20 servers..

f4sfa7a7sa1FSS.png

Link to comment
You can make that with dx drawing functions.
dxDrawRectangle 
dxDrawText 

And the exported functions "getLevelData", "getPlayerLevel" and "getPlayerEXP" from the "exp_system".

Can you help me create code? or where is this script?

Link to comment
If I may interrupt...

Resto, will be better for you If you try do it by yourself. Just try to create some code. If it doesn't work - no problem, we will help you. We just want to try learning you some things.

Cheers.

And this why not work? i want only updates

exports.scoreboard:addScoreboardColumn('Level') 
  
function updateStats(plr) 
    local acc = getPlayerAccount(plr) 
    local accName = getAccountName(acc) 
    local zKills = getAccountData(acc, "Zombie Kills") or 0 
    if zKills >= 0 and zKills <= 5 then 
        setAccountData(acc, "Level", 1) 
    elseif zKills >= 5 and zKills <= 10 then 
        setAccountData(acc, "Level", 2) 
    end 
end 
  
function getAllPlayers() 
    local players = getElementsByType("player") 
    for k, v in pairs(players) do 
        updateStats(v) 
    end 
end 
  
setTimer(getAllPlayers, 5000, 0) 

Link to comment

I already gave you a working code for that, you need to change the "Zombie Kills" to "Zombie kills", since the script you use to set the data uses that.

You need to keep in mind that you have to put exactly the same data name ( check for capital letters/etc ).

Link to comment
I already gave you a working code for that, you need to change the "Zombie Kills" to "Zombie kills", since the script you use to set the data uses that.

You need to keep in mind that you have to put exactly the same data name ( check for capital letters/etc ).

but there is from [5] to [6] and reward money i dont want..

Link to comment

I add this:

addEvent ( "onZombieWasted", true ) 
addEventHandler ( "onZombieWasted", root, 
    function ( theKiller ) 
        exports.exp_system:addPlayerEXP ( theKiller, 1 ) 
    end 
) 

But experience here not added:

local sx, sy = guiGetScreenSize() 
  
function drawExperience() 
    dxDrawRectangle((310/1024)*sx,(698/768)*sy,(481/1024)*sx,(36/768)*sy,tocolor(0,0,0,125),false) 
    dxDrawRectangle((315/1024)*sx,(703/768)*sy,(472/1024)*sx,(26/768)*sy,tocolor(255,0,0,55),false) 
    local experience = getElementData(localPlayer,"experience") or 0 
    local experience_n = getElementData(localPlayer,"experience_n") or 0 
    local level = getElementData(localPlayer,"LeveL") or 1 
    local percent = (experience / experience_n * 100) 
    if (percent >= 100) then 
        percent = 100 
    elseif (experience_n < 1) then 
        percent = 0 
    end 
    dxDrawRectangle((320/1024)*sx,(706/768)*sy,(tonumber(percent)*4.64/1024)*sx,(20/768)*sy,tocolor(0,0,0,75),false) 
    dxDrawBorderedText("LeveL: ".. tostring(level) .." | Experience Points: ".. tostring(experience) .." > ".. tostring(experience_n),(430/1024)*sx,(707/768)*sy,(667/1024)*sx,(724/768)*sy,tocolor(255,0,0,255),(sx/1024)*0.6,"bankgothic","center","center",false,false,false) 
end 
addEventHandler("onClientRender",root,drawExperience) 
  
function dxDrawBorderedText( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) 
    dxDrawText ( text, x - 1, y - 1, w - 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black 
    dxDrawText ( text, x + 1, y - 1, w + 1, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x - 1, y + 1, w - 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x + 1, y + 1, w + 1, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x - 1, y, w - 1, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x + 1, y, w + 1, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y - 1, w, h - 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y + 1, w, h + 1, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) 
    dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) 
end 
  
  
  
addEvent ( "LevelUpEffect", true ) 
addEventHandler ( "LevelUpEffect", root, 
    function ( ) 
        PlayerLevelUpSound() 
        addEventHandler("onClientRender",root,DrawLevelUp) 
        setTimer(function() 
            removeEventHandler("onClientRender",root,DrawLevelUp) 
        end, 4000, 1) 
    end 
) 
  
function PlayerLevelUpSound() 
    local sound = playSound("levelup.mp3") 
    setSoundVolume(sound, 1) 
end 
  
function DrawLevelUp() 
    dxDrawBorderedText( "[!] LEVEL UP [!]", sx/2, sy/15, sx/2, sx/2, tocolor(255,144,0,255),(sx/1024)*2.5,"bankgothic","center","center",false,false,false ) 
end 
  
  

And i had 283 zombie kills and when i go reconnect or join later i have always 283:

function addPlayerZombieKills(killer) 
    local account = getPlayerAccount(killer) 
    if isGuestAccount(account) then return end 
    local zombieKills = getAccountData(account,"Zombie kills") 
    if not zombieKills then setAccountData(account,"Zombie kills",0) end 
    setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) 
end 
  
  
addEventHandler("onPlayerLogin",root, 
function () 
    local account = getPlayerAccount(source) 
    if isGuestAccount(account) then return end 
    local zombieKills = getAccountData(account,"Zombie kills") 
    if zombieKills then 
        setElementData(source,"Zombie kills",tostring(zombieKills)) 
    else 
        setElementData(source,"Zombie kills",0)     
  
end 
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...