View Single Post
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