How do you get the PC of the player who just interacted with a GUI? I have a GUI that sends a player input back to the game (string variable). How do I set up the script so that it knows which PC the interacting player controls?
object oPC = ???????
Multi-player compliant preferred. It is possible that multiple players will be interacting with the GUI at the same time (though the GUI itself is seperate per player, so each player is on a "copy" of the GUI). Script itself is fired by the player pressing a GUI button - OnLeftClick=UIObject_MISC_ExecuteServerScript()
Thanks.
Get the Player's PC who interacted with GUI?
Débuté par
_Knightmare_
, oct. 03 2011 11:15
#1
Posté 03 octobre 2011 - 11:15
#2
Posté 03 octobre 2011 - 11:38
When a script is called from a GUI (a gui_<scriptname> script) the PC that interacted with it is OBJECT_SELF. I've verified this through testing in single-player, at least, but I'm pretty sure it applies to all environments.
Modifié par MasterChanger, 03 octobre 2011 - 11:39 .
#3
Posté 04 octobre 2011 - 12:39
quote i use the following for the event i fire off when characters are swapped ( i put a little delay in to make sure it's accurate.)
Might want to describe more about what you are doing, but it is technically OBJECT_SELF, but there are some outlier situations where the above, or things like getMaster are useful.
OBJECT_SELF is going to be sent from the gui, from the players computer, and be the player that sent it in. If more than one player, it would send in more than one event, one for each player, each one being OBJECT_SELF.
object oPC = OBJECT_SELF; //Despite who the player controls OBJECT_SELF is the person that opened the GUI. object oCurrentCharacter = GetControlledCharacter(oPC); // this is the actual character now controlled
Might want to describe more about what you are doing, but it is technically OBJECT_SELF, but there are some outlier situations where the above, or things like getMaster are useful.
OBJECT_SELF is going to be sent from the gui, from the players computer, and be the player that sent it in. If more than one player, it would send in more than one event, one for each player, each one being OBJECT_SELF.
#4
Posté 04 octobre 2011 - 03:20
Thanks for the replies. Basically when the player hits the button on the GUI, the script will jump them to another area. Just want to be sure that I am in fact jumping the character of the player that actually hit the button and not somebody else's/random PC. It is possible that two or more players are using the GUI at the same time, hit the button at the same time, but get jumped to different areas (based on variables within the script itself).
#5
Posté 04 octobre 2011 - 06:02
If two hit at the same time, then two events fire and OBJECT_SELF is for each event the particular player who clicked the button. It basically handles it all for you.
#6
Posté 04 octobre 2011 - 10:59
Sweet, that makes thing a lot easier. Thanks.
#7
Posté 04 octobre 2011 - 03:04
Thanks for the info. I've been eavesdropping and this is very useful.
#8
Posté 04 octobre 2011 - 06:25
As Pain notes, each player has a separate instance of the GUI, which calls a separate instance of the script. In this way, it's no different than if ten players simultaneously used Rage. In each instance of the impact script, OBJECT_SELF is the character that used the feat.
How the engine keeps track of which instance is being run for which object is beyond me. As Pain points out, the engine just works that way, which is how we are able to create custom scripts at all.
How the engine keeps track of which instance is being run for which object is beyond me. As Pain points out, the engine just works that way, which is how we are able to create custom scripts at all.





Retour en haut






