View Single Post
Re: Changing a players team
Old
  (#3)
brooks
Member
 
Status: Offline
Posts: 2
Join Date: Sep 2006
Default Re: Changing a players team - 13-09-2006

My bad bro, I'm working with metamod. I cracked open amx and got some stuff from that. Not suy why I didn't think about it earlier.

Code:
void Player::changeSide()
{
    int team =0;
    int model =0;

    char strTeam[100];

    strcpy( strTeam, getTeam() );

    if( !strcmp( strTeam, "TERRORIST") )
        team = 2;
    else if( !strcmp( strTeam, "CT") )
        team = 1;
    else
        team = 3;

    *((int *)entity->pvPrivateData + OFFSET_TEAM) = team;
    if (model != 0)
        *((int *)entity->pvPrivateData + OFFSET_INTERNALMODEL) = model;
    
    // And update scoreboard by sending TeamInfo msg.
    char teaminfo[32];
    switch (team) {
        case TERRORIST:
            setTeam("TERRORIST");
            strcpy(teaminfo, "TERRORIST");
            break;
        case CT:
            setTeam("CT");
            strcpy(teaminfo, "CT");
            break;
        case SPECTATOR:
            setTeam("SPECTATOR");
            strcpy(teaminfo, "SPECTATOR");
            break;
    }

    MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "TeamInfo", NULL));
    WRITE_BYTE(0);
    WRITE_STRING(teaminfo);
    MESSAGE_END();

    CLIENT_COMMAND(entity, "kill\n");

}
Thank you anyway
  
Reply With Quote