Page 1 of 1
ACS Help - Waiting Queue
Posted: Sun Nov 22, 2015 6:04 pm
by fr blood
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.
RE: ACS Help - Waiting Queue
Posted: Sun Nov 22, 2015 8:25 pm
by Jigsaw
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)
Actor CountMeIn : Ammo
{
Inventory.Maxamount 10 //Change this according to how many players you want in there
Ammo.Backpackmaxamount 10 //this too
}
Spoiler: ACS (Open)
script 3 ENTER //Need ENTER so every player activates it upon entering level.
{
If (CheckInventory("CountMeIn")) == 10
{
TakeInventory("CountMeIn",10);
Teleport(X,Y,1);
}
delay (1); //need a delay because this'll be repeating constantly
restart;
}
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)
script 4 respawn
{
acs_execute (3,0,0,0,0); //activate the ENTER script once again.
int playerid = 0;
for (playerid = 200; playerid < 264; playerid++ ) // Repeats until playernumbers 200-264 have been given the items once.
{
GiveActorInventory(playerid,"CountMeIn",1);
}
}
RE: ACS Help - Waiting Queue
Posted: Sun Nov 22, 2015 11:29 pm
by ZZYZX
"surefire way"
[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;
}
[/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.
RE: ACS Help - Waiting Queue
Posted: Mon Nov 23, 2015 7:09 am
by fr blood
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.
RE: ACS Help - Waiting Queue
Posted: Sun Jan 10, 2016 3:55 pm
by fr blood
Sorry I didn't manage to impliment it into my wad.