From de3dbd8a1dd8a0a13a6ae20ad3667e853aaacd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bergstr=C3=B6m?= Date: Thu, 22 Apr 2004 12:38:57 +0000 Subject: [PATCH] cs_set_user_vip - changes to VIP model + updates scoreboard when appropriate --- dlls/cstrike/cstrike.cpp | 39 ++++++++++++++++++++++++++++++++++--- dlls/cstrike/cstrike.h | 18 +++++++++++++++++ plugins/include/cstrike.inc | 8 ++++++-- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/dlls/cstrike/cstrike.cpp b/dlls/cstrike/cstrike.cpp index 6a9ed8f2..033e47f0 100755 --- a/dlls/cstrike/cstrike.cpp +++ b/dlls/cstrike/cstrike.cpp @@ -475,11 +475,44 @@ static cell AMX_NATIVE_CALL cs_set_user_vip(AMX *amx, cell *params) // cs_set_us return 0; } - if (params[2]) + if (params[2] == 1) { + // Set to "be" vip. *((int *)pPlayer->pvPrivateData + OFFSET_VIP) |= PLAYER_IS_VIP; - else + + // Set vip model + *((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL) = CS_CT_VIP; + // 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. + + // Set VIP on scoreboard. Probably doesn't work for terrorist team. + MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "ScoreAttrib", NULL)); + WRITE_BYTE(params[1]); + WRITE_BYTE(SCOREATTRIB_VIP); + MESSAGE_END(); + } + else { + // Set to not be vip. *((int *)pPlayer->pvPrivateData + OFFSET_VIP) &= ~PLAYER_IS_VIP; + // Set a random CT model. + CS_Internal_Models CTmodels[4] = {CS_CT_URBAN, CS_CT_GSG9, CS_CT_GIGN, CS_CT_SAS}; + CS_Internal_Models ct_model = CTmodels[RANDOM_LONG(0, 3)]; + *((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL) = ct_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. + + // Set nothing/dead on scoreboard. + int scoreattrib; + if (pPlayer->v.deadflag == DEAD_NO && pPlayer->v.health > 0) + scoreattrib = SCOREATTRIB_NOTHING; // cts can't have bombs anyway + else + scoreattrib = SCOREATTRIB_DEAD; + MESSAGE_BEGIN(MSG_ALL, GET_USER_MSG_ID(PLID, "ScoreAttrib", NULL)); + WRITE_BYTE(params[1]); + WRITE_BYTE(scoreattrib); + MESSAGE_END(); + } + return 1; } @@ -504,7 +537,7 @@ static cell AMX_NATIVE_CALL cs_get_user_team(AMX *amx, cell *params) // cs_get_u return 0; } - return (int)*((int *)pPlayer->pvPrivateData + OFFSET_TEAM); + return *((int *)pPlayer->pvPrivateData + OFFSET_TEAM); } static cell AMX_NATIVE_CALL cs_set_user_team(AMX *amx, cell *params) // cs_set_user_team(index, team, model = 0); = 3 params diff --git a/dlls/cstrike/cstrike.h b/dlls/cstrike/cstrike.h index aee857ac..058ae016 100755 --- a/dlls/cstrike/cstrike.h +++ b/dlls/cstrike/cstrike.h @@ -212,6 +212,24 @@ pfnmodule_engine_g* g_engModuleFunc; #define DEFUSER_COLOUR_B 0 #define HAS_NVGOGGLES (1<<0) + +#define SCOREATTRIB_NOTHING 0 +#define SCOREATTRIB_DEAD 1 +#define SCOREATTRIB_BOMB 2 // t only +#define SCOREATTRIB_VIP 4 // ct only + +enum CS_Internal_Models { + CS_DONTCHANGE = 0, + CS_CT_URBAN = 1, + CS_T_TERROR = 2, + CS_T_LEET = 3, + CS_T_ARCTIC = 4, + CS_CT_GSG9 = 5, + CS_CT_GIGN = 6, + CS_CT_SAS = 7, + CS_T_GUERILLA = 8, + CS_CT_VIP = 9 +}; // cstrike-specific defines above // Globals below diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index 2a72813e..7865e42a 100755 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -139,8 +139,12 @@ native cs_set_user_team(index, team, model = CS_DONTCHANGE); */ native cs_get_user_vip(index); -/* If vip = 1, user is set to vip. Note that this is useful to unset vips, so they can change teams properly. - * This will not change the player's model to/from vip, or add/remove the "VIP" text in scoreboard. +/* If vip = 1, user is set to vip. + * Model will be changed to VIP model if 1, else it will be changed to a random CT model. + * This shouldn't be used for players on teams other than CT. + * NOTE: this is mostly useful for unsetting vips, so they can change teams and/or buy items properly. + * It does not alter game play; the one being VIP at start of round will retain internal status as VIP; terrorists + * can terminate him and accomplish their objective, etc. */ native cs_set_user_vip(index, vip = 1);