HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Accessing Account ID in Scripts  (Read 1787 times)

WoE-Westly

  • General Accounts
  • *
  • Posts: 7
    • View Profile
Accessing Account ID in Scripts
« on: Sep 20, 11, 02:28:42 PM »

I was wondering how you get (from the client side so I can pass it in a remote call).  From what I've heard, there's something in the me variable, but I don't know how to access it.  Also, is there a way to get a return value from a remote call?
« Last Edit: Jan 23, 13, 10:59:52 AM by HE-Cooper »
Logged

HE-CHRISTOPHER

  • HeroEngine
  • *****
  • Posts: 424
    • View Profile
Re: Getting the account id from the client side
« Reply #1 on: Sep 20, 11, 02:55:23 PM »

On the client:

Code: [Select]
account_id = GetAccountID() will return your account ID

Additionally, the _PlayerAccount node (which is what is visualized on the client) has the same ID as the user's account to facilitate communication and interaction.  So when you see click on another player's character the ID of the node which was clicked is shares the ID of the account.

On the Server:

An incoming remote call fills in a system variable

Code: [Select]
// is populated with with the account ID
account_id = SYSTEM.REMOTE.CLIENT

Additionally, for remote calls that are calling a function (as opposed to a remote method on an object):

Code: [Select]
account_id = me  // me is set to the account id

When receiving remote calls on the server, using SYSTEM.REMOTE.CLIENT is preferred as you should not trust the client to tell you who it is and the data used to populate the system variable is known to the server (and thus is not subject to tampering by the client).
« Last Edit: Sep 20, 11, 03:27:10 PM by HE-CHRISTOPHER »
Logged
Christopher Larsen
CTO
HeroEngine

WoE-Westly

  • General Accounts
  • *
  • Posts: 7
    • View Profile
Re: Getting the account id from the client side
« Reply #2 on: Sep 20, 11, 03:14:39 PM »

That answer for getting the account id was perfect, thank you.
But what about this:
Also, is there a way to get a return value from a remote call?
Is it even possible?  It would be very useful if it is.
Logged

HE-CHRISTOPHER

  • HeroEngine
  • *****
  • Posts: 424
    • View Profile
Re: Getting the account id from the client side
« Reply #3 on: Sep 20, 11, 03:25:28 PM »

Also, is there a way to get a return value from a remote call?

No, a remote call is asynchronous and it would be bad to block processing waiting for a return value.
Logged
Christopher Larsen
CTO
HeroEngine