Jump to content

Player don't level up help please


Recommended Posts

Hello all, i have a bug with this script, it wont level up when somebody reach the experience required for here is the code.

function win(ammo, killer, weapon, bodypart) 
    if (killer and killer ~= source) then 
        local H = getElementData(killer, "XP") 
        local S = getElementData(killer, "Level") 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        setElementData(killer, "XP", tonumber(H)+math.random ( 5, 70 ) ) 
        if tonumber(H) == 100 then 
        setElementData(killer, "Level", "Lvl 1") 
        elseif tonumber(H) == 400 then 
        setElementData(killer, "Level", "Lvl 2") 
        elseif tonumber(H) == 600 then 
        setElementData(killer, "Level", "Lvl 3") 
        elseif tonumber(H) == 800 then 
        setElementData(killer, "Level", "Lvl 4") 
        elseif tonumber(H) == 1000 then 
        setElementData(killer, "Level", "Lvl 5") 
        elseif tonumber(H) == 1200 then 
        setElementData(killer, "Level", "Lvl 6") 
        elseif tonumber(H) == 1400 then 
        setElementData(killer, "Level", "Lvl 7") 
        elseif tonumber(H) == 1600 then 
        setElementData(killer, "Level", "Lvl 8") 
        elseif tonumber(H) == 1800 then 
        setElementData(killer, "Level", "Lvl 9") 
        elseif tonumber(H) == 2000 then 
        setElementData(killer, "Level", "Lvl 10") 
        elseif tonumber(H) == 2200 then 
        setElementData(killer, "Level", "Lvl 11") 
        elseif tonumber(H) == 2400 then 
        setElementData(killer, "Level", "Lvl 12") 
        elseif tonumber(H) == 2600 then 
        setElementData(killer, "Level", "Lvl 13") 
        elseif tonumber(H) == 2800 then 
        setElementData(killer, "Level", "Lvl 14") 
        elseif tonumber(H) == 4000 then 
        setElementData(killer, "Level", "Lvl 15") 
        elseif tonumber(H) == 4200 then 
        setElementData(killer, "Level", "Lvl 16") 
        elseif tonumber(H) == 4400 then 
        setElementData(killer, "Level", "Lvl 17") 
        elseif tonumber(H) == 4600 then 
        setElementData(killer, "Level", "Lvl 18") 
        elseif tonumber(H) == 4800 then 
        setElementData(killer, "Level", "Lvl 19") 
        elseif tonumber(H) == 4900 then 
        setElementData(killer, "Level", "Lvl 20") 
        elseif tonumber(H) == 7000 then 
        setElementData(killer, "Level", "Lvl 21") 
        elseif tonumber(H) == 9000 then 
        setElementData(killer, "Level", "Lvl 22") 
        elseif tonumber(H) == 15999 then 
        setElementData(killer, "Level", "Lvl 23") 
        end 
    end 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "LV") or "0") 
    setElementData(source, "XP", getAccountData(account, "EXP") or "0") 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(thePlayer, "Level")) 
        setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

Link to comment
function win(ammo, killer, weapon, bodypart) 
    if (killer and getElementType(killer) == "player" and killer ~= source) then 
        local H = getElementData(killer, "XP") or 0 
        local S = getElementData(killer, "Level") 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        local X = math.random(5, 70) 
        setElementData(killer, "XP", tonumber(H)+X) 
        local H = tonumber(H) + X 
        if tonumber(H) == 100 then 
        setElementData(killer, "Level", "Lvl 1") 
        elseif tonumber(H) == 400 then 
        setElementData(killer, "Level", "Lvl 2") 
        elseif tonumber(H) == 600 then 
        setElementData(killer, "Level", "Lvl 3") 
        elseif tonumber(H) == 800 then 
        setElementData(killer, "Level", "Lvl 4") 
        elseif tonumber(H) == 1000 then 
        setElementData(killer, "Level", "Lvl 5") 
        elseif tonumber(H) == 1200 then 
        setElementData(killer, "Level", "Lvl 6") 
        elseif tonumber(H) == 1400 then 
        setElementData(killer, "Level", "Lvl 7") 
        elseif tonumber(H) == 1600 then 
        setElementData(killer, "Level", "Lvl 8") 
        elseif tonumber(H) == 1800 then 
        setElementData(killer, "Level", "Lvl 9") 
        elseif tonumber(H) == 2000 then 
        setElementData(killer, "Level", "Lvl 10") 
        elseif tonumber(H) == 2200 then 
        setElementData(killer, "Level", "Lvl 11") 
        elseif tonumber(H) == 2400 then 
        setElementData(killer, "Level", "Lvl 12") 
        elseif tonumber(H) == 2600 then 
        setElementData(killer, "Level", "Lvl 13") 
        elseif tonumber(H) == 2800 then 
        setElementData(killer, "Level", "Lvl 14") 
        elseif tonumber(H) == 4000 then 
        setElementData(killer, "Level", "Lvl 15") 
        elseif tonumber(H) == 4200 then 
        setElementData(killer, "Level", "Lvl 16") 
        elseif tonumber(H) == 4400 then 
        setElementData(killer, "Level", "Lvl 17") 
        elseif tonumber(H) == 4600 then 
        setElementData(killer, "Level", "Lvl 18") 
        elseif tonumber(H) == 4800 then 
        setElementData(killer, "Level", "Lvl 19") 
        elseif tonumber(H) == 4900 then 
        setElementData(killer, "Level", "Lvl 20") 
        elseif tonumber(H) == 7000 then 
        setElementData(killer, "Level", "Lvl 21") 
        elseif tonumber(H) == 9000 then 
        setElementData(killer, "Level", "Lvl 22") 
        elseif tonumber(H) == 15999 then 
        setElementData(killer, "Level", "Lvl 23") 
        end 
    end 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "LV") or "0") 
    setElementData(source, "XP", getAccountData(account, "EXP") or "0") 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(thePlayer, "Level")) 
        setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

Link to comment

Not false, it's just your comparison won't equal.

if you want it work, you'll have to change this line

local X = math.random(5, 70) 

to

local X = 100 

Otherwise you have to change your comparison and use < and > and <= and >=

Link to comment
  • 1 month later...
  • Moderators
    function win(ammo, killer, weapon, bodypart) 
        if (killer and getElementType(killer) == "player" and killer ~= source) then 
            local H = getElementData(killer, "XP") or 0 
            --local S = getElementData(killer, "Level") 
            local killer1 = getPlayerName(killer) 
            local noob = getPlayerName(source) 
            local X = math.random(5, 70) 
            setElementData(killer, "XP", tonumber(H)+X) 
            local H = tonumber(H) + X 
            if tonumber(H) <= 100 then 
            setElementData(killer, "Level", "Lvl 0") 
            elseif tonumber(H) <= 400 then 
            setElementData(killer, "Level", "Lvl 1") 
            elseif tonumber(H) <= 600 then 
            setElementData(killer, "Level", "Lvl 2") 
            elseif tonumber(H) <= 800 then 
            setElementData(killer, "Level", "Lvl 3") 
            elseif tonumber(H) <= 1000 then 
            setElementData(killer, "Level", "Lvl 4") 
            elseif tonumber(H) <= 1200 then 
            setElementData(killer, "Level", "Lvl 5") 
            elseif tonumber(H) <= 1400 then 
            setElementData(killer, "Level", "Lvl 6") 
            elseif tonumber(H) <= 1600 then 
            setElementData(killer, "Level", "Lvl 7") 
            elseif tonumber(H) <= 1800 then 
            setElementData(killer, "Level", "Lvl 8") 
            elseif tonumber(H) <= 2000 then 
            setElementData(killer, "Level", "Lvl 9") 
            elseif tonumber(H) <= 2200 then 
            setElementData(killer, "Level", "Lvl 10") 
            elseif tonumber(H) <= 2400 then 
            setElementData(killer, "Level", "Lvl 11") 
            elseif tonumber(H) <= 2600 then 
            setElementData(killer, "Level", "Lvl 12") 
            elseif tonumber(H) <= 2800 then 
            setElementData(killer, "Level", "Lvl 13") 
            elseif tonumber(H) <= 4000 then 
            setElementData(killer, "Level", "Lvl 14") 
            elseif tonumber(H) <= 4200 then 
            setElementData(killer, "Level", "Lvl 15") 
            elseif tonumber(H) <= 4400 then 
            setElementData(killer, "Level", "Lvl 16") 
            elseif tonumber(H) <= 4600 then 
            setElementData(killer, "Level", "Lvl 17") 
            elseif tonumber(H) <= 4800 then 
            setElementData(killer, "Level", "Lvl 18") 
            elseif tonumber(H) <= 4900 then 
            setElementData(killer, "Level", "Lvl 19") 
            elseif tonumber(H) <= 7000 then 
            setElementData(killer, "Level", "Lvl 20") 
            elseif tonumber(H) <= 9000 then 
            setElementData(killer, "Level", "Lvl 21") 
            elseif tonumber(H) <= 15999 then 
            setElementData(killer, "Level", "Lvl 22") 
            elseif tonumber(H) > 15999 then 
            setElementData(killer, "Level", "Lvl 23") 
            end 
        end 
    end 
    addEventHandler( "onPlayerWasted", getRootElement(), win) 
      
    function onLogin (_,account) 
        setElementData(source, "Level", getAccountData(account, "LV") or "Lvl 0") 
        setElementData(source, "XP", getAccountData(account, "EXP") or 0) 
    end 
    addEventHandler ("onPlayerLogin", root, onLogin) 
      
    function saveData(thePlayer, theAccount) 
    --local theAccount = getPlayerAccount(source) -- you already have the account.....  fu nonsens ! 
        if (theAccount and not isGuestAccount(theAccount)) then 
            setAccountData (theAccount, "LV", getElementData(thePlayer, "Level") or 0) 
            setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP")  or 0) 
        end 
    end 
      
    addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
    addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

If you say again that it didn't work or bumb again I will start give sarcastic comments on all your fu topics. :x

Link to comment
    function win(ammo, killer, weapon, bodypart) 
        if (killer and getElementType(killer) == "player" and killer ~= source) then 
            local H = getElementData(killer, "XP") or 0 
            --local S = getElementData(killer, "Level") 
            local killer1 = getPlayerName(killer) 
            local noob = getPlayerName(source) 
            local X = math.random(5, 70) 
            setElementData(killer, "XP", tonumber(H)+X) 
            local H = tonumber(H) + X 
            if tonumber(H) <= 100 then 
            setElementData(killer, "Level", "Lvl 0") 
            elseif tonumber(H) <= 400 then 
            setElementData(killer, "Level", "Lvl 1") 
            elseif tonumber(H) <= 600 then 
            setElementData(killer, "Level", "Lvl 2") 
            elseif tonumber(H) <= 800 then 
            setElementData(killer, "Level", "Lvl 3") 
            elseif tonumber(H) <= 1000 then 
            setElementData(killer, "Level", "Lvl 4") 
            elseif tonumber(H) <= 1200 then 
            setElementData(killer, "Level", "Lvl 5") 
            elseif tonumber(H) <= 1400 then 
            setElementData(killer, "Level", "Lvl 6") 
            elseif tonumber(H) <= 1600 then 
            setElementData(killer, "Level", "Lvl 7") 
            elseif tonumber(H) <= 1800 then 
            setElementData(killer, "Level", "Lvl 8") 
            elseif tonumber(H) <= 2000 then 
            setElementData(killer, "Level", "Lvl 9") 
            elseif tonumber(H) <= 2200 then 
            setElementData(killer, "Level", "Lvl 10") 
            elseif tonumber(H) <= 2400 then 
            setElementData(killer, "Level", "Lvl 11") 
            elseif tonumber(H) <= 2600 then 
            setElementData(killer, "Level", "Lvl 12") 
            elseif tonumber(H) <= 2800 then 
            setElementData(killer, "Level", "Lvl 13") 
            elseif tonumber(H) <= 4000 then 
            setElementData(killer, "Level", "Lvl 14") 
            elseif tonumber(H) <= 4200 then 
            setElementData(killer, "Level", "Lvl 15") 
            elseif tonumber(H) <= 4400 then 
            setElementData(killer, "Level", "Lvl 16") 
            elseif tonumber(H) <= 4600 then 
            setElementData(killer, "Level", "Lvl 17") 
            elseif tonumber(H) <= 4800 then 
            setElementData(killer, "Level", "Lvl 18") 
            elseif tonumber(H) <= 4900 then 
            setElementData(killer, "Level", "Lvl 19") 
            elseif tonumber(H) <= 7000 then 
            setElementData(killer, "Level", "Lvl 20") 
            elseif tonumber(H) <= 9000 then 
            setElementData(killer, "Level", "Lvl 21") 
            elseif tonumber(H) <= 15999 then 
            setElementData(killer, "Level", "Lvl 22") 
            elseif tonumber(H) > 15999 then 
            setElementData(killer, "Level", "Lvl 23") 
            end 
        end 
    end 
    addEventHandler( "onPlayerWasted", getRootElement(), win) 
      
    function onLogin (_,account) 
        setElementData(source, "Level", getAccountData(account, "LV") or "Lvl 0") 
        setElementData(source, "XP", getAccountData(account, "EXP") or 0) 
    end 
    addEventHandler ("onPlayerLogin", root, onLogin) 
      
    function saveData(thePlayer, theAccount) 
    --local theAccount = getPlayerAccount(source) -- you already have the account.....  fu nonsens ! 
        if (theAccount and not isGuestAccount(theAccount)) then 
            setAccountData (theAccount, "LV", getElementData(thePlayer, "Level") or 0) 
            setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP")  or 0) 
        end 
    end 
      
    addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
    addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

If you say again that it didn't work or bumb again I will start give sarcastic comments on all your fu topics. :x

relax Bro

Link to comment
  • Moderators

@CastielRecords

Maybe you should find the definition of 'bro', because I am not even close your "bro".

:|

I am relaxed, telling me that I should relax will cause the opposite. :!:

I will not visiting this subtopic any more, post anything after this towards me would be useless.

Link to comment
function win( ammo, killer, weapon, bodypart ) 
    if ( killer and getElementType( killer ) == "player" and killer ~= source ) then 
        local H = tonumber( getElementData( killer, "XP" ) ) or 0 
        local S = getElementData( killer, "Level" ) 
        local killer1 = getPlayerName( killer ) 
        local noob = getPlayerName( source ) 
        local X = math.random( 5, 70 ) 
        setElementData( killer, "XP", H + X ) 
        local H = H + X 
        if ( H == 100 ) then 
            setElementData(killer, "Level", "Lvl 1") 
        elseif ( H == 400 ) then 
            setElementData(killer, "Level", "Lvl 2") 
        elseif ( H == 600 ) then 
            setElementData(killer, "Level", "Lvl 3") 
        elseif ( H == 800 ) then 
            setElementData(killer, "Level", "Lvl 4") 
        elseif ( H == 1000 ) then 
            setElementData(killer, "Level", "Lvl 5") 
        elseif ( H == 1200 ) then 
            setElementData(killer, "Level", "Lvl 6") 
        elseif ( H == 1400 ) then 
            setElementData(killer, "Level", "Lvl 7") 
        elseif ( H == 1600 ) then 
            setElementData(killer, "Level", "Lvl 8") 
        elseif ( H == 1800 ) then 
            setElementData(killer, "Level", "Lvl 9") 
        elseif ( H == 2000 ) then 
            setElementData(killer, "Level", "Lvl 10") 
        elseif ( H == 2200 ) then 
            setElementData(killer, "Level", "Lvl 11") 
        elseif ( H == 2400 ) then 
            setElementData(killer, "Level", "Lvl 12") 
        elseif ( H == 2600 ) then 
            setElementData(killer, "Level", "Lvl 13") 
        elseif ( H == 2800 ) then 
            setElementData(killer, "Level", "Lvl 14") 
        elseif ( H == 4000 ) then 
            setElementData(killer, "Level", "Lvl 15") 
        elseif ( H == 4200 ) then 
            setElementData(killer, "Level", "Lvl 16") 
        elseif ( H == 4400 ) then 
            setElementData(killer, "Level", "Lvl 17") 
        elseif ( H == 4600 ) then 
            setElementData(killer, "Level", "Lvl 18") 
        elseif ( H == 4800 ) then 
            setElementData(killer, "Level", "Lvl 19") 
        elseif ( H == 4900 ) then 
            setElementData(killer, "Level", "Lvl 20") 
        elseif ( H == 7000 ) then 
            setElementData(killer, "Level", "Lvl 21") 
        elseif ( H == 9000 ) then 
            setElementData(killer, "Level", "Lvl 22") 
        elseif ( H == 15999 ) then 
            setElementData(killer, "Level", "Lvl 23") 
        end 
    end 
end 
addEventHandler( "onPlayerWasted", root, win) 
  
function onLogin ( ) 
    local account = getAccountName ( getPlayerAccount ( source ) ) 
    if ( account ) then 
        setElementData(source, "Level", getAccountData(account, "LV") or "0" ) 
        setElementData(source, "XP", getAccountData(account, "EXP") or "0" ) 
    end 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function saveData(quitType, reason, responsibleElement) 
local theAccount = getPlayerAccount( source ) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "LV", getElementData(source, "Level")) 
        setAccountData (theAccount, "EXP", getElementData(source, "XP")) 
    end 
end 
addEventHandler ("onPlayerQuit", root, saveData ) 
addEventHandler ("onPlayerLogout", root, saveData ) 

This Must work You was make some fails :3 at save and load data and at function win

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