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

[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