• 🏆 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] Is it possible to only show destructables to one player?

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hi guys, is it possible to only show destructables to one player? I guess it is possible? But even it is possible, I am still confused about the GetLocalPlayer() function.

JASS:
function con takes nothing returns boolean
    if GetTriggerPlayer() == GetLocalPlayer() then   //This comparison must be wrong...
        ....     //Showing destructables
    endif
    return false    
endfunction

//===========================================================================
function InitTrig_test takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        exitwhen i > 7 // There are only 8 players in my map.
        call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_END_CINEMATIC) 
        set i = i + 1
    endloop
    call TriggerAddAction(t, function con)
endfunction

So, how to correctly use the GetLocalPlayer() function? Many thanks.
 
It is possible.
JASS:
if GetTriggerPlayer() == GetLocalPlayer() then
    call ShowDestructable(d, true)
endif

But if a player interacts with the destructable (e.g. attacks it, harvests it, w/e) then it will disconnect players. So just be careful. Here is a thorough list of what is and isn't problematic when it comes to hiding destructables (courtesy of Zwiebelchen):
Zwiebelchen said:
However, there are some rules you need to consider, in order to make your map work without desyncs in multiplayer:
- never hide destructables units or players can interact with (attackable, selectable or destructable)
- hiding destructables that block pathing is safe, as hiding the destructable will not change its pathing
- hiding destructables that need to be enumed is safe; hidden destructables can be enumerated
- hiding walkable platforms is also safe, as long as you dont get a location Z for a location placed on that destructable globally; this is not 100% safe anyway, as
the returned value of GetLocationZ() is dependant on the render state of the destructable
 
Level 11
Joined
Oct 11, 2012
Messages
711
It is possible.
JASS:
if GetTriggerPlayer() == GetLocalPlayer() then
    call ShowDestructable(d, true)
endif

But if a player interacts with the destructable (e.g. attacks it, harvests it, w/e) then it will disconnect players. So just be careful. Here is a thorough list of what is and isn't problematic when it comes to hiding destructables (courtesy of Zwiebelchen):

Thanks a lot, PnF. +Rep
 
Status
Not open for further replies.
Top