• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Is there another method? (if player number == number)

Status
Not open for further replies.
Level 4
Joined
Jul 31, 2009
Messages
89
Alright ill try to explain this as simple as possible..

I have 12 players, when the player creates his hero ill add a custom health bar to that unit like this:

Player unit create event:
Code:
call AddBarNow(GetTriggerPlayer())

Add bar function (Works for player red.. noone else)
Code:
function AddBarNow takes player pu returns nothing

//! textmacro skill_check_make15 takes nummer
if (GetConvertedPlayerId(pu) == $nummer$) then

set s$nummer$=TTGradBar.create(".", 25, 9,   0, 0, 0) 
**More code**

endif
    //! endtextmacro
    //! runtextmacro skill_check_make15("1")
    //! runtextmacro skill_check_make15("2")
    //! runtextmacro skill_check_make15("3")
    //! runtextmacro skill_check_make15("4")
**etc**


 endfunction


This works with other functions so maybe there is a problem with bar code. (I have a variable for every player)

Well my real question is: Is there any better way to do this?
Trigger code becomes really large with a if state for every player.. -.- Help me out please!

I have another smaller question, not so important:
I create a multibar for every player but i cant loop 12 create multibar at the same time.. it only creates 5. So i now have made 3 triggers with 0.5 sec between them to make it work..
 
Level 4
Joined
Jul 31, 2009
Messages
89
JASS:
globals
    TTGradBar array s //you should really have a better name for this.
endglobals

function AddBarNow takes player p returns nothing
    local integer i = GetPlayerId(p)
    set s[i] = TTGradBar.create(".",25,9,0,0,0)
    //etc
endfunction

Your the best.. I have always wondered how to declare a array in Jass.. Lol i thought it wasnt possible. Time to fix my code!

+rep
 
Status
Not open for further replies.
Top