Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Shavit on Sun 15/12/2013 21:41:05

Title: Changing rooms of multiple players
Post by: Shavit on Sun 15/12/2013 21:41:05
Hi,

I have a room which changes alot when I'm doing some action in it, so I craeted alternate room for the room when presents the other situation.

When I'm doing the action in the room, I'm perfroming ChangeRoomAutoPosition to my player, but since I have 3 players, I want to change the room of the other players also - when they are in this room, like this for example:

Code (ags) Select

  player.ChangeRoomAutoPosition(3);
  cPlayer2.SetAsPlayer();
  player.ChangeRoomAutoPosition(3);


but AGS report an error : "run this command since the is a NewRoom command already quested to run".

Help will be appreciated ! 8-0
Title: Re: Changing rooms of multiple players
Post by: Khris on Sun 15/12/2013 22:00:45
You can't use the command like that. Using it the first time puts the room change in the queue, and you can't call it a second time in the same function.

If the other players are set to follow your player character, they will change the room anyway. If they aren't, you have to use .ChangeRoom on them instead.
Title: Re: Changing rooms of multiple players
Post by: monkey0506 on Mon 16/12/2013 02:16:01
Right, the ChangeRoom functions are part of the Character type, they aren't exclusive to the player character. If you're wanting to just make sure all three characters change rooms without duplicate code, you can just avoid using the player keyword and call ChangeRoom directly on the character instances. It's only queued/delayed when calling it on the player character, which AGS will sort out internally, and all three characters will be moved to the new room.
Title: Re: Changing rooms of multiple players
Post by: Shavit on Mon 16/12/2013 06:18:55
I found the problem:

I tried to perform ChangeRoomAutoPosition of performing ChangeRoom on the other players...