Jump to content

EXP script


OrbTanT

Recommended Posts

How can I leave on the scoreboard, the value of "Level".

exports [ "scoreboard" ]:addScoreboardColumn ( "Level", 4 ) 
  
function level ( player, Level ) 
    for index, player in ipairs ( getElementsByType "player" ) do 
        local account = getAccountData ( player ) 
        local Level = 1 
        local myExp = setAccountData ( account, player) 
    end 
end 

MUST have some errors, first time with getAccountData and setAccountData.

Link to comment

Is not working, create a column "level" more does not show the level of the player, right way to use setElementData?

exports [ "scoreboard" ]:addScoreboardColumn ( "Level", 4 ) 
  
addCommandHandler ( "mylevel", 
    function ( player, theLevel ) 
        for index, player in ipairs ( getElementsByType "player" ) do 
            local account = getAccountData ( player ) 
            local theLevel = 1 
            local myExp = setAccountData ( account, player) 
            setElementData ( player, "Level", theLevel ) 
  
        end 
    end 
) 

Link to comment

How can I save the XPs and LVLs when the player exits the game and load, xp and lvl when you enter.

exports.scoreboard:scoreboardAddColumn("EXP") 
exports.scoreboard:scoreboardAddColumn("Level") 
  
function level () 
    for index, player in ipairs ( getElementsByType "player" ) do 
        setElementData( player, "Level", "lvl 1") 
        setElementData( player, "EXP", 0) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), level) 
  
function levelup (ammo, killer, weapon, bodypart) 
    local XP = getElementData(killer, "EXP") 
    local LVL = getElementData(killer, "Level") 
        if killer and killer ~=source then 
            setElementData(killer, "EXP", tonumber(XP)+10) 
            if tonumber(XP) == 100 then 
                setElementData(killer, "Level", "lvl 2") 
            elseif tonumber(XP) == 200 then 
                setElementData(killer, "Level", "lvl 3") 
            elseif tonumber(XP) == 300 then 
                setElementData(killer, "Level", "lvl 4") 
            elseif tonumber(XP) == 400 then 
                setElementData(killer, "Level", "lvl 5") 
            elseif tonumber(XP) == 500 then 
                setElementData(killer, "Level", "lvl 6") 
            elseif tonumber(XP) == 600 then 
                setElementData(killer, "Level", "lvl 7") 
            elseif tonumber(XP) == 700 then 
                setElementData(killer, "Level", "lvl 8") 
            elseif tonumber(XP) == 800 then 
                setElementData(killer, "Level", "lvl 9") 
            elseif tonumber(XP) == 900 then 
                setElementData(killer, "Level", "lvl 10") 
            end 
        end 
end 
addEventHandler("onPlayerWasted", getRootElement(), levelup) 

Link to comment
How can I save the XPs and LVLs when the player exits the game and load, xp and lvl when you enter.
exports.scoreboard:scoreboardAddColumn("EXP") 
exports.scoreboard:scoreboardAddColumn("Level") 
  
function level () 
    for index, player in ipairs ( getElementsByType "player" ) do 
        setElementData( player, "Level", "lvl 1") 
        setElementData( player, "EXP", 0) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), level) 
  
function levelup (ammo, killer, weapon, bodypart) 
    local XP = getElementData(killer, "EXP") 
    local LVL = getElementData(killer, "Level") 
        if killer and killer ~=source then 
            setElementData(killer, "EXP", tonumber(XP)+10) 
            if tonumber(XP) == 100 then 
                setElementData(killer, "Level", "lvl 2") 
            elseif tonumber(XP) == 200 then 
                setElementData(killer, "Level", "lvl 3") 
            elseif tonumber(XP) == 300 then 
                setElementData(killer, "Level", "lvl 4") 
            elseif tonumber(XP) == 400 then 
                setElementData(killer, "Level", "lvl 5") 
            elseif tonumber(XP) == 500 then 
                setElementData(killer, "Level", "lvl 6") 
            elseif tonumber(XP) == 600 then 
                setElementData(killer, "Level", "lvl 7") 
            elseif tonumber(XP) == 700 then 
                setElementData(killer, "Level", "lvl 8") 
            elseif tonumber(XP) == 800 then 
                setElementData(killer, "Level", "lvl 9") 
            elseif tonumber(XP) == 900 then 
                setElementData(killer, "Level", "lvl 10") 
            end 
        end 
end 
addEventHandler("onPlayerWasted", getRootElement(), levelup) 

I , Just hate when someone's steal My Codes , Why Don't you meak your Own ?

Link to comment
How can I save the XPs and LVLs when the player exits the game and load, xp and lvl when you enter.
exports.scoreboard:scoreboardAddColumn("EXP") 
exports.scoreboard:scoreboardAddColumn("Level") 
  
function level () 
    for index, player in ipairs ( getElementsByType "player" ) do 
        setElementData( player, "Level", "lvl 1") 
        setElementData( player, "EXP", 0) 
    end 
end 
addEventHandler("onPlayerLogin", getRootElement(), level) 
  
function levelup (ammo, killer, weapon, bodypart) 
    local XP = getElementData(killer, "EXP") 
    local LVL = getElementData(killer, "Level") 
        if killer and killer ~=source then 
            setElementData(killer, "EXP", tonumber(XP)+10) 
            if tonumber(XP) == 100 then 
                setElementData(killer, "Level", "lvl 2") 
            elseif tonumber(XP) == 200 then 
                setElementData(killer, "Level", "lvl 3") 
            elseif tonumber(XP) == 300 then 
                setElementData(killer, "Level", "lvl 4") 
            elseif tonumber(XP) == 400 then 
                setElementData(killer, "Level", "lvl 5") 
            elseif tonumber(XP) == 500 then 
                setElementData(killer, "Level", "lvl 6") 
            elseif tonumber(XP) == 600 then 
                setElementData(killer, "Level", "lvl 7") 
            elseif tonumber(XP) == 700 then 
                setElementData(killer, "Level", "lvl 8") 
            elseif tonumber(XP) == 800 then 
                setElementData(killer, "Level", "lvl 9") 
            elseif tonumber(XP) == 900 then 
                setElementData(killer, "Level", "lvl 10") 
            end 
        end 
end 
addEventHandler("onPlayerWasted", getRootElement(), levelup) 

I , Just hate when someone's steal My Codes , Why Don't you meak your Own ?

Cuz it's easier to steal

Link to comment
exports.scoreboard:scoreboardAddColumn("EXP") 
exports.scoreboard:scoreboardAddColumn("Level") 
  
function levelup (ammo, killer, weapon, bodypart) 
    if (killer and getElementType(killer) == "player" and killer ~= source) then 
        local XP = getElementData(killer, "EXP") or 0 
        local LVL = getElementData(killer, "Level") or 1 
        setElementData(killer, "EXP", tonumber(XP)+10) 
        if tonumber(XP) == 100 then 
            setElementData(killer, "Level", 2) 
        elseif tonumber(XP) == 200 then 
            setElementData(killer, "Level", 3) 
        elseif tonumber(XP) == 300 then 
            setElementData(killer, "Level", 4) 
        elseif tonumber(XP) == 400 then 
            setElementData(killer, "Level", 5) 
        elseif tonumber(XP) == 500 then 
            setElementData(killer, "Level", 6) 
        elseif tonumber(XP) == 600 then 
            setElementData(killer, "Level", 7) 
        elseif tonumber(XP) == 700 then 
            setElementData(killer, "Level", 7) 
        elseif tonumber(XP) == 800 then 
            setElementData(killer, "Level", 7) 
        elseif tonumber(XP) == 900 then 
            setElementData(killer, "Level", 10) 
        end 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), levelup) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "Level") or 1) 
    setElementData(source, "EXP", getAccountData(account, "EXP") or 0) 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function onLogout (_,account) 
    setElementData(source, "Level", 0) 
    setElementData(source, "EXP", 0) 
end 
addEventHandler ("onPlayerLogout", root, onLogout) 
  
function saveData(thePlayer, theAccount) 
local theAccount = getPlayerAccount(source) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "Level", getElementData(thePlayer, "Level")) 
        setAccountData (theAccount, "EXP", getElementData(thePlayer, "EXP")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, 
function () 
    saveData(source, getPlayerAccount(source)) 
end) 
  
addEventHandler ("onPlayerLogout", root, 
function ()  
    saveData(source, getPlayerAccount(source))  
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...