• 🏆 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!

[vJASS] What Is wrong with this short snippet?

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
Basically after this line:
JASS:
call SyncSelections()
            call GroupEnumUnitsSelected(g, pp, null)
The code doesn't work any more. Only thing I can think off is if g isn't declared but it is...

JASS:
private function AttachName takes integer p, integer i, string name returns nothing
        local unit u
        local unit foundunit
        local integer count
        local integer j = (p*10) + i
        local player pp = Player(p)
        if sCharacterName[j] == null then 
            call DisplayTimedTextToPlayer(pp, 0, 0, 5, "|cffff0303[ERROR]|r Failed to attach a name.|r")
            return
        endif
        if i > 0 then 
            set count = 0
            call BJDebugMsg("this is shown")
            call SyncSelections()
            call GroupEnumUnitsSelected(g, pp, null)    
            call BJDebugMsg("but not this...")
            loop
                call BJDebugMsg("looping")
                set u = FirstOfGroup(g)
                exitwhen u == null
                call GroupRemoveUnit(g, u)
                if GetOwningPlayer(u) == pp then
                    set count = count + 1
                    set foundunit = u
                endif
            endloop
            call BJDebugMsg("never reach this point")
            if count == 1 then 
                call BJDebugMsg("Victory!")
            elseif count == 0 then
                call DisplayTimedTextToPlayer(pp, 0, 0, 5, "|cffff0303[ERROR]|r Need to have a character selected to execute command.")
            else 
                call DisplayTimedTextToPlayer(pp, 0, 0, 5, "|cffff0303[ERROR]|r Can only attach a name to one of your units.")
            endif
        endif
    endfunction
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
If you are sure g is a valid group and pp is a valid player, try executing this function via ExecuteFunc or as a triggeraction(use globals for arguments)
 
Like Ceday said, passing bad parameters to a function will cause the entire thread to crash. One thing you should know though is that SyncSelections can cause some troubles in multiplayer, depending on how often you use it. Usually, it will make player input very irresponsive and laggy. I'm not sure if you actually need to use it, so if you end up experiencing these kind of issues you can try removing it and see if the game still stays in sync.
 
Status
Not open for further replies.
Top