Jump to content

Exp system


Recommended Posts

Posted

Hello i have this exp_system and i want two things on it i tryed but not working here is the lua

exports.scoreboard:scoreboardAddColumn("ExP") 
exports.scoreboard:scoreboardAddColumn("Level") 
local levels = {[1] = 1, [50] = 2, [75] = 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)+75) 
        if levels[tonumber(H)] then 
            setElementData(killer, "Level", "Lvl ".. tostring(levels[tonumber(H)]) .." !") 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    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 "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) 

I want when player kill somebody he earn Random Experience i tryed adding this but not working math.random ( 5, 35 )

and when he get killed by somebody who had a higher exp he lose like math.random ( -5, -35 )

Thanks for helping

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.

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Why is not working? I don't see math.random anywhere on your script either.

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

that's the original one

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

The script you've posted works? and you want to add random experience?

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

Yeh :) and when player get killed he lost some experience

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
exports.scoreboard:scoreboardAddColumn("ExP") 
exports.scoreboard:scoreboardAddColumn("Level") 
local levels = {[1] = 1, [50] = 2, [75] = 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 ( 5, 35 ) ) 
        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, 35 ) ) 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Level", getAccountData(account, "lvl") or "Level 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) 

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

Thanks a lot bro you're the best and one more thing please

The command of get player experience dont work

function getRep ( commandName, playerName ) 
    if ( playerName ) then 
        local thePlayer = getPlayerFromName ( playerName ) 
        if ( thePlayer ) then 
            local ExP = getElementData ( thePlayer, "ExP" ) 
            outputChatBox ( getPlayerName ( thePlayer ) .." Reputation is ".. ExP "!", source ) 
        else 
            outputChatBox ( "Couldn't find '" .. playerName .. "'", source ) 
        end 
    end 
end 
addCommandHandler ( "getrep", getRep ) 

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

Is client side?

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 (edited)

yes

can i remove " Lvl " and "!" from

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

because when i remove it the script being crashed

Edited by Guest

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
function getRep ( _, playerName ) 
    if ( playerName ) then 
        local thePlayer = getPlayerFromName ( playerName ) 
        if ( thePlayer ) then 
            local ExP = getElementData ( thePlayer, "ExP" ) or 0 
            outputChatBox ( getPlayerName ( thePlayer ) .." Reputation is ".. tostring ( ExP ) .."!" ) 
        else 
            outputChatBox ( "Couldn't find '" .. playerName .. "'", source ) 
        end 
    end 
end 
addCommandHandler ( "getrep", getRep ) 

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

Castillo, i tryed this but not working can you fix it please

This for set player exp

addCommandHandler ( "setexp", 
    function ( thePlayer, commandName, theExP ) 
                local theExP = tonumber ( theExP ) or 0 
        exports.exp_system:setPlayerExP ( thePlayer, theExP ) 
    end 
) 

and this for set player level

addCommandHandler ( "setlevel", 
    function ( thePlayer, commandName, theLevel ) 
                local theLevel = tonumber ( theLevel ) or 1 
        exports.exp_system:setPlayerLevel ( thePlayer, theLEvel ) 
    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

Errors on debugscript?

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

no errors :(

    function ( thePlayer, commandName, theLevel , playerName) 

what about this ?

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

The resource "exp_system" has these exported 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 on meta

    function="getPlayerLevel" type="server" /> -- arguments: thePlayer --> 
    function="setPlayerLevel" type="server" /> -- arguments: thePlayer, theLevel  --> 
    function="getPlayerEXP" type="server" /> -- arguments: thePlayer --> 
    function="setPlayerEXP" type="server" /> -- arguments: thePlayer, theExperience  -->   
    function="addPlayerEXP" type="server" /> -- arguments: thePlayer, theExperience  -->   
     
    function="getAccountLevel" type="server" /> -- arguments: theAccount --> 
    function="setAccountLevel" type="server" /> -- arguments: theAccount, theLevel  --> 
    function="getAccountEXP" type="server" /> -- arguments: theAccount --> 
    function="setAccountEXP" type="server" /> -- arguments: theAccount, theExperience  -->     
    function="addAccountEXP" type="server" /> -- arguments: theAccount, theExperience  --> 
    function="getLevelData" type="server" /> -- arguments: theLevel  --> 

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

It's "setPlayerEXP" not "setPlayerExP".

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

Oh ok, i will try it

it set exp only for me not for other players

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

That's because it's what the script does.

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

ok but there isnt a solution for set player exp ?

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 
) 

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

thanks but what about the music script

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

What music 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

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 ?

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

Sha67 سابقاً

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