New natives: cs_set_user_armor(), cs_get_user_armor()
cs_set_user_armor() should be used instead of fun's set_user_armor().
This commit is contained in:
parent
5f7dabf9b6
commit
53188ab941
|
@ -346,6 +346,51 @@ static cell AMX_NATIVE_CALL cs_set_weapon_burstmode(AMX *amx, cell *params) // c
|
||||||
return 1;
|
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
|
static cell AMX_NATIVE_CALL cs_get_user_vip(AMX *amx, cell *params) // cs_get_user_vip(index); = 1 param
|
||||||
{
|
{
|
||||||
// Is user vip?
|
// Is user vip?
|
||||||
|
@ -1193,6 +1238,8 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
|
||||||
{"cs_set_user_tked", cs_set_user_tked},
|
{"cs_set_user_tked", cs_set_user_tked},
|
||||||
{"cs_get_user_driving", cs_get_user_driving},
|
{"cs_get_user_driving", cs_get_user_driving},
|
||||||
{"cs_get_user_stationary", cs_get_user_stationary},
|
{"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!
|
//------------------- <-- max 19 characters!
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
// "player" entities
|
// "player" entities
|
||||||
#if !defined __amd64__
|
#if !defined __amd64__
|
||||||
// 32 bit offsets here
|
// 32 bit offsets here
|
||||||
|
#define OFFSET_ARMORTYPE 112 + EXTRAOFFSET
|
||||||
#define OFFSET_TEAM 114 + EXTRAOFFSET
|
#define OFFSET_TEAM 114 + EXTRAOFFSET
|
||||||
#define OFFSET_CSMONEY 115 + EXTRAOFFSET
|
#define OFFSET_CSMONEY 115 + EXTRAOFFSET
|
||||||
#define OFFSET_PRIMARYWEAPON 116 + EXTRAOFFSET
|
#define OFFSET_PRIMARYWEAPON 116 + EXTRAOFFSET
|
||||||
|
@ -100,6 +101,7 @@
|
||||||
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
|
#define OFFSET_HOSTAGEID 487 + EXTRAOFFSET
|
||||||
#else
|
#else
|
||||||
// Amd64 offsets here
|
// Amd64 offsets here
|
||||||
|
//#define OFFSET_ARMORTYPE ??? + EXTRAOFFSET // need to find this one out! :-)
|
||||||
#define OFFSET_TEAM 139 + EXTRAOFFSET // +25
|
#define OFFSET_TEAM 139 + EXTRAOFFSET // +25
|
||||||
#define OFFSET_CSMONEY 140 + EXTRAOFFSET // +25
|
#define OFFSET_CSMONEY 140 + EXTRAOFFSET // +25
|
||||||
#define OFFSET_PRIMARYWEAPON 141 + EXTRAOFFSET // +25
|
#define OFFSET_PRIMARYWEAPON 141 + EXTRAOFFSET // +25
|
||||||
|
@ -205,6 +207,10 @@
|
||||||
#define AMD64_STATIONARY_NO 2
|
#define AMD64_STATIONARY_NO 2
|
||||||
#define AMD64_STATIONARY_YES 3
|
#define AMD64_STATIONARY_YES 3
|
||||||
|
|
||||||
|
#define CS_ARMOR_NONE 0
|
||||||
|
#define CS_ARMOR_KEVLAR 1
|
||||||
|
#define CS_ARMOR_ASSAULTSUIT 2
|
||||||
|
|
||||||
enum CS_Internal_Models {
|
enum CS_Internal_Models {
|
||||||
CS_DONTCHANGE = 0,
|
CS_DONTCHANGE = 0,
|
||||||
CS_CT_URBAN = 1,
|
CS_CT_URBAN = 1,
|
||||||
|
|
|
@ -176,6 +176,20 @@ native cs_get_user_driving(index);
|
||||||
*/
|
*/
|
||||||
native cs_get_user_stationary(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.
|
/* Returns 1 if specified weapon is in burst mode.
|
||||||
*/
|
*/
|
||||||
native cs_get_weapon_burst(index);
|
native cs_get_weapon_burst(index);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user