• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

[Solved] Enter Region only working for Player 1?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

Why is this trigger only firing for player 1? AFAIK, there's no parameter for a player argument for an Enter Region event. This trigger works perfectly for Player 1, but it won't do jack for any other player.

JASS:
    static method enterMain takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
		call DisplayTimedTextToPlayer(players[pid], 0, 0, 10, "Entered a region?")
    endmethod

    method setup takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function CreepRegion.enterMain))
        call TriggerRegisterEnterRegion(t, this.r, null)
        set t = null
    endmethod
 
Last edited by a moderator:

EdgeOfChaos

E

EdgeOfChaos

Are you sure the players[] array is initialized correctly?
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
That's not the problem (I just checked myself, but players[] is properly initialized and works in all other instances.). And here, I'll change it to "p."

The problem is the trigger isn't firing for anyone except Player 1. This doesn't make sense to me, since you cannot bind EnterRegionEvents to specific players without a filter. And I'm not using any filter
here.

Edit: I tried changing it to TriggerRegisterEnterRegionSimple but it didn't change squat.

JASS:
    static method enterMain takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
	call DisplayTimedTextToPlayer(p, 0, 0, 10, "Entered a region?")
    endmethod

    method setup takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function CreepRegion.enterMain))
        call TriggerRegisterEnterRegion(t, this.r, null)
        set t = null
    endmethod
 

EdgeOfChaos

E

EdgeOfChaos

Can you post what condition "CreepRegion.enterMain" is? That's the only thing I can see that would do it
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
This is CreepRegion.enterMain...

JASS:
    static method enterMain takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
    call DisplayTimedTextToPlayer(p, 0, 0, 10, "Entered a region?")
    endmethod
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
Genius purge. That was the problem. GetTriggerPlayer() returns null for these kind of events.

The reason why it worked for player 1 was because the integer pid defaults to 0 for null players?
 
The reason why it worked for player 1 was because the integer pid defaults to 0 for null players?

Yep. For future reference, GetTriggerPlayer usually works with things like TriggerRegisterPlayerEvent or TriggerRegisterPlayerUnitEvent, but for other events, I would use something else, such as GetOwningPlayer.
 
Status
Not open for further replies.
Top