• 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] Shops unselectable by certain players

Status
Not open for further replies.
Level 2
Joined
Jun 25, 2006
Messages
18
What I'm trying to do is, make 2 shops, one can only be accessed by players 1-3, the other players 4-6. The only answer I could come up with is doing this in JASS, but it has a delay and players can buy items from the other persons shop if they are fast enough before the unit is unselected. This is my JASS (1 out of the 2 triggers), is there any better way to do what I'm trying to accomplish?

JASS:
function SpecialtyShop1 takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit q = udg_ShopTracker[1]
    local player p = GetTriggerPlayer()
    if (u==q) and (GetLocalPlayer() == p) then
        call SelectUnit(u, false)
    endif
    set p = null
    set q = null
    set u = null
endfunction
function InitTrig_Shop1Unselect takes nothing returns nothing
    local integer i = 3
    local player p
    set gg_trg_Shop1Unselect = CreateTrigger()
    loop
        exitwhen i > 5
        set p = Player(i)
        call TriggerRegisterPlayerUnitEvent(gg_trg_Shop1Unselect, p, EVENT_PLAYER_UNIT_SELECTED, null)
        set i = i + 1
    endloop
    call TriggerAddAction(gg_trg_Shop1Unselect, function SpecialtyShop1)
    set p = null
endfunction
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
In
JASS:
loop
    exitwhen i > 5
    set p = Player(i)
    call TriggerRegisterPlayerUnitEvent(gg_trg_Shop1Unselect, p, EVENT_PLAYER_UNIT_SELECTED, null)
    set i = i + 1
endloop
You don't need the local player var
Instead:
JASS:
loop
    exitwhen i > 5
    call TriggerRegisterPlayerUnitEvent(gg_trg_Shop1Unselect, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
    set i = i + 1
endloop
 
Status
Not open for further replies.
Top