Page 1 of 1

how to comunication beetween room and zone

Posted: 12 Dec 2024, 03:56
by dekii
i'm making a card game.The player can still auto playing on a room when offline, so i working on a custom list player, not a default user variable.
My game have a rules, when player out and number of players on a room < minNumberOnRoom, i need to check all another room to balance player rooms. So i need fire a event from room to my zone, and i dont know how to comunication beetween room and zone
I user sfs2x version

Re: how to comunication beetween room and zone

Posted: 12 Dec 2024, 07:33
by Lapo
Hi,
all Extensions have a method that looks like this:

Code: Select all

Object handleInternalMessage(String cmdName, Object params)

which allows to send messages between extensions.

For example from the Zone you can do the following:

Code: Select all

var someRoom = zone.getRoomByName("SomeRoom");
someRoom.getExtension().handleInternalMessage("cmd", params);

You can also do the other way around:

Code: Select all

var myZone = someRoom.getZone();
myZone.getExtension().handleInternalMessage("cmd", params);

Cheers

Re: how to comunication beetween room and zone

Posted: 12 Dec 2024, 09:13
by dekii
I solved it by your answer
Thank for your help. Have good day sir :D