Jump to content

Exp system


Recommended Posts

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Posted

im not using level.xml

im using this

exports.scoreboard:scoreboardAddColumn("ExP") 
exports.scoreboard:scoreboardAddColumn("Level") 
local levels = {[50] = 1, [100] = 2, [175] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11} 
  
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)+math.random ( 10, 80 ) ) 
        if levels[tonumber(H)] then 
            setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .."  ") 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local H = getElementData ( source, "ExP" ) or 0 
    setElementData ( source, "ExP", tonumber ( H ) - math.random ( 5, 50 ) ) 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "lvl") or "0") 
    setElementData(source, "ExP", getAccountData(account, "exp") or "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) 

and if i want change levels to like Example

Level 1 : Rookie

Level 2 : Amateur

Level 3 : Semi-pro

Level 4 : Pro

Level 5 : ELITE

Level 6 : Boss

can you help me ?

Do you want set the player level if write [[command]] ?

or do you want set the level name ?

Level change local levels to level name

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

anything else ?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

First, stop DOUBLE/TRIPLE posting, because is annoying.

Second, you can add a second value to your levels table, defining the name of the level.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Like that ?

exports.scoreboard:scoreboardAddColumn("ExP") 
exports.scoreboard:scoreboardAddColumn("Level") 
local levels = {[50] = Rookie, [100] = Amateur, [175] = SemiPro, [240] = Pro, [950] = Elite, [1200] = Boss, [2000] = Hero, [5000] = Evil, [9963] = Demon, [20000] = Criminal} 
  
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)+math.random ( 10, 80 ) ) 
        if levels[tonumber(H)] then 
            setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .."  ") 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local H = getElementData ( source, "ExP" ) or 0 
    setElementData ( source, "ExP", tonumber ( H ) - math.random ( 5, 50 ) ) 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "lvl") or "0") 
    setElementData(source, "ExP", getAccountData(account, "exp") or "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) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

No, that's not what I meant.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Is there a solution that if i removed the local levels

local levels = {[1] = 1, [50] = 2, [75] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11} 

it load levels from levels.xml ?

    "Rookie" experienceRequired = "2" /> 
    "Amateur" experienceRequired = "100" /> 
    "Semi-Pro" experienceRequired = "150" /> 
    "Pro" experienceRequired = "200" /> 
    "ELITE" experienceRequired = "2000" /> 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Why don't you just use my latest script?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

i used it but i dont know how it works(how much player earn if he killed someone or how much he lost if he get killed)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
addCommandHandler ( "setexp", 
    function ( thePlayer, _, who, theExP ) 
        local theExP = tonumber ( theExP ) or 0 
        local playerWho = getPlayerFromName ( who ) 
        if ( playerWho ) then 
            exports.exp_system:setPlayerEXP ( playerWho, theExP ) 
        end 
    end 
) 

it was working fine now it show a error in console

ERROR: attempt to call a nil value [string"?"]

ERROR: call:failed to call 'exp_system:setPlayerEXP' [string"?"]

help

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Does the resource export these functions?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

on meta yes

    

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

And script has the functions?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes

addCommandHandler ( "setexp", 
    function ( thePlayer, _, who, theExP ) 
        local theExP = tonumber ( theExP ) or 0 
        local playerWho = getPlayerFromName ( who ) 
        if ( playerWho ) then 
            exports.exp_system:setPlayerEXP ( playerWho, theExP ) 
        end 
    end 
) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

You don't understand, does the resource "exp_system" have the functions that are being exported?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

i don't understand sorry. :(

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

To me, it looks like you've copied the exports from the meta.xml of my "exp_system" and pasted it on that resource, without the actual functions, it won't work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

yes, that what i do, there isn't a solution?

anything else ?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Castillo, can you explain me please?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

no another one

using this

exports.scoreboard:scoreboardAddColumn("ExP") 
exports.scoreboard:scoreboardAddColumn("Level") 
local levels = {[50] = 1, [100] = 2, [175] = 3, [240] = 4, [950] = 5, [1200] = 6, [2000] = 7, [5000] = 8, [9963] = 9, [20000] = 10, [100000] = 11} 
  
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)+math.random ( 10, 80 ) ) 
        if levels[tonumber(H)] then 
            setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .."  ") 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local H = getElementData ( source, "ExP" ) or 0 
    setElementData ( source, "ExP", tonumber ( H ) - math.random ( 5, 50 ) ) 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "lvl") or "0") 
    setElementData(source, "ExP", getAccountData(account, "exp") or "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) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Castillo can u help me ?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

You can't copy the exported functions from one resource without having them on the script itself.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

So what i need to do?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Create your own functions or just set element data.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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