Hi everyone, I would like to know how to make a waiting queue for players with only ACS.
In my Invasion Project when people die they are teleported in the waiting room, if there are no reinforcement then the waiting queue is turned on and will free the 1st player who spawned in the room in a random delay then loop and deal with the second.
I know ACS but don't know where to start to make it works.
Thanks for the help.
ACS Help - Waiting Queue
RE: ACS Help - Waiting Queue
A quirky but surefire way could be creating a dummy ammotype, and giving 1 of it to every player each time someone spawns in there. That way, the player with most of that ammotype would be the first one. Then you can use CheckInventory to see how many the player has, and if they have enough (should be the number of players you want in there), then they get to teleport back AND lose all of that ammotype. This could work by itself too, if implemented correctly, but also requires DECORATE.
Spoiler: Decorate code (Open)
Spoiler: ACS (Open)For giving a CountMeIn to everyone that enters the spawn area, you need to define a RESPAWN script with a FOR loop and GiveActorInventory, like this:
Spoiler: ACS (Open)
Last edited by Jigsaw on Sun Nov 22, 2015 8:52 pm, edited 1 time in total.
- ZZYZX
- Posts a lot
- Posts: 742
- Joined: Thu Jun 07, 2012 5:56 pm
- Location: Ukraine
- Clan: A3
- Clan Tag: [A3]
RE: ACS Help - Waiting Queue
"surefire way"
[spoiler][/spoiler]
On DEATH (that, or ENTER and RESPAWN), run WQ_AddPlayer. Then once WaitQueueLen is above 0, wait your random delay and run WQ_RemoveFirstPlayer.
The number returned by WQ_RemoveFirstPlayer is the first player from the queue.
On DISCONNECT, run WQ_RemovePlayer on the player that disconnects.
The code isn't tested, but should work.
[spoiler]
Code: Select all
#define MAXPLAYERS 64
int WaitQueueLen = 0;
int WaitQueue[MAXPLAYERS+1];
function bool WQ_Contains(int playernum)
{
for (int i = 0; i < WaitQueueLen; i++)
{
if (WaitQueue[i] == playernum)
return true;
}
return false;
}
function void WQ_AddPlayer(int playernum)
{
if (WQ_Contains(playernum))
return;
WaitQueue[WaitQueueLen] = playernum; // put at the end of the queue
WaitQueueLen++;
}
function void WQ_RemovePlayer(int playernum)
{
bool found = false;
for (int i = 0; i < WaitQueueLen; i++)
{
if (WaitQueue[i] == playernum)
found = true;
if (found) WaitQueue[i] = WaitQueue[i+1];
}
if (found) WaitQueueLen--;
}
function int WQ_RemoveFirstPlayer(void)
{
if (WaitQueueLen <= 0) return -1;
int player = WaitQueue[0];
WQ_RemovePlayer(player);
return player;
}
On DEATH (that, or ENTER and RESPAWN), run WQ_AddPlayer. Then once WaitQueueLen is above 0, wait your random delay and run WQ_RemoveFirstPlayer.
The number returned by WQ_RemoveFirstPlayer is the first player from the queue.
On DISCONNECT, run WQ_RemovePlayer on the player that disconnects.
The code isn't tested, but should work.
Last edited by ZZYZX on Sun Nov 22, 2015 11:43 pm, edited 1 time in total.
quality DoomExplorer hackeringFilystyn wrote:Do you know what windows.h is? It's D, DWORD.
overcomplicated ZDoom grenade
random Doom things
GZDoomBuilder-Bugfix
- fr blood
- Frequent Poster Miles card holder
- Posts: 995
- Joined: Wed Mar 06, 2013 4:04 pm
- Location: France
RE: ACS Help - Waiting Queue
Thank for you help guys, this seems very hard as I tought, I'll keep you guys informed if I managed or not to make it works properly.
- fr blood
- Frequent Poster Miles card holder
- Posts: 995
- Joined: Wed Mar 06, 2013 4:04 pm
- Location: France
RE: ACS Help - Waiting Queue
Sorry I didn't manage to impliment it into my wad.