Limit max players in a deathmatch ?
#1

Hi, everything in the title, I search how to limit the number max of players in a deathmatch, for example:

PlayerA type /dm3 > He is teleported in the deathmatch

PlayerB type /dm3 > He is teleported too in the deathmatch

PlayerC type /dm3 > He got an error message like "deathmatch 3 is full" and he can't join the deathmatch.

Can someone help me please ?
Reply
#2

Just an short example:

pawn Код:
new DM3Joiners;
new DMParticipant[MAX_PLAYERS];

//at the cmd
if(DMParticipant[playerid]==1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are already in a deatmatch.");
if(DM3Joiners>=3)
{
//Your code....then
DM3Joiners++;
DMParticipant[playerid]=1;
}
else
{
return SendClientMessage(playerid, COLOR_RED, "Dm 3 is full.");
}


//OnPlayerDeath
DM3Joiners--;
DMParticipant[playerid]=0;


//OnPlayerDisconnect
DMParticipant[playerid]=0;

This was just fast typed.
If you have any questions, or any errors, or something more, just let me know.

Jeffry
Reply
#3

At the top:
Код:
new dm3;// to count players joined.
In OnPlayerCommandText
Код:
if(strcmp("/pm", cmdtext, true) == 0)
{
   if(dm3 == 0)
   {
     dm3++;
     // make player teleport to deathmatch
   }
   if(dm3 == 2)
   {
     SendClientMessage(playerid, COLOR, "The deathmatch is full. You have to wait.");
   }
   return 1;
}
Reply
#4

Quote:
Originally Posted by |)ЂΩ†{−}ЂR™ – Dare To Die
At the top:
Код:
new dm3;// to count players joined.
In OnPlayerCommandText
Код:
if(strcmp("/pm", cmdtext, true) == 0)
{
   if(dm3 == 0)
   {
     dm3++;
     // make player teleport to deathmatch
   }
   if(dm3 == 2)
   {
     SendClientMessage(playerid, COLOR, "The deathmatch is full. You have to wait.");
   }
   return 1;
}
Your code wont work, as only 1 player can join as you did "if(dm3 == 0)" has to be like "if(dm3 < 2)"
Reply
#5

It works, thanks =)
Reply
#6

Quote:
Originally Posted by Naxix
Quote:
Originally Posted by |)ЂΩ†{−}ЂR™ – Dare To Die
At the top:
Код:
new dm3;// to count players joined.
In OnPlayerCommandText
Код:
if(strcmp("/pm", cmdtext, true) == 0)
{
   if(dm3 == 0)
   {
     dm3++;
     // make player teleport to deathmatch
   }
   if(dm3 == 2)
   {
     SendClientMessage(playerid, COLOR, "The deathmatch is full. You have to wait.");
   }
   return 1;
}
Your code wont work, as only 1 player can join as you did "if(dm3 == 0)" has to be like "if(dm3 < 2)"
oh yea. Mistake!! :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)