Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,219
GetLocalPlayer
By Chaosy
Introduction
I made this tutorial since I think way to few people know that this exist in GUI, so I want to show you how to use "GetLocalPlayer" in GUI.
What is needed?
- Decent knowlege of GUI triggering
- Very basic jass knowledge
- A few moments of your time
What is GetLocalPlayer?
GetLocalPlayer is a method to create certain things/stuff in JASS, but I will show you how to use this method in the GUI.
This method will allow you to create this thing/stuff [special effects, multiboards, floating text, etc] for the player of your choice only.
For example, you can show a multiboard to player 1 only, while the other player wont see any multiboard at all!
That sounds awesome how do I use this?
As one example I will create a multiboard for player 1 only, you can use any event you want.
I will show you 3 ways to do it, tho you should use the recommended one since you use less memory that way.
NOTICE! We use a player variable named "GetLocalPlayer" or "Player" based on which way you want to use
-
init
-
Events
- Map initialization
- Conditions
-
Actions
- Custom script: set udg_GetLocalPlayer = GetLocalPlayer()
-
Events
-
Multiboard for one player
-
Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
-
Actions
- Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
- Multiboard - Hide (Last created multiboard)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- GetLocalPlayer Equal to Player 1 (Red)
-
Then - Actions
- Multiboard - Show (Last created multiboard)
- Else - Actions
-
If - Conditions
-
Events
-
Multiboard for one player jass
-
Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
-
Actions
- Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
- Multiboard - Hide (Last created multiboard)
- Custom script: if GetLocalPlayer() == Player(0) then
- Multiboard - Show (Last created multiboard)
- Custom script: endif
-
Events
-
Multiboard for one player
-
Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
-
Actions
- Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
- Multiboard - Hide (Last created multiboard)
- Custom script: set udg_Player = GetLocalPlayer()
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Player Equal to Player 1 (Red)
-
Then - Actions
- Multiboard - Show (Last created multiboard)
- Else - Actions
-
If - Conditions
-
Events
Now I will go through the trigger
First we create a multiboard just edit it as you want
- Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
- Multiboard - Hide (Last created multiboard)
- Custom script: set udg_Player = GetLocalPlayer()
NOTICE! The jass and the GUI version is just the same you can use any of them!
NOTICE! In jass the player index is between in 0-11 insted of 1-12 in GUI
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Player Equal to Player 1 (Red)
-
Then - Actions
- Multiboard - Show (Last created multiboard)
- Else - Actions
-
If - Conditions
- Custom script: if GetLocalPlayer() == Player(0) then
- Multiboard - Show (Last created multiboard)
- Custom script: endif
Great, but can I do the same to other things?
Yes you really can, lets take special effects.-
init
-
Events
- Map initialization
- Conditions
-
Actions
- Custom script: set udg_GetLocalPlayer = GetLocalPlayer()
-
Events
-
special effect trollbrain way
-
Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
-
Actions
- Set Effect = <Empty String>
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- GetLocalPlayer Equal to Player 1 (Red)
-
Then - Actions
- Set Effect = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
- Else - Actions
-
If - Conditions
- Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
-
Events
-
Special effect for one player jass
-
Events
- Player - Player 1 (Red) Presses the Right Arrow key
- Player - Player 2 (Blue) Presses the Right Arrow key
- Conditions
-
Actions
- Set Effect = <Empty String>
- Custom script: set udg_Player = GetLocalPlayer()
- Custom script: if GetLocalPlayer() == Player(0) then
- Set Effect = Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
- Custom script: endif
- Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
-
Events
-
Special effect for one player
-
Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
-
Actions
- Set Effect = <Empty String>
- Custom script: set udg_Player = GetLocalPlayer()
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Player Equal to Player 1 (Red)
-
Then - Actions
- Set Effect = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
- Else - Actions
-
If - Conditions
- Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
-
Events
As you see I use the same system, but I will explain the new actions for you anyway.
Here I simply store a string variable into nothing, this means if the player aint the player I want it to be there wont be any effect. (you will see later)
- Set Effect = <Empty String>
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Player Equal to Player 1 (Red)
-
Then - Actions
- Set Effect = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
- Else - Actions
-
If - Conditions
- Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
Desyncronization
Desyncronization only exist in multiplayer due you need both a host and a client to make this happen, it causes clients playing the map do disconnect from the game. Thats why you must keep this in mind, if possible do only use the GetLocalPlayer in conditions.
So if it does desync do NOT use it, if it does not desync you can just enjoy the game.
NOTICE! Handles that have their own stack will never desync!
1. Fade filters for 1 player only
Question - this cause desyncronization?
Answer - No, but you have to locally set the alpha (transparency) rather than putting the fade filter in the "if" block.
Click this link for the technique.
2. Quest for 1 player only?
Question - this cause desyncronization?
Answer - Yes but if u use Enable/Disable quest then No
3. Special effects, visibile for 1 player only?
Question - this cause desyncronization?
Answer - No
4. Special effects attachment to unit, visibile for 1 player only?
Question - this cause desyncronization?
Answer - No
6. Unit visibility, color, visibile for 1 player only?
Question - this cause desyncronization?
Answer - Yes but Vertex color dont desync
7. Fog of war and black mask, color, visibile for 1 player only?
Question - this cause desyncronization?
Answer - Yes
8. Images, visibile for 1 player only?
Question - this cause desyncronization?
Answer - No
9. Sound & music, for 1 player only?
Question - this cause desyncronization?
Answer - Mostly No
10. Show Multiboard, for 1 player only?
Question - this cause desyncronization?
Answer - No
11. Trackables, for 1-2 player only?
Question - this cause desyncronization?
Answer - No
12. Pause the game, for 1 player only?
Question - this cause desyncronization?
Answer - Yes
13. Create different unit for player?
Question - this cause desyncronization?
Answer - Yes
Note - It might not desync if (1) it is a non hero unit and (2) the two units have only differences in art fields/physical display (such as model or icon) - by PurgeandFire111
14. Weather effect off for 1 player?
Question - this cause desyncronization?
Answer - No?
15. Desctructible visibility, for 1 player only?
Question - this cause desyncronization?
Answer - ?
Credits
Hashjie - Telling me info about GetLocalPlayer and the idea to this tutorial
Troll-Brain - awesome tip to improve the tutorial
Last edited: