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

[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