Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Posts: 17
Joined: 14 Jul 2020, 13:06


Postby bhattacharyakun » 16 Sep 2020, 05:55

So I'm trying to build a matchmaking system using this article ... s/game-api
But seems like the code is kinda outdated? Its giving me alot of errors. I can't find the "zone" class either.

I've this code

Code: Select all

import java.util.List;

import com.smartfoxserver.v2.api.SFSApi;
import com.smartfoxserver.v2.entities.Room;
import com.smartfoxserver.v2.entities.Zone;
import com.smartfoxserver.v2.entities.match.BoolMatch;
import com.smartfoxserver.v2.entities.match.MatchExpression;
import com.smartfoxserver.v2.entities.match.NumberMatch;
import com.smartfoxserver.v2.entities.match.RoomProperties;

public class MatchMaking {

   MatchExpression exp = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true).and
            (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true).and
            ("isGameStarted", BoolMatch.EQUALS, false).and("minPlayersToStartGame", NumberMatch.EQUALS, 4);
   List<Room> joinableRooms = SFSApi.findRooms(Zone.getRoomListFromGroup("chess"), exp, 0);

I'm getting the error

Code: Select all

Description   Resource   Path   Location   Type
Cannot make a static reference to the non-static method getRoomListFromGroup(String) from the type Zone
one the last line.
User avatar
Site Admin
Posts: 21723
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: MatchMaking

Postby Lapo » 16 Sep 2020, 09:25

the problem is in your code.

As per the error message you're trying to access an instance method as if it were a static one, which it isn't.
In other words SFSApi does not expose a static method called findRooms. You can see that from the server side javadoc: ... FSApi.html
and also from your IDE auto-complete, which you don't seem to be using.

You're making the same mistake with the Zone class.
I would highly recommend to use a Java IDE with auto-complete such as Eclipse, Netbeans or IntelliJ, they are all great and will help you a lot with the coding.

I would also recommend to review the basics for writing Extensions here: ... uick-start ... a/overview

If there's anything else let us know.
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 30 guests