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

Author Topic: Assigning teams through a chat command  (Read 817 times)

wallace_balaniuc

  • Developer
  • *
  • Posts: 9
    • View Profile
Assigning teams through a chat command
« on: Aug 28, 13, 09:00:25 AM »

What we're trying to accomplish here is to get all the characters currently in the area and assign them a team (Team1 or Team2) when a command is given.

We currently have a class TSMS_PlayerCharacter (They Stole My Sheep is the game name), which is a child of _PlayerCharacter and contains the logic and function for setting and getting a team.

We've looked into two ways of retrieving all the players in the area, but both lead to the same problem we're having.

  • The first is to use GetPlayersInArea() which successfully returns a list of all account ID's in the area. The problem is that I'm not sure how to go from having an account ID to a reference of the character that is of type TSMS_PlayerCharacter.
  • The second is QueryNodes() which isn't ideal since it is not recommended for production. This will successfully return a list of noderefs which can be cast as kindof _PlayerCharacter but I cannot be cast as type TSMS_PlayerCharacter which has the team assignment functions.
 

In all, inside the overridden cmdTemplate script, we'd like to be able to get all the characters in the area, and assign their teams using the function created in our own player character class.

Thank you for your help
Logged
Lead Programmer - Gallium Gaming

Thazager

  • General Accounts
  • *
  • Posts: 1156
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Assigning teams through a chat command
« Reply #1 on: Aug 29, 13, 01:47:10 AM »

One way to turn an account ID into a character noderef or name is using:

client side
  acct as NodeRef of Class E_playerAccount = GetAccountID()
  char as NodeRef of Class E_playerCharacter = acct.GetMyCharacter()
  name as String = char.name

server side
  acct as NodeRef of Class E_playerAccount = accountID
  char as NodeRef of Class E_playerCharacter = acct.GetMyChar()
  name as String = char.name


Logged