ACS Team Player Problems

Discuss all aspects related to modding Zandronum here.
Post Reply
Captain Toenail
 
Posts: 37
Joined: Sat Apr 20, 2013 8:59 pm

ACS Team Player Problems

#1

Post by Captain Toenail » Tue Jan 06, 2015 6:33 pm

I'm trying to setup a new gamemode that works with TLMS.

The gist of it is, every 10 seconds one team is given a weapon and the other is disarmed. This alternates till everyone on one team is dead.

Problem is my script is giving both teams the weapon at the same time, and then disarming both teams at the same time. I'm stumped, any ideas?

Attempt 1:

Code: Select all

#include "zcommon.acs"

// assign players a TID
Script 749 ENTER
{
	Thing_ChangeTID(0, 1000 + PlayerNumber()); // This assigns the TID
}

// Set player health to 1 and remove all weapons
script 751 ENTER
{
    int playerTID = ActivatorTID();

    SetActorProperty (playerTID, APROP_Health, 1);
    ClearInventory();
}

// Set player health to 1 and remove all weapons
script 750 RESPAWN
{
    int playerTID = ActivatorTID();

    SetActorProperty (playerTID, APROP_Health, 1);
    ClearInventory();
}


// choose starting team
script 754 OPEN
{
    ACS_Execute(random(752, 753), 0, 0, 0, 0);
}

// red team then blue team
script 752 (void)
{
    ACS_Execute (755, 0, 0, 0, 0);
    Delay (350); // 10 seconds
    ACS_Execute (756, 0, 0, 0, 0);
    Delay (350);
    Restart;
}

// blue team then red team
script 753 (void)
{
    ACS_Execute (756, 0, 0, 0, 0);
    Delay (350); // 10 seconds
    ACS_Execute (755, 0, 0, 0, 0);
    Delay (350);
    Restart;
}

// give red team chainsaws
script 755 (void)
{
    int playerTID = ActivatorTID();
    int teamNumber = GetPlayerInfo(playerTID, PLAYERINFO_TEAM);
    
    if (teamNumber == 1)
    {
        Print (s:"Give RED TEAM chainsaws");
        GiveInventory("Chainsaw", 1);
    }
    else
    {
        ClearInventory();
    }
}

// give blue team chainsaws
script 756 (void)
{
    int playerTID = ActivatorTID();
    int teamNumber = GetPlayerInfo(playerTID, PLAYERINFO_TEAM);
    
    if (teamNumber == 0)
    {
        Print (s:"Give BLUE TEAM chainsaws");
        GiveInventory("Chainsaw", 1);
    }
    else
    {
        ClearInventory();
    }
}
Attempt 2:

Code: Select all

Script 1 OPEN
{
    ACS_ExecuteAlways(2, 0, 0, 0);
    Delay(350);
    ACS_ExecuteAlways(3, 0, 0, 0);
    Delay(350);
    Restart;
}

Script 2 (void)
{
    int teamNumber = GetPlayerInfo(0, PLAYERINFO_TEAM);
    if (teamNumber == 0)
    {
        GiveInventory("Chainsaw", 1);
    }
    else
    {
        ClearInventory();
    }
}

Script 3 (void)
{
    int teamNumber = GetPlayerInfo(0, PLAYERINFO_TEAM);
    if (teamNumber == 1)
    {
        GiveInventory("Chainsaw", 1);
    }
    else
    {
        ClearInventory();
    }
}

Script 4 ENTER
{
    //SetActorProperty (0, APROP_Health, 1);
    ClearInventory();
}

Script 5 RESPAWN
{
    //SetActorProperty (0, APROP_Health, 1);
    ClearInventory();
}

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: ACS Team Player Problems

#2

Post by Vincent(PDP) » Tue Jan 06, 2015 7:22 pm

Code: Select all

int playerTID = ActivatorTID();
Here's your problem. The script is originally activated by the server (via the OPEN script), which means the tid returns -1. When the server activates it it will apply to every single player.

You need to do a loop through all players.

Code: Select all

For(Int i=0; i<64; i++)
{
    If(PlayerInGame(1000+i) && GetPlayerInfo(1000+i, PLAYERINFO_TEAM) == TEAM_RED)
    {
        GiveActorInventory(1000+i, "Chainsaw", 1);
    }
    Else If(PlayerInGame(1000+i) && GetPlayerInfo(1000+i, PLAYERINFO_TEAM) != TEAM_RED)
    {
        ClearActorInventory(1000+i);
    }
}
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Captain Toenail
 
Posts: 37
Joined: Sat Apr 20, 2013 8:59 pm

RE: ACS Team Player Problems

#3

Post by Captain Toenail » Tue Jan 06, 2015 7:45 pm

Hmm, ok thanks Vincent, that makes sense. However now when I run the map no players receive weapons at all. Any ideas?

Code: Select all

#include "zcommon.acs"


// assign players a TID
Script 749 ENTER
{
	Thing_ChangeTID(0, 1000 + PlayerNumber()); // This assigns the TID
}

// Set player health to 1 and remove all weapons
script 751 ENTER
{
    SetActorProperty (0, APROP_Health, 1);
    ClearInventory();
}

// Set player health to 1 and remove all weapons
script 750 RESPAWN
{
    SetActorProperty (0, APROP_Health, 1);
    ClearInventory();
}


// choose starting team
script 754 OPEN
{
    ACS_Execute(random(752, 753), 0, 0, 0, 0);
}

// red team then blue team
script 752 (void)
{
    ACS_Execute (755, 0, 0, 0, 0);
    Delay (350); // 10 seconds
    ACS_Execute (756, 0, 0, 0, 0);
    Delay (350);
    Restart;
}

// blue team then red team
script 753 (void)
{
    ACS_Execute (756, 0, 0, 0, 0);
    Delay (350); // 10 seconds
    ACS_Execute (755, 0, 0, 0, 0);
    Delay (350);
    Restart;
}

// give red team chainsaws
script 755 (void)
{

For(Int i=0; i<64; i++)
{
    If(PlayerInGame(1000+i) && GetPlayerInfo(1000+i, PLAYERINFO_TEAM) == TEAM_RED)
    {
        GiveActorInventory(1000+i, "Chainsaw", 1);
    }
    Else If(PlayerInGame(1000+i) && GetPlayerInfo(1000+i, PLAYERINFO_TEAM) != TEAM_RED)
    {
        ClearActorInventory(1000+i);
    }
}
}

// give blue team chainsaws
script 756 (void)
{

For(Int i=0; i<64; i++)
{
    If(PlayerInGame(1000+i) && GetPlayerInfo(1000+i, PLAYERINFO_TEAM) == TEAM_BLUE)
    {
        GiveActorInventory(1000+i, "Chainsaw", 1);
    }
    Else If(PlayerInGame(1000+i) && GetPlayerInfo(1000+i, PLAYERINFO_TEAM) != TEAM_BLUE)
    {
        ClearActorInventory(1000+i);
    }
}
}

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: ACS Team Player Problems

#4

Post by Vincent(PDP) » Tue Jan 06, 2015 7:50 pm

How about this?

Code: Select all

GetPlayerInfo(i, PLAYERINFO_TEAM) == TEAM_RED
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Captain Toenail
 
Posts: 37
Joined: Sat Apr 20, 2013 8:59 pm

RE: ACS Team Player Problems

#5

Post by Captain Toenail » Tue Jan 06, 2015 8:06 pm

The player's now receive their weapons, but the original problem is back in that both teams receive and lose weapons at the same time.

I think it is because the server is activating the script rather than the players individually as you said earlier. I don't know how to go about that unfortunately.

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: ACS Team Player Problems

#6

Post by Vincent(PDP) » Tue Jan 06, 2015 8:10 pm

Captain Toenail wrote: The player's now receive their weapons, but the original problem is back in that both teams receive and lose weapons at the same time.

I think it is because the server is activating the script rather than the players individually as you said earlier. I don't know how to go about that unfortunately.
That's strange... According to code it should only give the players in the specific team.
I will try the code and see what happens.

... Neither of the scripts works for me.
Okay this works a 100% to me:

Code: Select all

 // give red team chainsaws
 script 755 (void)
 {
 For(Int i=0; i<64; i++)
 {
     If(PlayerInGame(i) == True && GetPlayerInfo(i, PLAYERINFO_TEAM) == TEAM_RED)
     {
         GiveActorInventory(1000+i, "Chainsaw", 1);
     }
     Else If(PlayerInGame(i) == True && GetPlayerInfo(i, PLAYERINFO_TEAM) == TEAM_BLUE)
     {
         ClearActorInventory(1000+i);
     }
 }
 }

 // give blue team chainsaws
 script 756 (void)
 {
 For(Int i=0; i<64; i++)
 {
     If(PlayerInGame(i) == True && GetPlayerInfo(i, PLAYERINFO_TEAM) == TEAM_BLUE)
     {
         GiveActorInventory(1000+i, "Chainsaw", 1);
     }
     Else If(PlayerInGame(i) == True && GetPlayerInfo(i, PLAYERINFO_TEAM) == TEAM_RED)
     {
         ClearActorInventory(1000+i);
     }
 }
 }
Last edited by Vincent(PDP) on Tue Jan 06, 2015 8:37 pm, edited 1 time in total.
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Captain Toenail
 
Posts: 37
Joined: Sat Apr 20, 2013 8:59 pm

RE: ACS Team Player Problems

#7

Post by Captain Toenail » Tue Jan 06, 2015 10:10 pm

Excellent, thank you! :smile:

User avatar
Dusk
Developer
Posts: 581
Joined: Thu May 24, 2012 9:59 pm
Location: Turku

RE: ACS Team Player Problems

#8

Post by Dusk » Wed Jan 07, 2015 5:54 am

Whoops, I accidentally made it shorter.

Code: Select all

// give offensive team chainsaws
script 755 (int offensiveTeam)
{
	for (int i = 0; i < 64; i++)
	{
		if (PlayerInGame(i) == false)
			continue;
		
		if (GetPlayerInfo(i, PLAYERINFO_TEAM) == offensiveTeam)
			GiveActorInventory(1000+i, "Chainsaw", 1);
		else
			ClearActorInventory(1000+i);
	}
}

Lollipop
Zandrone
Posts: 1124
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

RE: ACS Team Player Problems

#9

Post by Lollipop » Wed Jan 07, 2015 6:52 am

If it isn't uber important that all players have an unique id, then all players on one team can use one id and the other team another id.
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there

User avatar
Vincent(PDP)
Forum Regular
Posts: 527
Joined: Thu Mar 14, 2013 7:35 pm
Location: Sweden
Clan: My DOOM site
Clan Tag: <MDS>
Contact:

RE: ACS Team Player Problems

#10

Post by Vincent(PDP) » Wed Jan 07, 2015 10:01 am

Dusk wrote: Whoops, I accidentally made it shorter.

Code: Select all

// give offensive team chainsaws
script 755 (int offensiveTeam)
{
	for (int i = 0; i < 64; i++)
	{
		if (PlayerInGame(i) == false)
			continue;
		
		if (GetPlayerInfo(i, PLAYERINFO_TEAM) == offensiveTeam)
			GiveActorInventory(1000+i, "Chainsaw", 1);
		else
			ClearActorInventory(1000+i);
	}
}
Hahaha. Nice. :)
//Visual Vincent ( Vincent (PDP) )
- My DOOM site Team

My projects:
Spoiler: (Open)
Doom Writer
Escape From The Laboratory - Done
Escape From The Laboratory Part 2
Parkskolan Zombie Horde Map (ZM10) - Done
In game Admin Commands for Zandronum.
Achievement Mod for Zandronum
Stats mod

Post Reply