diff --git a/dlls/cstrike/cstrike.cpp b/dlls/cstrike/cstrike.cpp index d9803217..41d3b4b5 100755 --- a/dlls/cstrike/cstrike.cpp +++ b/dlls/cstrike/cstrike.cpp @@ -346,6 +346,51 @@ static cell AMX_NATIVE_CALL cs_set_weapon_burstmode(AMX *amx, cell *params) // c return 1; } +static cell AMX_NATIVE_CALL cs_get_user_armor(AMX *amx, cell *params) // cs_get_user_armor(index, CsArmorType:&armortype); = 2 params +{ + // Return how much armor and set reference of what type... + // params[1] = user index + // params[2] = byref, set armor type here (no armor/vest/vest+helmet) + + CHECK_PLAYER(params[1]); + + // Make into edict pointer + edict_t *pPlayer = MF_GetPlayerEdict(params[1]); + + cell *armorTypeByRef = MF_GetAmxAddr(amx, params[2]); + *armorTypeByRef = *((int *)pPlayer->pvPrivateData + OFFSET_ARMORTYPE); + + return pPlayer->v.armorvalue; +} + +static cell AMX_NATIVE_CALL cs_set_user_armor(AMX *amx, cell *params) // cs_set_user_armor(index, armorvalue, CsArmorType:armortype); = 3 params +{ + // Set armor and set what type and send a message to client... + // params[1] = user index + // params[2] = armor value + // params[3] = armor type (no armor/vest/vest+helmet) + + CHECK_PLAYER(params[1]); + + // Make into edict pointer + edict_t *pPlayer = MF_GetPlayerEdict(params[1]); + + // Set armor value + pPlayer->v.armorvalue = params[2]; + + // Set armor type + *((int *)pPlayer->pvPrivateData + OFFSET_ARMORTYPE) = params[3]; + + if (params[3] == CS_ARMOR_KEVLAR || params[3] == CS_ARMOR_ASSAULTSUIT) { + // And send appropriate message + MESSAGE_BEGIN(params[1], GET_USER_MSG_ID(PLID, "ItemPickup", NULL), NULL, pPlayer); + WRITE_STRING(params[3] == CS_ARMOR_KEVLAR ? "item_kevlar" : "item_assaultsuit"); + MESSAGE_END(); + } + + return 1; +} + static cell AMX_NATIVE_CALL cs_get_user_vip(AMX *amx, cell *params) // cs_get_user_vip(index); = 1 param { // Is user vip? @@ -1193,6 +1238,8 @@ AMX_NATIVE_INFO cstrike_Exports[] = { {"cs_set_user_tked", cs_set_user_tked}, {"cs_get_user_driving", cs_get_user_driving}, {"cs_get_user_stationary", cs_get_user_stationary}, + {"cs_get_user_armor", cs_get_user_armor}, + {"cs_set_user_armor", cs_set_user_armor}, //------------------- <-- max 19 characters! {NULL, NULL} }; diff --git a/dlls/cstrike/cstrike.h b/dlls/cstrike/cstrike.h index dba9fd13..f84beaef 100755 --- a/dlls/cstrike/cstrike.h +++ b/dlls/cstrike/cstrike.h @@ -63,6 +63,7 @@ // "player" entities #if !defined __amd64__ // 32 bit offsets here + #define OFFSET_ARMORTYPE 112 + EXTRAOFFSET #define OFFSET_TEAM 114 + EXTRAOFFSET #define OFFSET_CSMONEY 115 + EXTRAOFFSET #define OFFSET_PRIMARYWEAPON 116 + EXTRAOFFSET @@ -100,6 +101,7 @@ #define OFFSET_HOSTAGEID 487 + EXTRAOFFSET #else // Amd64 offsets here + //#define OFFSET_ARMORTYPE ??? + EXTRAOFFSET // need to find this one out! :-) #define OFFSET_TEAM 139 + EXTRAOFFSET // +25 #define OFFSET_CSMONEY 140 + EXTRAOFFSET // +25 #define OFFSET_PRIMARYWEAPON 141 + EXTRAOFFSET // +25 @@ -205,6 +207,10 @@ #define AMD64_STATIONARY_NO 2 #define AMD64_STATIONARY_YES 3 +#define CS_ARMOR_NONE 0 +#define CS_ARMOR_KEVLAR 1 +#define CS_ARMOR_ASSAULTSUIT 2 + enum CS_Internal_Models { CS_DONTCHANGE = 0, CS_CT_URBAN = 1, diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index 2b25e015..4f9170d2 100755 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -176,6 +176,20 @@ native cs_get_user_driving(index); */ native cs_get_user_stationary(index); +/* Returns armor value and sets armor type in second parameter. + */ +enum CsArmorType { + CS_ARMOR_NONE = 0, // no armor + CS_ARMOR_KEVLAR = 1, // armor + CS_ARMOR_VESTHELM = 2 // armor and helmet +}; +native cs_get_user_armor(index, CsArmorType:armortype); + +/* Use this instead of fun's set_user_armor. + * Appropriate message to update client's HUD will be sent if armortype is kevlar or vesthelm. + */ +native cs_set_user_armor(index, armorvalue, CsArmorType:armortype); + /* Returns 1 if specified weapon is in burst mode. */ native cs_get_weapon_burst(index);