Room Multiplayer Console
#1

Is it possible to display the current on Rooms to join in.

Here is my code

pawn Код:
#define MAX_ROOMS  100

enum PlayerMultiplayer
{
    Ready,
    Hoster
};
new pM[MAX_PLAYERS][PlayerMultiplayer];

enum RoomMultiplayer
{
    Players,
    Rooms,
    Hoster[MAX_PLAYER_NAME]
};
new rM[RoomMultiplayer];

new str[12];
format(str, sizeof(str), "N/A");
rM[Hoster] = str;
rM[Rooms] = 0;
rM[Players] = 0;

CMD:multiplayer(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 1583.8099,-1688.2061,6.2188))
    {
        for(new = i; i < MAX_ROOMS; i++)
        {
            if(rM[Rooms] >= 1)
            {
            }
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not in Multiplayer Garage!");
    return 1;
}
If so how??
Reply
#2

do you mean foreach room or the current room?

What i mean is will there be more than room running at a time?
Reply
#3

I want to built a multiplayer system.

Which when player makes a multiplayer room it will show up when player use /multiplayer.
Reply
#4

pawn Код:
new rM[RoomMultiplayer];
Should be
pawn Код:
new rM[MAX_ROOMS][RoomMultiplayer];
Example:
pawn Код:
CMD:multiplayer(playerid, params[])
{
    new string[1024];
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 1583.8099,-1688.2061,6.2188))
    {
        new check;
        for(new = i; i < MAX_ROOMS; i++)
        {
            if(rM[i][Rooms] >= 1)
            {
                check = 1;
                format(string, 1024,"%sPlayers: %i - Hoster: %s\n",string,rM[i][Players], rM[i][Hoster]);
            }
        }
        if(check==0) return ShowPlayerDialog(playerid, 1583, DIALOG_STYLE_MSGBOX, "Multiplayer::ERROR", "There are no rooms available.", "OK", "Cancel");
        ShowPlayerDialog(playerid, 1584, DIALOG_STYLE_LIST, "Multiplayer rooms", string, "Choose", "Cancel");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not in Multiplayer Garage!");
    return 1;
}
Reply
#5

now it give me many errors

Код:
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(297) : error 091: ambiguous constant; tag override is required (symbol "Hoster")
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(297) : error 047: array sizes do not match, or destination array is too small
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(298) : warning 213: tag mismatch
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(298) : error 033: array must be indexed (variable "rM")
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(299) : warning 213: tag mismatch
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(299) : error 033: array must be indexed (variable "rM")
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(308) : error 091: ambiguous constant; tag override is required (symbol "Hoster")
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(308) : error 047: array sizes do not match, or destination array is too small
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(309) : warning 213: tag mismatch
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(309) : error 033: array must be indexed (variable "rM")
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2220) : error 001: expected token: "-identifier-", but found "="
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2222) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2225) : error 017: undefined symbol "i"
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2224) : warning 204: symbol is assigned a value that is never used: "check"
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2224 -- 2228) : warning 217: loose indentation
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2224 -- 2228) : error 017: undefined symbol "check"
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2230) : warning 209: function "cmd_multiplayer" should return a value
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2231) : error 010: invalid function or declaration
C:\DOCUME~1\Justin\MYDOCU~1\AWESOM~1\GAMEMO~1\blank.pwn(2232) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Anyway how can i use the dialog in the command multiplayer in OnDialogResponse?
Reply
#6

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1583)
    {
    }
    if(dialogid == 1584)
    {
        if(!response) return 1;//If the player clicks cancel, do nothing and close the dialog.
        SetPlayerPos(playerid, x, y, z); // The X,Y,Z are to be replaced with the position(entrance) of the room, for example.
        //Let's say that the X, Y, Z are stored in rM[MAX_ROOMS][PosX]/PosY/PosZ etc.
        SetPlayerPos(playerid, rM[listitem][PosX], rM[listitem][PosY], rM[listitem][PosZ]); //What we're doing here is setting his position towards
        //The entrance of the room he chose, which is "listitem"
        new string[128];//String.
        format(string, 128, "Multiplayer:: You have entered room number %i", listitem); //Explanation of listitem and what it is.
        SendClientMessage(playerid, COLOR_RED, string); //Sending the string in red color to the player.
        rM[listitem][Players]++;//Increasing the amount of players in the room, since an extra player has joined it.
        return 1; //Finished.
    }
    return 1;
}
This is how to use OnPlayerDialogResponse.
Reply
#7

How can i list the players that are in the room?

Sorry if i ask such as easy questions..

I will bold it.

How can i list the players that are in the room?
Reply
#8

pawn Код:
enum PlayerMultiplayer
{
    Ready,
    Hoster,
    Room
};
new pM[MAX_PLAYERS][PlayerMultiplayer];
Add this, and then whenever a player joins a room, set the enum to the number of the room, for example:

pawn Код:
pM[playerid][Room] = roomid;
Then just loop through all the players in a certain room, so like:

pawn Код:
COMMAND:checkroom(playerid, params[]
{
    new
        iRoomID,
        szMessage[100],
        szPlayerName[MAX_PLAYER_NAME];
       
    if(sscanf(params, "i", iRoomID))
    {
        return SendClientMessage(playerid, COLOR_YELLOW, "USE: /checkroom [room id]");
    }
   
    // Check here to make sure they don't choose a crazy room ID
   
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(pM[i][Room] == iRoomID)
        {
            GetPlayerName(i, szPlayerName, sizeof(szPlayerName));
            format(szMessage, sizeof(szMessage), "[Room %i] %s", iRoomID, szPlayerName);
            SendClientMessage(playerid, COLOR_WHITE, szMessage);
        }
    }
    return 1;
}
Let's say BobJohn and JohnBob where in room 8, it'd output:

Quote:

[Room 8] BobJohn
[Room 8] JohnBob

Something like that, it's untested!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)