diff --git a/dlls/dod2/dodfun/CMisc.cpp b/dlls/dod2/dodfun/CMisc.cpp index ce201368..248b01ea 100755 --- a/dlls/dod2/dodfun/CMisc.cpp +++ b/dlls/dod2/dodfun/CMisc.cpp @@ -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 ); + } +} \ No newline at end of file diff --git a/dlls/dod2/dodfun/CMisc.h b/dlls/dod2/dodfun/CMisc.h index a7c7eb62..92eee36c 100755 --- a/dlls/dod2/dodfun/CMisc.h +++ b/dlls/dod2/dodfun/CMisc.h @@ -83,6 +83,7 @@ public: void Disconnect(); void killPlayer(); void setTeamName( char *szName ); + void getTeamName( char *szName ); inline bool IsBot(){ const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict); diff --git a/dlls/dod2/dodfun/NPD.cpp b/dlls/dod2/dodfun/NPD.cpp index d081f4f1..69cd8b8a 100755 --- a/dlls/dod2/dodfun/NPD.cpp +++ b/dlls/dod2/dodfun/NPD.cpp @@ -75,7 +75,7 @@ static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){ return 0; } int iTeam = params[2]; - if ( iTeam<1 || iTeam>2 ){ + if ( iTeam<1 || iTeam>3 ){ MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; } @@ -87,16 +87,15 @@ static cell AMX_NATIVE_CALL set_user_team(AMX *amx, cell *params){ pPlayer->killPlayer(); pPlayer->pEdict->v.team = iTeam; - char szTeamName[16]; switch( iTeam ){ - case 1: strcpy(szTeamName,"Allies"); + case 1: pPlayer->setTeamName("Allies"); break; - case 2: strcpy(szTeamName,"Axis"); + case 2: pPlayer->setTeamName("Axis"); + break; + case 3: pPlayer->setTeamName("Spectators"); break; } - pPlayer->setTeamName(szTeamName); - if ( bSteam ) *( (int*)pPlayer->pEdict->pvPrivateData + STEAM_PDOFFSET_RCLASS) = 1; // set random class else @@ -246,6 +245,27 @@ static cell AMX_NATIVE_CALL set_user_teamname(AMX *amx, cell *params){ 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){ int index = params[1]; if (index<1||index>gpGlobals->maxClients){ @@ -304,7 +324,7 @@ AMX_NATIVE_INFO pd_Natives[] = { { "dod_set_pl_deaths", set_user_deaths }, { "dod_set_user_score", set_user_score }, { "dod_set_pl_teamname", set_user_teamname }, - + { "dod_get_pl_teamname", get_user_teamname }, { "dod_is_deployed", is_weapon_deployed }, { "dod_test_pd", test_pd }, diff --git a/dlls/dod2/dodfun/moduleconfig.cpp b/dlls/dod2/dodfun/moduleconfig.cpp index 96db2624..3997c6f3 100755 --- a/dlls/dod2/dodfun/moduleconfig.cpp +++ b/dlls/dod2/dodfun/moduleconfig.cpp @@ -103,6 +103,7 @@ void PlayerPreThink_Post( edict_t *pEntity ) { else if ( pEntity->v.iuser4 < pPlayer->staminaMin ) pEntity->v.iuser4 = pPlayer->staminaMin; } + RETURN_META(MRES_IGNORED); }