Jump to content

Need help !!


Recommended Posts

Posted

I have another trouble if player like example have in experience 112 he don't move to level 1.

P.S : It was working fine.

here's the lua

exports.scoreboard:scoreboardAddColumn("Level") 
local levels = {[100] = 1, [200] = 2, [300] = 3, [400] = 4, [500] = 5, [1000] = 6, [2500] = 7, [5000] = 8, [7000] = 9, [10000] = 10, [15000] = 11, [20000] = 12, [30000] = 13, [55000] = 14, [65000] = 15} 
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

Try this :

exports.scoreboard:scoreboardAddColumn( "Level" ); 
  
local levels = {  
    [ 100 ] = 1,  
    [ 200 ] = 2, 
    [ 300 ] = 3,  
    [ 400 ] = 4,  
    [ 500 ] = 5,  
    [ 1000 ] = 6,  
    [ 2500 ] = 7,  
    [ 5000 ] = 8,  
    [ 7000 ] = 9,  
    [ 10000 ] = 10,  
    [ 15000 ] = 11,  
    [ 20000 ] = 12,  
    [ 30000 ] = 13,  
    [ 55000 ] = 14,  
    [ 65000 ] = 15 
}; 
  
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 ); 
        local setData = setElementData( killer, "ExP", tonumber( H ) + math.random( 10, 80 ) ); 
        if setData then 
            if levels[ getElementData( killer, "Exp" ) ] then 
                setElementData( killer, "Level", "Lvl ".. getElementData( killer, "Exp" ) .." ! " ); 
                triggerClientEvent( killer, "playSound", killer ); 
            end 
        end 
    end 
    local _H = getElementData( source, "ExP" ) or 0 
    setElementData( source, "ExP", tonumber( _H ) - math.random( 5, 50 ) ); 
end 
addEventHandler( "onPlayerWasted", root, 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 ); 

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted

still not working

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 errors !! its working fine but when player reach 100 exp or 101 exp he dont level up.

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.

  • Moderators
Posted

Because it only should work when his level is exp is 100 and exact 200....

+ math.random( 10, 80 )

logistic...

loop the table and compare and when you find the right information, break it. -_-"

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted

Like as sample:

  
local levels = { 
    {100,1}, 
    {200,2}, 
    {300,3}, 
    {400,4}, 
    {500,5}, 
    {1000,6}, 
    {2500,7}, 
    {5000,8}, 
    {7000,9}, 
    {10000,10}, 
    {15000,11}, 
    {20000,12}, 
    {30000,13}, 
    {55000,14}, 
    {65000,15} 
} 
  
local getLevel = function (xp) 
    for i=1,#levels do 
        local position = levels[i] 
        if xp => position[1] then 
            return position[2] 
        end 
    end 
end 
  
-- getLevel(xp) 
  

You also can create your own index start number to save cpu power.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

that's not 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.

  • Moderators
Posted

it is, as long you can script.

Else no, then you wasted my time.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

You're solution wont 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.

  • Moderators
Posted

Maybe you should first test it.

exports.scoreboard:scoreboardAddColumn("Level") 
  
local levels = { 
    {100,1}, 
    {200,2}, 
    {300,3}, 
    {400,4}, 
    {500,5}, 
    {1000,6}, 
    {2500,7}, 
    {5000,8}, 
    {7000,9}, 
    {10000,10}, 
    {15000,11}, 
    {20000,12}, 
    {30000,13}, 
    {55000,14}, 
    {65000,15} 
} 
  
local getLevel = function (xp,level) 
    for i=level,#levels do 
        local position = levels[i] 
        if xp => position[1] then 
            return position[2] 
        end 
    end 
end 
  
function win(ammo, killer, weapon, bodypart) 
    if (killer and killer ~= source) then 
        local H = getElementData(killer, "ExP")  or 0 
        local S = getElementData(killer, "Level") or 0 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        setElementData(killer, "ExP", tonumber(H)+math.random ( 10, 80 ) ) 
        local newLevel = getLevel(H,S+1) 
        if newLevel and newLevel ~= S then 
            setElementData(killer, "Level", "Lvl ".. tostring(newLevel) .." ! ") 
            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) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
Maybe you should first test it.
exports.scoreboard:scoreboardAddColumn("Level") 
  
local levels = { 
    {100,1}, 
    {200,2}, 
    {300,3}, 
    {400,4}, 
    {500,5}, 
    {1000,6}, 
    {2500,7}, 
    {5000,8}, 
    {7000,9}, 
    {10000,10}, 
    {15000,11}, 
    {20000,12}, 
    {30000,13}, 
    {55000,14}, 
    {65000,15} 
} 
  
local getLevel = function (xp,level) 
    for i=level,#levels do 
        local position = levels[i] 
        if xp => position[1] then 
            return position[2] 
        end 
    end 
end 
  
function win(ammo, killer, weapon, bodypart) 
    if (killer and killer ~= source) then 
        local H = getElementData(killer, "ExP")  or 0 
        local S = getElementData(killer, "Level") or 0 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        setElementData(killer, "ExP", tonumber(H)+math.random ( 10, 80 ) ) 
        local newLevel = getLevel(H,S+1) 
        if newLevel and newLevel ~= S then 
            setElementData(killer, "Level", "Lvl ".. tostring(newLevel) .." ! ") 
            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) 

ok i will test ...and thanks dude.

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.

  • Moderators
Posted (edited)

Saw another mistake, the new xp wasn't calculated for the leveling, but only for the elementdata. Of course in time it would be come correct, but it would not logistic. It have to be done within the locals.

Tell me if something doesn't work, I did not really test it. Based on logistic.

exports.scoreboard:scoreboardAddColumn("Level") 
  
local levels = { 
    {100,1}, 
    {200,2}, 
    {300,3}, 
    {400,4}, 
    {500,5}, 
    {1000,6}, 
    {2500,7}, 
    {5000,8}, 
    {7000,9}, 
    {10000,10}, 
    {15000,11}, 
    {20000,12}, 
    {30000,13}, 
    {55000,14}, 
    {65000,15} 
} 
  
local getLevel = function (xp,level) 
    for i=level,#levels do 
        local position = levels[i] 
        if xp >= position[1] then 
            local position2 = levels[i+1] 
            if position2 and xp < position2[1] then -- this is for the future when you are going to give more xp. 
                return position[2] 
            end 
        else 
            return false -- he didn't reached the next level. 
        end 
    end 
end 
  
function win(ammo, killer, weapon, bodypart) 
    if (killer and killer ~= source) then 
        local H = tonumber(getElementData(killer, "ExP")) or 0 
        local S = getElementData(killer, "Level") or 0 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        local newXP = H+math.random ( 10, 80 ) -- new xp, for the elementdata and level finder. 
        setElementData(killer, "ExP", newXP )  
        if S < #levels then -- stop doing things when he reached max level  
            local newLevel = getLevel(newXP,S+1) 
            if newLevel and newLevel ~= S then 
                setElementData(killer, "Level", "Lvl ".. tostring(newLevel) .." ! ") 
                triggerClientEvent ( killer, "playSound", killer ) 
            end 
        end 
    end 
    local H = tonumber (getElementData ( source, "ExP" )) or 0 
    setElementData ( source, "ExP", 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) 
  
local saveData = function (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) 

Edited by Guest

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

SCRIPT ERROR: exp_system\server.lua:24: 'then' expected near '='

WARNING: Loading script failed: exp_system\server.lua:24: 'then' expected near '='

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

i tried both, not working.

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.

  • Moderators
Posted
i tried both, not working.

Cause? I am not going to test it, it is your code.

It is your job to debug it, not mine. I can't help you if the only thing you say is "not working".

A system like that require lots of brain power, if you want it working then you have to debug it.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

I didn't asked about making it for me, i guess i posted the code and i need somebody to fix it.

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.

  • Moderators
Posted

I even get the feeling this isn't your code since you didn't try to debug it.

You seriously wasted my time, I will never try to help you again. :!:

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

It's not my code castillo maked it for me, and i have troubles in level up.

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.

  • Moderators
Posted
It's not my code castillo maked it for me, and i have troubles in level up.

Then now you just threw castillo's code on a global forum. :roll:

Wasted of his time don't you think....

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

No, I just helped him with it.

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

Help 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

Please help, there isn't another solution?

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.

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