added spectator support to dod_set_user_team native

This commit is contained in:
Lukasz Wlasinksi 2004-07-04 21:09:03 +00:00
parent 8dceb45567
commit e0f1b56363
4 changed files with 37 additions and 7 deletions

View File

@ -77,3 +77,11 @@ void CPlayer::setTeamName( char *szName ){
} }
} }
void CPlayer::getTeamName(char * szName ){
for (int i=0;i<16;i++){
if ( bSteam )
szName[i] = *( (char*)pEdict->pvPrivateData + STEAM_PDOFFSET_TEAMNAME + i );
else
szName[i] = *( (char*)pEdict->pvPrivateData + WON_PDOFFSET_TEAMNAME + i );
}
}

View File

@ -83,6 +83,7 @@ public:
void Disconnect(); void Disconnect();
void killPlayer(); void killPlayer();
void setTeamName( char *szName ); void setTeamName( char *szName );
void getTeamName( char *szName );
inline bool IsBot(){ inline bool IsBot(){
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict); const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);

View File

@ -75,7 +75,7 @@ static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){
return 0; return 0;
} }
int iTeam = params[2]; int iTeam = params[2];
if ( iTeam<1 || iTeam>2 ){ if ( iTeam<1 || iTeam>3 ){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE); MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0; return 0;
} }
@ -87,16 +87,15 @@ static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){
pPlayer->killPlayer(); pPlayer->killPlayer();
pPlayer->pEdict->v.team = iTeam; pPlayer->pEdict->v.team = iTeam;
char szTeamName[16];
switch( iTeam ){ switch( iTeam ){
case 1: strcpy(szTeamName,"Allies"); case 1: pPlayer->setTeamName("Allies");
break; break;
case 2: strcpy(szTeamName,"Axis"); case 2: pPlayer->setTeamName("Axis");
break;
case 3: pPlayer->setTeamName("Spectators");
break; break;
} }
pPlayer->setTeamName(szTeamName);
if ( bSteam ) if ( bSteam )
*( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_RCLASS) = 1; // set random class *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_RCLASS) = 1; // set random class
else else
@ -246,6 +245,27 @@ static cell AMX_NATIVE_CALL set_user_teamname(AMX *amx, cell *params){
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_user_teamname(AMX *amx, cell *params){
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->ingame ){
char szTeamName[16];
pPlayer->getTeamName(szTeamName);
return MF_SetAmxString(amx, params[2],szTeamName,params[3]);
}
return 1;
}
static cell AMX_NATIVE_CALL is_weapon_deployed(AMX *amx, cell *params){ static cell AMX_NATIVE_CALL is_weapon_deployed(AMX *amx, cell *params){
int index = params[1]; int index = params[1];
if (index<1||index>gpGlobals->maxClients){ if (index<1||index>gpGlobals->maxClients){
@ -304,7 +324,7 @@ AMX_NATIVE_INFO pd_Natives[] = {
{ "dod_set_pl_deaths", set_user_deaths }, { "dod_set_pl_deaths", set_user_deaths },
{ "dod_set_user_score", set_user_score }, { "dod_set_user_score", set_user_score },
{ "dod_set_pl_teamname", set_user_teamname }, { "dod_set_pl_teamname", set_user_teamname },
{ "dod_get_pl_teamname", get_user_teamname },
{ "dod_is_deployed", is_weapon_deployed }, { "dod_is_deployed", is_weapon_deployed },
{ "dod_test_pd", test_pd }, { "dod_test_pd", test_pd },

View File

@ -103,6 +103,7 @@ void PlayerPreThink_Post( edict_t *pEntity ) {
else if ( pEntity->v.iuser4 < pPlayer->staminaMin ) else if ( pEntity->v.iuser4 < pPlayer->staminaMin )
pEntity->v.iuser4 = pPlayer->staminaMin; pEntity->v.iuser4 = pPlayer->staminaMin;
} }
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }