-.Paradox.- Posted July 12, 2013 Posted July 12, 2013 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)
PaiN^ Posted July 12, 2013 Posted July 12, 2013 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 );
-.Paradox.- Posted July 12, 2013 Author Posted July 12, 2013 no errors !! its working fine but when player reach 100 exp or 101 exp he dont level up. anything else?
Moderators IIYAMA Posted July 12, 2013 Moderators Posted July 12, 2013 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. -_-"
Moderators IIYAMA Posted July 12, 2013 Moderators Posted July 12, 2013 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.
Moderators IIYAMA Posted July 13, 2013 Moderators Posted July 13, 2013 it is, as long you can script. Else no, then you wasted my time.
Moderators IIYAMA Posted July 13, 2013 Moderators Posted July 13, 2013 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)
-.Paradox.- Posted July 13, 2013 Author Posted July 13, 2013 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.
Moderators IIYAMA Posted July 13, 2013 Moderators Posted July 13, 2013 (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 July 13, 2013 by Guest
-.Paradox.- Posted July 13, 2013 Author Posted July 13, 2013 SCRIPT ERROR: exp_system\server.lua:24: 'then' expected near '=' WARNING: Loading script failed: exp_system\server.lua:24: 'then' expected near '='
Moderators IIYAMA Posted July 13, 2013 Moderators Posted July 13, 2013 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.
-.Paradox.- Posted July 14, 2013 Author Posted July 14, 2013 I didn't asked about making it for me, i guess i posted the code and i need somebody to fix it. Anything else?
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 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.
-.Paradox.- Posted July 14, 2013 Author Posted July 14, 2013 It's not my code castillo maked it for me, and i have troubles in level up.
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 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. Wasted of his time don't you think....
-.Paradox.- Posted July 16, 2013 Author Posted July 16, 2013 Please help, there isn't another solution?
iMr.3a[Z]eF Posted July 16, 2013 Posted July 16, 2013 Who give you the codes, he have to fix it no't us.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now