-.Paradox.- Posted December 21, 2013 Posted December 21, 2013 Hello, i made this script it suppose to draw an image in the screen when player level up, but it dont change it's stuck on rank_0.png, no errors in debug, here is the script. server addEventHandler ( "onPlayerJoin", root, function ( ) setElementData ( source, "Rankicon",":Class\\Rank\\rank_0.png" ) end ) addEventHandler ( "onPlayerLogin", root, function ( _, acc ) local accName = getAccountName ( acc ) local LV = getAccountData(acc, "LV") if (LV >= 0) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_0.png" ) elseif (LV >= 1) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_1.png" ) elseif (LV >= 2) then setElementData ( source, "Rankicon", ":Class\Rank\\rank_2.png" ) elseif (LV >= 3) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_3.png" ) elseif (LV >= 4) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_4.png" ) elseif (LV >= 5) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_5.png" ) elseif (LV >= 6) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_6.png" ) elseif (LV >= 7) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_7.png" ) elseif (LV >= 8 ) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_8.png" ) elseif (LV >= 9) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_9.png" ) elseif (LV >= 10) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_10.png" ) elseif (LV >= 11) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_11.png" ) elseif (LV >= 12) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_12.png" ) elseif (LV >= 13) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_13.png" ) elseif (LV >= 14) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_14.png" ) elseif (LV >= 15) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_15.png" ) elseif (LV >= 16) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_16.png" ) elseif (LV >= 17) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_17.png" ) elseif (LV >= 18) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_18.png" ) elseif (LV >= 19) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_19.png" ) elseif (LV >= 20) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_20.png" ) elseif (LV >= 21) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_21.png" ) elseif (LV >= 22) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_22.png" ) elseif (LV >= 23) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_23.png" ) elseif (LV >= 24) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_23.png" ) elseif (LV >= 25) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_23.png" ) elseif (LV >= 26) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 27) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 28) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 29) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 30) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 31) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_25.png" ) elseif (LV >= 32) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_25.png" ) elseif (LV >= 33) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_25.png" ) elseif (LV >= 34) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 35) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 36) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 37) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 38) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_27.png" ) elseif (LV >= 39) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_27.png" ) elseif (LV >= 40) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_27.png" ) elseif (LV >= 41) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 42) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 43) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 44) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 45) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 46) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 47) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 48) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 49) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 50) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_30.png" ) else setElementData ( source, "Rankicon", ":Class\\Rank\\rank_0.png" ) end end ) client addEventHandler ( "onClientRender", root, function ( ) local Rankicon = getElementData ( localPlayer, "Rankicon" ) if ( Rankicon and fileExists ( Rankicon ) ) then dxDrawImage(1173, 265, 36, 41, Rankicon, 0, 0, 0, tocolor(255, 255, 255, 255), true) 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.
pa3ck Posted December 21, 2013 Posted December 21, 2013 Because of the if (LV >= 0) then -- this condition will always be true and the if statement will automatically break itself as soon as it gets to this line Use if (LV == 0) then -- etc, etc, etc...
-.Paradox.- Posted December 22, 2013 Author Posted December 22, 2013 No not working Here is my xp system, maybe it would help function win(killer, weapon, bodypart) if (killer and getElementType(killer) == "player" and killer ~= source) then local H = getElementData(killer, "XP") or 0 local S = getElementData(killer, "Level") local killer1 = getPlayerName(killer) local noob = getPlayerName(source) local X = 5 setElementData(killer, "XP", tonumber(H)+X) local H = tonumber(H) + X if tonumber(H) == 100 then setElementData(killer, "Level", "LV 1") elseif tonumber(H) == 400 then setElementData(killer, "Level", "LV 2") elseif tonumber(H) == 600 then setElementData(killer, "Level", "LV 3") elseif tonumber(H) == 800 then setElementData(killer, "Level", "LV 4") elseif tonumber(H) == 1000 then setElementData(killer, "Level", "LV 5") elseif tonumber(H) == 1200 then setElementData(killer, "Level", "LV 6") elseif tonumber(H) == 1400 then setElementData(killer, "Level", "LV 7") elseif tonumber(H) == 1600 then setElementData(killer, "Level", "LV 8") elseif tonumber(H) == 1800 then setElementData(killer, "Level", "LV 9") elseif tonumber(H) == 2000 then setElementData(killer, "Level", "LV 10") elseif tonumber(H) == 2200 then setElementData(killer, "Level", "LV 11") elseif tonumber(H) == 2400 then setElementData(killer, "Level", "LV 12") elseif tonumber(H) == 2600 then setElementData(killer, "Level", "LV 13") elseif tonumber(H) == 2800 then setElementData(killer, "Level", "LV 14") elseif tonumber(H) == 4000 then setElementData(killer, "Level", "LV 15") elseif tonumber(H) == 4200 then setElementData(killer, "Level", "LV 16") elseif tonumber(H) == 4400 then setElementData(killer, "Level", "LV 17") elseif tonumber(H) == 4600 then setElementData(killer, "Level", "LV 18") elseif tonumber(H) == 4800 then setElementData(killer, "Level", "LV 19") elseif tonumber(H) == 4900 then setElementData(killer, "Level", "LV 20") elseif tonumber(H) == 7000 then setElementData(killer, "Level", "LV 21") elseif tonumber(H) == 9000 then setElementData(killer, "Level", "LV 22") elseif tonumber(H) == 10000 then setElementData(killer, "Level", "LV 23") elseif tonumber(H) == 12000 then setElementData(killer, "Level", "LV 24") elseif tonumber(H) == 13000 then setElementData(killer, "Level", "LV 25") elseif tonumber(H) == 14000 then setElementData(killer, "Level", "LV 26") elseif tonumber(H) == 15000 then setElementData(killer, "Level", "LV 27") elseif tonumber(H) == 16000 then setElementData(killer, "Level", "LV 28") elseif tonumber(H) == 17000 then setElementData(killer, "Level", "LV 29") elseif tonumber(H) == 20000 then setElementData(killer, "Level", "LV 30") elseif tonumber(H) == 22000 then setElementData(killer, "Level", "LV 31") elseif tonumber(H) == 24000 then setElementData(killer, "Level", "LV 32") elseif tonumber(H) == 26000 then setElementData(killer, "Level", "LV 33") elseif tonumber(H) == 28000 then setElementData(killer, "Level", "LV 34") elseif tonumber(H) == 30000 then setElementData(killer, "Level", "LV 35") elseif tonumber(H) == 32000 then setElementData(killer, "Level", "LV 36") elseif tonumber(H) == 34000 then setElementData(killer, "Level", "LV 37") elseif tonumber(H) == 36000 then setElementData(killer, "Level", "LV 38") elseif tonumber(H) == 38000 then setElementData(killer, "Level", "LV 39") elseif tonumber(H) == 40000 then setElementData(killer, "Level", "LV 40") elseif tonumber(H) == 42000 then setElementData(killer, "Level", "LV 41") elseif tonumber(H) == 44000 then setElementData(killer, "Level", "LV 42") elseif tonumber(H) == 46000 then setElementData(killer, "Level", "LV 43") elseif tonumber(H) == 48000 then setElementData(killer, "Level", "LV 44") elseif tonumber(H) == 50000 then setElementData(killer, "Level", "LV 45") elseif tonumber(H) == 52000 then setElementData(killer, "Level", "LV 46") elseif tonumber(H) == 54000 then setElementData(killer, "Level", "LV 47") elseif tonumber(H) == 56000 then setElementData(killer, "Level", "LV 48") elseif tonumber(H) == 58000 then setElementData(killer, "Level", "LV 49") elseif tonumber(H) == 60000 then setElementData(killer, "Level", "LV 50") end end end addEventHandler( "onZombieWasted", getRootElement(), win) function onLogin (_,account) setElementData(source, "Level", getAccountData(account, "LV") or "LV 0") setElementData(source, "XP", getAccountData(account, "EXP") or "0") end addEventHandler ("onPlayerLogin", root, onLogin) function saveData(thePlayer, theAccount) local theAccount = getPlayerAccount(source) if (theAccount and not isGuestAccount(theAccount)) then setAccountData (theAccount, "LV", getElementData(thePlayer, "Level")) setAccountData (theAccount, "EXP", getElementData(thePlayer, "XP")) end end addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) addCommandHandler ( "setxp", function ( thePlayer, _, who, XP ) local XP = tonumber ( XP ) or 0 local ThePlayer = getPlayerFromName ( who ) if ( ThePlayer ) then setElementData( ThePlayer,"XP",XP ) 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.
Sasu Posted December 22, 2013 Posted December 22, 2013 Try it: addEventHandler ( "onPlayerJoin", root, function ( ) setElementData ( source, "Rankicon",":Class\\Rank\\rank_0.png" ) end ) addEventHandler ( "onPlayerLogin", root, function ( _, acc ) local accName = getAccountName ( acc ) local Level = getAccountData(acc, "LV") local LV = tonumber(string.sub(Level, 4)) if (LV >= 0) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_0.png" ) elseif (LV >= 1) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_1.png" ) elseif (LV >= 2) then setElementData ( source, "Rankicon", ":Class\Rank\\rank_2.png" ) elseif (LV >= 3) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_3.png" ) elseif (LV >= 4) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_4.png" ) elseif (LV >= 5) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_5.png" ) elseif (LV >= 6) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_6.png" ) elseif (LV >= 7) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_7.png" ) elseif (LV >= 8 ) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_8.png" ) elseif (LV >= 9) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_9.png" ) elseif (LV >= 10) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_10.png" ) elseif (LV >= 11) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_11.png" ) elseif (LV >= 12) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_12.png" ) elseif (LV >= 13) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_13.png" ) elseif (LV >= 14) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_14.png" ) elseif (LV >= 15) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_15.png" ) elseif (LV >= 16) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_16.png" ) elseif (LV >= 17) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_17.png" ) elseif (LV >= 18) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_18.png" ) elseif (LV >= 19) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_19.png" ) elseif (LV >= 20) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_20.png" ) elseif (LV >= 21) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_21.png" ) elseif (LV >= 22) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_22.png" ) elseif (LV >= 23) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_23.png" ) elseif (LV >= 24) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_23.png" ) elseif (LV >= 25) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_23.png" ) elseif (LV >= 26) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 27) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 28) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 29) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 30) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_24.png" ) elseif (LV >= 31) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_25.png" ) elseif (LV >= 32) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_25.png" ) elseif (LV >= 33) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_25.png" ) elseif (LV >= 34) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 35) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 36) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 37) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_26.png" ) elseif (LV >= 38) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_27.png" ) elseif (LV >= 39) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_27.png" ) elseif (LV >= 40) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_27.png" ) elseif (LV >= 41) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 42) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 43) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 44) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 45) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_28.png" ) elseif (LV >= 46) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 47) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 48) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 49) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_29.png" ) elseif (LV >= 50) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_30.png" ) else setElementData ( source, "Rankicon", ":Class\\Rank\\rank_0.png" ) end end ) State: Inactive
-.Paradox.- Posted December 25, 2013 Author Posted December 25, 2013 No not working this time no errors in debug 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.
bandi94 Posted December 25, 2013 Posted December 25, 2013 Well , it's kinda funny the if/elseif make no sens. "if (LV >= 0) then" this "if" will be executed every time, why ? LV = 0 is LV == 0 (0==0) LV = 5 it's LV > 0 (5>0) LV=50 it's LV>0 ( 50 > 0) , so any of elseif will be never checked. to make it work you need to start from the back : if (LV >= 50) .... elseif (LV>= 45) ..... elseif (LV>=40) ..... Any way why using the bunch of if/else if , you could simply use : if (LV>=0 and LV <=50 ) setElementData ( source, "Rankicon", ":Class\\Rank\\rank_"..LV..".png" ) end Ingame Name : |DGT|Puma DGT Clan Server 24/7 Owner/Scripter MultiGameMode in progress :
Sasu Posted December 25, 2013 Posted December 25, 2013 Well , it's kinda funny the if/elseif make no sens."if (LV >= 0) then" this "if" will be executed every time, why ? LV = 0 is LV == 0 (0==0) LV = 5 it's LV > 0 (5>0) LV=50 it's LV>0 ( 50 > 0) , so any of elseif will be never checked. to make it work you need to start from the back : if (LV >= 50) .... elseif (LV>= 45) ..... elseif (LV>=40) ..... Any way why using the bunch of if/else if , you could simply use : if (LV>=0 and LV <=50 ) setElementData ( source, "Rankicon", ":Class\\Rank\\rank_"..LV..".png" ) end Did you realize that the images is repeated? State: Inactive
-.Paradox.- Posted December 26, 2013 Author Posted December 26, 2013 Yeah I repeated the images 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.
johny46 Posted December 26, 2013 Posted December 26, 2013 You could easily use an array for that, would be a lot cleaner.
-.Paradox.- Posted December 26, 2013 Author Posted December 26, 2013 How? 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.
johny46 Posted December 26, 2013 Posted December 26, 2013 There are many ways to accomplish this. You can for example use it as a dictionary: table = {level0 = "file.png", level1 = "file.png", level2 = "file.png"} You can then use this syntax to retrieve filenames: filename = table["level"..playerLevel] There's a good tutorial on that here: http://phailed.me/2011/02/learn-lua-the ... ay-tables/
-.Paradox.- Posted December 27, 2013 Author Posted December 27, 2013 But where i should use the syntax to retrieve filenames and level? 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.
johny46 Posted December 27, 2013 Posted December 27, 2013 Instead of all these if and elseif, similar to what bandi94 suggested.
.:HyPeX:. Posted December 27, 2013 Posted December 27, 2013 Example based on johny-s idea Saving: local x = LevelNumber setElementData(player, "Level", x) Setting image local imageTable = {level0 = "file.png", level1 = "file.png", level2 = "file.png"} local playerLevel = getElementData(player, "Level") local filename = imageTable["level"..playerLevel] setElementData ( source, "Rankicon", ":Class\\Rank\\rank_"..filename..".png" ) My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Dealman Posted December 27, 2013 Posted December 27, 2013 What Bandi94 suggested should do the trick. And is arguably the easiest way of doing it. I don't see how the images being "repeated" matter. Since you're getting the player's level, then replacing the rank with it. So if the data returns 5, it will set the element data to rank image #5 and so on. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
-.Paradox.- Posted December 27, 2013 Author Posted December 27, 2013 I can't understand, should i use getElementData? 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.
Dealman Posted December 27, 2013 Posted December 27, 2013 if (LV>=0 and LV <=50 ) setElementData ( source, "Rankicon", ":Class\\Rank\\rank_"..LV..".png" ) end Get the player's Level using getAccountData, store said level into a variable - for example, LV as above. Then check if the Level is equal or greater than 0 and equal or lower than 50. If true, then setElementData like above. You're concatenating the variable into the string, so for example, if the player's level is 13: This; setElementData(source, "Rankicon", ":Class\\Rank\\rank_"..LV..".png") Would translate into this; setElementData(source, "Rankicon", ":Class\\Rank\\rank_13.png") If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
johny46 Posted December 27, 2013 Posted December 27, 2013 Dealman, apparently you didn't check the code thoroughly. Notice how the same file is used for multiple levels. Eg. the "rank_24.png" file is used for the 26th, 27th, 28th, 29th and the 30th level, not only the 24th level.
Dealman Posted December 27, 2013 Posted December 27, 2013 Dealman, apparently you didn't check the code thoroughly. Notice how the same file is used for multiple levels. Eg. the "rank_24.png" file is used for the 26th, 27th, 28th, 29th and the 30th level, not only the 24th level. Ah, good catch. Either way, it can be modified for that purpose as well. No need to use tables at all. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
-.Paradox.- Posted December 27, 2013 Author Posted December 27, 2013 So is there anyway to make it work? please help guys 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.
Dealman Posted December 27, 2013 Posted December 27, 2013 So is there anyway to make it work? please help guys Since you've got some repeating images, you should make your if statements look like this instead for it to work; function exampleCode() if (LV >= 0) and (LV <=22) then setElementData ( source, "Rankicon", ":Class\\Rank\\rank_"..LV..".png") end if(LV >= 23) and (LV <= 25) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_23.png") end if(LV >= 26) and (LV <= 30) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_24.png") end if(LV >= 31) and (LV <= 33) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_25.png") end if(LV >= 34) and (LV <= 37) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_26.png") end if(LV >= 38) and (LV <= 40) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_27.png") end if(LV >= 41) and (LV <= 45) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_28.png") end if(LV >= 46) and (LV <= 49) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_29.png") end if(LV == 50) then setElementData(source, "Rankicon", ":Class\\Rank\\rank_30.png") end end Edit: Don't care too much about how I use the parentheses, I write it like that only to make it easier to read. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Sasu Posted December 27, 2013 Posted December 27, 2013 Also notice that 'LV' return a string = "LV "..tostring(number), so that if's won't work because you are trying to compare a string with number. @StevyDK, see the console too, sometime the error on server side appear there in the console. State: Inactive
-.Paradox.- Posted December 28, 2013 Author Posted December 28, 2013 Nope nothing in console too 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.
Dealman Posted December 28, 2013 Posted December 28, 2013 Nope nothing in console too My last reply has been tested and it should work. Something else in your code is breaking it. There are no errors or warnings in the debug at all...? If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
-.Paradox.- Posted December 29, 2013 Author Posted December 29, 2013 No, nothing in debug, here is what i tried addEventHandler ( "onPlayerJoin", root, function ( ) setElementData ( source, "Rankicons",":Class\\Rank\\rank_0.png" ) end ) addEventHandler ( "onPlayerLogin", root, function ( _, acc ) local accName = getAccountName ( acc ) local LV = getAccountData(acc, "LV") if (LV >= 0) and (LV <=22) then setElementData ( source, "Rankicons", ":Class\\Rank\\rank_"..LV..".png") end if(LV >= 23) and (LV <= 25) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_23.png") end if(LV >= 26) and (LV <= 30) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_24.png") end if(LV >= 31) and (LV <= 33) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_25.png") end if(LV >= 34) and (LV <= 37) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_26.png") end if(LV >= 38) and (LV <= 40) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_27.png") end if(LV >= 41) and (LV <= 45) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_28.png") end if(LV >= 46) and (LV <= 49) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_29.png") end if(LV == 50) then setElementData(source, "Rankicons", ":Class\\Rank\\rank_30.png") else setElementData ( source, "Rankicons", ":Class\\Rank\\rank_0.png" ) 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.
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