1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

GetLocalPlayer

Discussion in 'Trigger (GUI) Editor Tutorials' started by Chaosy, Nov 17, 2012.

  1. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,626
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    Those questions seems kind of stupid to me actually...
    This is a normal tigger its called GUI
    • trigger name
    • Events
    • Conditions
    • Actions


    this is JASS or vJASS
    Code (vJASS):

    function functionname takes nothing returns nothing
    endfunction
     


    and in the GUI there is no such thing as GetLocalPlayer and I show to how to get the JASS native GetLocalPlayer into the GUI. so tell me how can it not be suiting in the GUI tutorials?
     
  2. Hashjie

    Hashjie

    Joined:
    Apr 20, 2009
    Messages:
    1,515
    Resources:
    0
    Resources:
    0
    Nah it's not stupid, I get his perspective...

    Damn right it is!

    Nope, just JASS ;P

    Let me rephrase that for him:
    If GetLocalPlayer() only exists in Jass, then how can this be a GUI tutorial?

    But then again... It's in the GUI section because it effectively shows you how to put the return of a Jass function inside a GUI variable.
    Which can then be used for local code without having to use custom script actions over and over again in GUI. Which can be a useful refference for GUI users.
    (If you've come this far as a GUI user, I don't really see the point in not learning Jass anyways then :/)
     
  3. frettory

    frettory

    Joined:
    Jan 19, 2012
    Messages:
    51
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    • Custom script: set udg_global_variable = JASSFunctionReturn()


    How hard is that?
     
  4. Hashjie

    Hashjie

    Joined:
    Apr 20, 2009
    Messages:
    1,515
    Resources:
    0
    Resources:
    0
    Depends... How much do you know about GUI? :)
    I'm just saying, this stuff is simple cake for almost anyone but you'll never know who finds it useful.
    Plus the fact that not every GUI'er thinks of this solution for using local code.
    It's also good to have idiot proof things...

    Did you know that there was a women in the US who had fried her dog with a microwave just because the dog went outside in the rain. And afterwards sued the company who made the microwave because it killed the dog since it wasn't in the user manual that you should not put your dog in the microwave?

    Imagine this world without simple idiot proof explenations 0.o
    Retardation will be without limits. (no offence to anyone who is retarded b.t.w.)
     
    Last edited: Dec 4, 2012
  5. frettory

    frettory

    Joined:
    Jan 19, 2012
    Messages:
    51
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    My answer:
    There you go.

    However, you make a good point. Maybe I will create a tutorial on how and when to use a custom script sooner or later.
     
  6. Hashjie

    Hashjie

    Joined:
    Apr 20, 2009
    Messages:
    1,515
    Resources:
    0
    Resources:
    0
    You are correct, but that doesn't mean I don't find it useful to use this guide for reference whenever someone doesn't know how to use local code in GUI.

    Well that will be a brief tutorial in that case :)
    It's good if it gave some hints towards learning Jass.
    I think at this point GUI users should seriously consider doing that instead.
    It's not that hard anyways...
     
  7. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    I have used GetLocalPlayer 5-6 times in my map. Only one of them causes a desync, though... i gotta find the problem.
    Anyway, after doing this :
    • Custom script: set udg_Player = GetLocalPlayer()
    what will be the current value of the "Player" variable?
     
  8. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,626
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    well, it's a special type of variable.. it can be any player.. you can see it as a playergroup and when you use it you pick one of them
     
  9. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    So this variable of type "Player" is actually a player group... Jass basically does magic then. Never going to understand it (i think). Doesn't matter, it solves many problems. :p
     
  10. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    No, it's still a player variable, just that it contains another value for each client. Jass code is not handled centrally on the game server but every client gets the same sheet of paper of script and executes it on its own. Functions like GetLocalPlayer() provide client-specific data the other players in the game have no access to. This way, they create asynchronous results.
     
  11. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    So if i have this "Player" variable, set it to GetLocalPlayer, convert it to string and display it as game text (so that it's visible) to all players, will it show "Player 1" to... player 1, "Player 2" to player 2 and so on?
     
  12. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    Yes, to each player his/her own name.
     
  13. CoLd Bon3

    CoLd Bon3

    Joined:
    Aug 8, 2010
    Messages:
    948
    Resources:
    4
    Spells:
    4
    Resources:
    4
    My objective in life is done.
    Function in Jass understood.
    Awaiting death.
     
  14. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    I looked over it and I approve. I may go back to this tutorial and make minor edits for capitalization and organization, but the content seems to be okay from my first read.

    Approved. :)
     
  15. HammerFist132

    HammerFist132

    Joined:
    Mar 22, 2012
    Messages:
    1,314
    Resources:
    17
    Models:
    11
    Icons:
    2
    Maps:
    2
    Spells:
    2
    Resources:
    17
    Sry for saying this, but...

    Shadowvzs have created almost everything of this and crated much more detailed, he was planning to create this tutotial so I feel like u stole someones work :(
     
  16. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,626
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    You got your own opionion mon, however I would not say he got everything covered. He did only list if it does desync or not. He said nothing about what it is or how it works.
     
  17. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    "Handles that have their own stack will never desync!"

    I speak JASS, but I don't know what that means. Handle stacks?
     
  18. HammerFist132

    HammerFist132

    Joined:
    Mar 22, 2012
    Messages:
    1,314
    Resources:
    17
    Models:
    11
    Icons:
    2
    Maps:
    2
    Spells:
    2
    Resources:
    17
    I am thinking to it was obvious to u create speical effects for only one player, or change player name for only one player. And I think he included triggers. Anyway sorry for insulting you. +Rep
     
  19. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    The stacks refer to handle ID's.

    The main stack begins at 0x100000 (hex), which is 1048576. The reason why it is called a stack is because of the way handle ID's are assigned. Normally, handles will be +1 the last value. So the first handle will be 1048576, the next 1048577, the next 1048578, etc. Once a handle is destroyed, that slot becomes available. So if the stack is currently at 1049000, but the handle at 1048600 is available, then the next handle created will go to that slot.

    That "general" stack applies to most handles, including units, triggers, rects, locations, and more. However, some handle types have special stacks. For example, texttags have their own stack that starts off at 0 and goes to 99 (or the other way around, I don't remember). The same thing happens for ubersplats and lightning handles (iirc). There are probably a few others as well.

    As a general rule of thumb, those can be created within GetLocalPlayer() without desyncs. I can't say I've tested them all though, but I can guarantee that texttags work when created/destroyed locally.

    However, those handles having a separate stack might not be the reason that they don't desync when created locally. We don't really have that much insight on how Blizzard coded Wc3. It is just an observed pattern.
     
  20. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    Yes, them having their separate id pools is a factor. The main handle stack needs to be synced because types like units transmit information to other clients. The unit must be identifyable on the other side and this is done by having the same id. Now, not all included types really do this, like rects. You can however read them out (GetRectMinX, GetRectCenterY, ...) and often the won data is then applied in a supposed sync manner. So it is probably a security reason for them.

    It really does not make sense for types like special effect, multiboard/multiboarditem.