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

[Solved] GetLocalPlayer and Special Effect visibility

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
I'm trying to use GetLocalPlayer() to show a special effect to only one player. I followed what was written about here: Any way to show a special effect to a single player?

But in multiplayer tests it doesn't seem to work. The special effects are not using the <Empty String> that is meant to "hide" them. In other words, I can see Player 2's special effects as Player 1, and vice versa.

This is on the latest patch.

  • Setup Quest Markers
    • Events
      • Time - Elapsed game time is 0.25 seconds
    • Conditions
    • Actions
      • Set VariableSet ActivePlayers = (All players controlled by a User player)
      • -------- --------
      • -------- GetEnumPlayer() is the Picked player --------
      • Player Group - Pick every player in ActivePlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet PN = (Player number of (Picked player))
          • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
          • Set VariableSet effectString = Abilities\Spells\Other\TalkToMe\TalkToMe
          • Custom script: else
          • Set VariableSet effectString = <Empty String>
          • Custom script: endif
          • Special Effect - Create a special effect attached to the overhead of Paladin 0000 <gen> using effectString
          • Set VariableSet quest_Sfx[PN] = (Last created special effect)
  • Destroy Sfx
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 2 (Blue) skips a cinematic sequence
      • Player - Player 3 (Teal) skips a cinematic sequence
      • Player - Player 4 (Purple) skips a cinematic sequence
    • Conditions
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Special Effect - Destroy quest_Sfx[PN]
Anyone know why this isn't working? I'm not sure what i'm doing wrong.
 
Last edited:
Level 6
Joined
Mar 7, 2011
Messages
124
as a side note, it used to potentially desync the wc3 string cache when you reference a string for the first time in a local player block (i think it still does). since this suggestion won't change anything functionally, it can't hurt to twist your setup a little bit just to play it safe

instead of setting the string to the fx path for the local player and then blank for all other players. set the string outside of the local blocks entirely and then clear it for everyone but the target player in a single local player block. this references the string for all players synchronously, avoiding desync risks around the wc3 string cache, but then goes on to only show the fx for a single specified player
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
as a side note, it used to potentially desync the wc3 string cache when you reference a string for the first time in a local player block (i think it still does). since this suggestion won't change anything functionally, it can't hurt to twist your setup a little bit just to play it safe

instead of setting the string to the fx path for the local player and then blank for all other players. set the string outside of the local blocks entirely and then clear it for everyone but the target player in a single local player block. this references the string for all players synchronously, avoiding desync risks around the wc3 string cache, but then goes on to only show the fx for a single specified player
Gotcha, I was actually doing that originally, but ended up with this setup after some trial and error. I'll go back to setting the variable before GetLocalPlayer.

Can you explain what you are trying to do?
I'm creating special effects that are only visible to specific players.

In this case it's for a Quest system. Players that have the quest available will see an exclamation point above the NPC's head, players that already have the quest will see a question mark, and players that have completed the quest will see nothing as their special effect will have been destroyed.

And to clarify on the issue, I tested in LAN as well as online with a friend. Both player 1 (me) and player 2 (friend) were able to see each others special effects. This was confirmed after I had destroyed my own special effect, but could still see my friend's special effect. This shouldn't be the case if everything is working correctly, as his special effect should have an <Empty String> as it's model path on my side of things.

Append .mdl to effectString value.
The special effects are using the correct models so I'm not sure if this is a misunderstanding, but I'll give that a shot.

It's created for all player that are "user", or? So all users would see the effect.
But the users should only be able to see their own version of the special effect. I'm setting the model path to <Empty String> for everyone besides the given user.

So when I create Player 1's special effect:
The model of the effect for P1: Abilities\Spells\Other\TalkToMe\TalkToMe
The model of the effect for P2: <Empty String>
The model of the effect for P3: <Empty String>
etc...

Then when I create Player 2's special effect:
The model of the effect for P1: <Empty String>
The model of the effect for P2: Abilities\Spells\Other\TalkToMe\TalkToMe
The model of the effect for P3: <Empty String>
etc...
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Anyone know why this isn't working? I'm not sure what i'm doing wrong.
The action is meant to be run outside of the loop. The idea is that GetLocalPlayer and control flow logic are used to create special effects using the model path on some clients and empty string on all others.

What you are currently doing is creating 1 special effect for each player that only that player can see on the same unit so it looks like each player can see each other's special effect.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
The action is meant to be run outside of the loop. The idea is that GetLocalPlayer and control flow logic are used to create special effects using the model path on some clients and empty string on all others.

What you are currently doing is creating 1 special effect for each player that only that player can see on the same unit so it looks like each player can see each other's special effect.
Thanks for the help! I haven't tested it yet but i'm sure this is the solution.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
Edit: It actually was working the entire time. I had made a mistake in the second part of my trigger (which I didn't show you guys) which created a new special effect after destroying the first one. This mistake lead me to believe that it wasn't working...

Anyway, here are the working triggers:
  • Setup Quest Markers
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Set VariableSet ActivePlayers = (All players controlled by a User player)
      • -------- --------
      • Player Group - Pick every player in ActivePlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet PN = (Player number of (Picked player))
          • Set VariableSet effectString = Abilities\Spells\Other\TalkToMe\TalkToMe
          • Custom script: if GetLocalPlayer() != GetEnumPlayer() then
          • Set VariableSet effectString = <Empty String>
          • Custom script: endif
          • Special Effect - Create a special effect attached to the overhead of Paladin 0000 <gen> using effectString
          • Set VariableSet quest_Sfx1[PN] = (Last created special effect)
  • Destroy Quest Markers
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
      • Player - Player 2 (Blue) skips a cinematic sequence
      • Player - Player 3 (Teal) skips a cinematic sequence
    • Conditions
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Special Effect - Destroy quest_Sfx1[PN]
      • -------- --------
      • Player Group - Pick every player in ActivePlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet PN = (Player number of (Picked player))
          • Set VariableSet effectString = Objects\RandomObject\RandomObject
          • Custom script: if GetLocalPlayer() != GetTriggerPlayer() then
          • Set VariableSet effectString = <Empty String>
          • Custom script: endif
          • Special Effect - Create a special effect attached to the overhead of Paladin 0000 <gen> using effectString
          • Set VariableSet quest_Sfx2[PN] = (Last created special effect)
I also did what @Serenity09 said to avoid a potential desync.
 
Last edited:
Status
Not open for further replies.
Top