SphereCommunity
List of skills (highest to lowest) - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: List of skills (highest to lowest) (/Thread-List-of-skills-highest-to-lowest)



List of skills (highest to lowest) - Soulless - 07-22-2012 09:34 PM

Can anyone see a better way of creating this script? it def will lag the player if they did it often. I just got it all working, i think im just having a dumb day, but if anyone can do this better please feel free to chime in.

Code:
[function rankskill] //compare 1 skill to the other 48 and return ranking
for 48
if (<<serv.skill.<argn>.key>> == <<serv.skill.<local._for>.key>>) && (<argn>!=<local._for>)
local.sameas += 1
endif
if (<<serv.skill.<argn>.key>> > <<serv.skill.<local._for>.key>>)
local.betterthan += 1
endif
endfor
return <eval (48-<local.betterthan>)>


[function compareskills]
serv.log <local.rank>
for 48    //set skill ranks
if !(<local.skill<rankskill <local._for>>>)
local.skill<rankskill <local._for>>=<serv.skill.<local._for>.key>
else


local.x=<rankskill <local._for>>
local.messedup=1
while <local.messedup>
if (<local.skill<eval <local.x>>>)
local.x -= 1
else
local.skill<eval <local.x>>=<serv.skill.<local._for>.key>
local.messedup=

endif
endwhile

endif
endfor


for 48     //test in console to see if it lists right
serv.log <local.skill<eval <local._for>>>
endfor



RE: List of skills (highest to lowest) - Soulless - 07-22-2012 11:10 PM

EDIT: i removed this reply because its no longer necessary since the error has been resolved. But if anyone can please help optimize the above code i would really appreciate it.

thanks.


RE: List of skills (highest to lowest) - Shaklaban - 07-23-2012 01:15 AM

you can use skillbest function:

PHP Code:
[dialog sb_test]
100,100
resizepic 0 0 
<def.menu_border200 350
gumppictiled 10 10 180 330 2624
checkertrans 10 10 180 330

local
.20
local
.20
for 0 9
    
if <src.<skillbest.<local._for>>> > 0
        dtext 
<local.x> <local.y1152 <src.skillbest.<local._for>>
        
local.+= 20
    
endif 
endfor 



RE: List of skills (highest to lowest) - Soulless - 07-23-2012 02:26 AM

Thanks Shaklaban.

Even though i feel so stupid for writing such a ridiculous function to sort the skills. it will come in handy someday with something else.

i very much appreciate your hepl Smile


RE: List of skills (highest to lowest) - Shaklaban - 07-23-2012 05:44 AM

no problem, thanks to sugarcube we have this function.


RE: List of skills (highest to lowest) - Anarch Cassius - 07-23-2012 06:53 AM

Yeah, that function just helped a bunch with my quasi-champ system.