Page 1 of 1

We should be able to get the team from the IUser

Posted: Mon Jan 15, 2018 1:01 am
by MrAnyone
I'm making an map script and I noticed that I can't get this information from the game script interface:

Image

Is there any way to get the user team? I need this to persist the teams in an map that I'm making.

This can be added to the IUser interface, since the player already have an (in game current) getTeam.

Code: Select all

interface IUser {
    PlayerTeam GetTeam();
}
The GetTeam() method above would return the game team (team that it need to respawn), not the IPlayer team.

Another questions, why Game.CreatePlayer() doesn't persists the team from the game settings? It always spawns a new player using the independent team.

I'm current limited by that, thanks for reading! I'm waiting a response.

Re: We should be able to get the team from the IUser

Posted: Mon Jan 15, 2018 12:04 pm
by JakSparro98
MrAnyone wrote:
Mon Jan 15, 2018 1:01 am
I'm making an map script and I noticed that I can't get this information from the game script interface:

Image

Is there any way to get the user team? I need this to persist the teams in an map that I'm making.

This can be added to the IUser interface, since the player already have an (in game current) getTeam.

Code: Select all

interface IUser {
    PlayerTeam GetTeam();
}
The GetTeam() method above would return the game team (team that it need to respawn), not the IPlayer team.

Another questions, why Game.CreatePlayer() doesn't persists the team from the game settings? It always spawns a new player using the independent team.

I'm current limited by that, thanks for reading! I'm waiting a response.
The IUser class only keep track of real players interfaces, you can specify the entity they will controll but everything else (health, team, world position, etc...) is handled by the IPlayer class.

Since you're trying to set players teams with /SETTEAMS command, the changes will be applied next round, that's why you can see an arrow with a number of a team, but technically the player team is still the same untill a new round begins.

I guess you will find more usefull the possibility to perform custom commands by reading the chat through scripts, an already planned feature that brings unlimited uses and also may solve your needs to change something (script behaviour, game objects, etc...) during runtime, you can read about ScriptAPI changes here.

Re: We should be able to get the team from the IUser

Posted: Mon Jan 15, 2018 11:15 pm
by MrAnyone
The IUser class only keep track of real players interfaces, you can specify the entity they will controll but everything else (health, team, world position, etc...) is handled by the IPlayer class.

Since you're trying to set players teams with /SETTEAMS command, the changes will be applied next round, that's why you can see an arrow with a number of a team, but technically the player team is still the same untill a new round begins.

I guess you will find more usefull the possibility to perform custom commands by reading the chat through scripts, an already planned feature that brings unlimited uses and also may solve your needs to change something (script behaviour, game objects, etc...) during runtime, you can read about ScriptAPI changes here.
Oh, so the IUser can't have a team, that I understood.

Now, I think that what I really need is get the current teams settings. Or, in a more generic approach, get the server game info. Is there any way to do that?

I'll explain what I need to do if it helps you clarify what I'm asking:
  • It's an arena map, every time a player dies, it goes to a lobby.
  • When the player selects a kit. I need to know what team the /setteams command gives for the user ID. It's sequential if /setteams 10000000, user with ID 0 will have the team 1 (blue).
  • Suppose that I create (respawn) a player. The player comes with team 0, how do I get the game settings to give him the correct one? It's impossible currently.
Thanks for the response! I liked the currently scriptAPI planned features.

Re: We should be able to get the team from the IUser

Posted: Mon Jan 15, 2018 11:52 pm
by JakSparro98
MrAnyone wrote:
Mon Jan 15, 2018 11:15 pm
The IUser class only keep track of real players interfaces, you can specify the entity they will controll but everything else (health, team, world position, etc...) is handled by the IPlayer class.

Since you're trying to set players teams with /SETTEAMS command, the changes will be applied next round, that's why you can see an arrow with a number of a team, but technically the player team is still the same untill a new round begins.

I guess you will find more usefull the possibility to perform custom commands by reading the chat through scripts, an already planned feature that brings unlimited uses and also may solve your needs to change something (script behaviour, game objects, etc...) during runtime, you can read about ScriptAPI changes here.
Oh, so the IUser can't have a team, that I understood.

Now, I think that what I really need is get the current teams settings. Or, in a more generic approach, get the server game info. Is there any way to do that?

I'll explain what I need to do if it helps you clarify what I'm asking:
  • It's an arena map, every time a player dies, it goes to a lobby.
  • When the player selects a kit. I need to know what team the /setteams command gives for the user ID. It's sequential if /setteams 10000000, user with ID 0 will have the team 1 (blue).
  • Suppose that I create (respawn) a player. The player comes with team 0, how do I get the game settings to give him the correct one? It's impossible currently.
Thanks for the response! I liked the currently scriptAPI planned features.
Very few things are impossible with current classes provided by the ScriptAPI, there is a simple solution for what you asks.

When a player dies you can save his instance in a custom object, then when it's time to respawn him you can read data from this object wich contains the user that was controlling the player, what his team was, and so on.
Now that the user is reassigned a new player with same profile, same team, etc. you only need to read the sender team when some one press a button in the lobby.

I simplified the steps just for giving you an idea of how this system works with scripts, if you need some code, no problem, me and the scripters community will help you with pleasure.

Re: We should be able to get the team from the IUser

Posted: Tue Jan 16, 2018 3:11 am
by MrAnyone
I already did that, but there is a problem, when a new player logs in into the server, I can't get "what is his team on /setteams".

Code that I'm working on: https://pastebin.com/z1hXynLC
I know it is kinda messed up, like old "Utils.settimers", I'm working in this code since like, 2016 but I never had time to properly finish it.

Line 776 has a persistentTeam variable from the DynamicUser class. Line 787 assigns it, the problem about new players is that when someone logs in they doesn't spawn automatically and the team assigned to the player when I use the respawn() method (line 876) is 0.

So even when doing that the script can't dynamically assign the teams.

If the host decides to keep the teams all 0 in the middle of the game, only in the next round the script will "figure out" the correct teams to use.

Thanks for the feedback!
me and the scripters community will help you with pleasure.
This is what makes this community great.

Re: We should be able to get the team from the IUser

Posted: Sun Mar 11, 2018 1:14 pm
by Gurt
Added IUser.GetTeam() (If this user isn't controlling any player the current team assigned in the lobby will be returned.)
Added IUser.GameSlotIndex property (Gets the game slot index (lobby slot index) this user occupies.)
Available after Beta 1.0.2c