• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Region System Help

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
Hello Hivers,

I'm trying to make a simple system so when you enter the region it pops up the name of the area you are in. For some reason right now it keeps showing 2 messages everytime i enter the region. I'm pretty sure it has to do with how I'm setting up the trigger part, but I can't seem to figure it out.

Thanks!

JASS:
library Regions initializer Init

    globals
        private constant string PREFIX = "|cff8fbc8b"
        private hashtable RegionHash = InitHashtable()
        
    endglobals
    
    struct Regions
        rect regions
        string name
        trigger regiont
        
        static method enter takes nothing returns nothing
            local Regions t = LoadInteger(RegionHash, GetHandleId(GetTriggeringRegion()), 1)
            local player p = GetOwningPlayer(GetTriggerUnit())
            
            call DisplayTimedTextToPlayer(p, 0, 0, 5, PREFIX+t.name+"|r")
        endmethod
        
        static method create takes rect r, string n returns Regions
            local Regions temp = Regions.allocate()
            local region rectRegion = CreateRegion()
                call RegionAddRect(rectRegion, r)
                set temp.regions = r
                set temp.name = n
                set temp.regiont = CreateTrigger()
                call SaveInteger(RegionHash, GetHandleId(rectRegion), 1, temp)
                call TriggerRegisterEnterRegion(temp.regiont, rectRegion, null)
                call TriggerAddAction(temp.regiont, function thistype.enter)
            return temp
        endmethod
        
    endstruct
    
    private function Init takes nothing returns nothing
        local Regions RefugeeCamp = Regions.create(gg_rct_RefugeeCamp, "Refugee Camp")
        local Regions SouthernAsturniaHills = Regions.create(gg_rct_SouthernAsturniaHills, "Southern Asturnia Hills")
    endfunction
    
endlibrary
 
Status
Not open for further replies.
Top