Changing rooms of multiple players

Started by Shavit, Sun 15/12/2013 21:41:05

Previous topic - Next topic

Shavit

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

  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

Khris

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.

monkey0506

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.

Shavit

I found the problem:

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

SMF spam blocked by CleanTalk