.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Getting teams in CS - "TeamInfo"
Old
  (#1)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Getting teams in CS - "TeamInfo" - 12-02-2006

OK yesterday some hours I had making a tests with the "TeamInfo" CS message to get the teams without using a models. Here what I got.
Code:
// This message is sent whenever information for the teams is sended.
void BotClient_CS_TeamInfo (void *p, int index)
{

    if (strcmp((char *) p, "UNASSIGNED") == 0) 
    {
        ThreatTab[index].iTeam = TEAM_UNASSIGNED;
    }
    else if (strcmp((char *) p, "TERRORIST") == 0)
    {
        ThreatTab[index].iTeam = TEAM_T;
    }
    else if (strcmp((char *) p, "CT") == 0)
    {
        ThreatTab[index ].iTeam = TEAM_CT;
    }
    else if (strcmp((char *) p, "SPECTATOR") == 0)
    {
        ThreatTab[index].iTeam = TEAM_SPECTATOR;
    }
    state++;
}
The message is hooked fine in engine.cpp like all others clients messages but it seems to not work propertie.
I tryed to debug it. So I putted this line at the start of the function:
Code:
{ fp=fopen("EPB.txt","a"); fprintf(fp,"BotClient_CS_TeamInfo: %s\n",p); fclose(fp); }
and now the function looks like this:
Code:
// This message is sent whenever information for the teams is sended.
void BotClient_CS_TeamInfo (void *p, int index)
{

{ fp=fopen("EPB.txt","a"); fprintf(fp,"BotClient_CS_TeamInfo: %s\n",p); fclose(fp); }

    if (strcmp((char *) p, "UNASSIGNED") == 0) 
    {
        ThreatTab[index].iTeam = TEAM_UNASSIGNED;
    }
    else if (strcmp((char *) p, "TERRORIST") == 0)
    {
        ThreatTab[index].iTeam = TEAM_T;
    }
    else if (strcmp((char *) p, "CT") == 0)
    {
        ThreatTab[index ].iTeam = TEAM_CT;
    }
    else if (strcmp((char *) p, "SPECTATOR") == 0)
    {
        ThreatTab[index].iTeam = TEAM_SPECTATOR;
    }
    state++;
}
and after I opened the EPB.txt file I got this:
Code:
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: UNASSIGNED
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: UNASSIGNED
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: TERRORIST
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: UNASSIGNED
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: TERRORIST
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: UNASSIGNED
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: TERRORIST
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: TERRORIST
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: UNASSIGNED
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: TERRORIST
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: TERRORIST
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: CT
BotClient_CS_TeamInfo: 
BotClient_CS_TeamInfo: UNASSIGNED
This message is called when a player or bot change a team and on each round start.
I moved the debug info in to the if {} else {} to see if my checks for the messages are ok and it seems that all is work just fine but when I try to get the teams of the players it's just not work. I can't get the players and bots teams. The message is sended correct and I get it correct but it seems that this lines are not working correct:
Code:
ThreatTab[index].iTeam = TEAM_UNASSIGNED;
ThreatTab[index].iTeam = TEAM_T;
ThreatTab[index].iTeam = TEAM_SPECTATOR;
If someone can tell me where I wrong I will be very happy.
  
Reply With Quote
Re: Getting teams in CS - "TeamInfo"
Old
  (#2)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,425
Join Date: Apr 2004
Default Re: Getting teams in CS - "TeamInfo" - 12-02-2006

For debug info write also index, to be sure if it is called with ALL parameters correctly.
[EDIT1]
Code:
static cell AMX_NATIVE_CALL cs_set_user_team(AMX *amx, cell *params) // cs_set_user_team(index, team, model = 0); = 3 params
{
    // Set user team
    // params[1] = user index
    // params[2] = team
    // params[3] = model = 0

    // Valid entity should be within range
    CHECK_PLAYER(params[1]);

    // Make into edict pointer
    edict_t *pPlayer = MF_GetPlayerEdict(params[1]);

    int model = params[3];

    // Just set team. Removed check of 1-2-3, because maybe scripters want to create new teams, 4, 5 etc?
    *((int *)pPlayer->pvPrivateData + OFFSET_TEAM) = params[2];
    if (model != 0)
        *((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL) = model;
    
    // This makes the model get updated right away.
    MDLL_ClientUserInfoChanged(pPlayer, GETINFOKEYBUFFER(pPlayer)); //  If this causes any problems for WON, do this line only in STEAM builds.

    // And update scoreboard by sending TeamInfo msg.
    char teaminfo[32];
    switch (params[2]) {
        case TEAM_UNASSIGNED:
            strcpy(teaminfo, "UNASSIGNED");
            break;
        case TEAM_T:
            strcpy(teaminfo, "TERRORIST");
            break;
        case TEAM_CT:
            strcpy(teaminfo, "CT");
            break;
        case TEAM_SPECTATOR:
            strcpy(teaminfo, "SPECTATOR");
            break;
        default:
            int team_nr = (int)params[2];
            sprintf(teaminfo, "TEAM_%i", team_nr);
    }
    MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "TeamInfo", NULL));
    WRITE_BYTE(params[1]);
    WRITE_STRING(teaminfo);
    MESSAGE_END();
(...)
}
I believe You need to get it as message sent to ALL, and You need to catch also this what is written as WRITE_BYTE (params[1]) - this is the player index. Before You will not show how Your function gets called, nothing more helpful for You will be written here...
[/EDIT1]
[EDIT2]
You need to use:
Code:
static int iPlayerIndex; 
switch (state)
 {
 case 0:
    iPlayerIndex = *(int *)p;
    break;
 case 1:
    if (strcmp((char *) p, "UNASSIGNED") == 0) 
    {
        ThreatTab[iPlayerIndex].iTeam = TEAM_UNASSIGNED;
    }
    else if (strcmp((char *) p, "TERRORIST") == 0)
    {
        ThreatTab[iPlayerIndex].iTeam = TEAM_T;
    }
    else if (strcmp((char *) p, "CT") == 0)
    {
        ThreatTab[iPlayerIndex].iTeam = TEAM_CT;
    }
    else if (strcmp((char *) p, "SPECTATOR") == 0)
    {
        ThreatTab[iPlayerIndex].iTeam = TEAM_SPECTATOR;
    }
    break;
}
Or maybe You need to use iPlayerIndex-1 as index in ThreatTab.
[/EDIT2]

Last edited by KWo; 12-02-2006 at 16:26..
  
Reply With Quote
Re: Getting teams in CS - "TeamInfo"
Old
  (#3)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: Getting teams in CS - "TeamInfo" - 12-02-2006

KWo thanks you so much. I was forgot that I must get the player index via the message.
So here the right function:
Code:
// This message is sent whenever information for the teams is sended. - THE STORM
void Client_CS_TeamInfo (void *p, int/* iPlayerIndex*/)
{

    static int iPlayerIndex;

    switch (state++)
    {
    case 0:
        iPlayerIndex = *(int *)p;
        break;
    case 1:
        if (strcmp((char *) p, "UNASSIGNED") == 0) 
        {
            clients[iPlayerIndex - 1].iTeam = TEAM_CS_UNASSIGNED;
        }
        else if (strcmp((char *) p, "TERRORIST") == 0)
        {
            clients[iPlayerIndex - 1].iTeam = TEAM_CS_TERRORIST;
        }
        else if (strcmp((char *) p, "CT") == 0)
        {
            clients[iPlayerIndex - 1].iTeam = TEAM_CS_COUNTER;
        }
        else if (strcmp((char *) p, "SPECTATOR") == 0)
        {
            clients[iPlayerIndex - 1].iTeam = TEAM_CS_SPECTATOR;
        }
        break;
    }
}
No more team detection with models.

Last edited by The Storm; 12-02-2006 at 18:41..
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com