Implemented amb291 - cs_{set,get}_c4_defusing()

This commit is contained in:
Steve Dudenhoeffer 2007-08-03 19:11:47 +00:00
parent aa2cac0f0c
commit ffb8fc683b
3 changed files with 42 additions and 0 deletions

View File

@ -1707,6 +1707,38 @@ static cell AMX_NATIVE_CALL cs_set_c4_explode_time(AMX* amx, cell* params)
return 1;
}
static cell AMX_NATIVE_CALL cs_get_c4_defusing(AMX* amx, cell* params)
{
CHECK_NONPLAYER(params[1]);
edict_t* pC4 = INDEXENT(params[1]);
// Make sure it's a c4
if (strcmp(STRING(pC4->v.classname), "grenade") != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not C4!", params[1], STRING(pC4->v.classname));
return 0;
}
return *((char*)((REAL*)pC4->pvPrivateData + OFFSET_C4_DEFUSING)) ? 1 : 0;
return 1;
}
static cell AMX_NATIVE_CALL cs_set_c4_defusing(AMX* amx, cell* params)
{
CHECK_NONPLAYER(params[1]);
edict_t* pC4 = INDEXENT(params[1]);
// Make sure it's a c4
if (strcmp(STRING(pC4->v.classname), "grenade") != 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not C4!", params[1], STRING(pC4->v.classname));
return 0;
}
*((char*)((REAL*)pC4->pvPrivateData + OFFSET_C4_DEFUSING)) = params[2] ? 1 : 0;
return 1;
}
#else
@ -1726,6 +1758,8 @@ static cell AMX_NATIVE_CALL not_on_64(AMX* amx, cell* params)
#define cs_set_hostage_nextuse not_on_64
#define cs_get_c4_explode_time not_on_64
#define cs_set_c4_explode_time not_on_64
#define cs_get_c4_defusing not_on_64
#define cs_set_c4_defusing not_on_64
#endif
@ -1788,6 +1822,8 @@ AMX_NATIVE_INFO cstrike_Exports[] = {
{"cs_set_hostage_nextuse", cs_set_hostage_nextuse},
{"cs_get_c4_explode_time", cs_get_c4_explode_time},
{"cs_set_c4_explode_time", cs_set_c4_explode_time},
{"cs_get_c4_defusing", cs_get_c4_defusing},
{"cs_set_c4_defusing", cs_set_c4_defusing},
{NULL, NULL}
};

View File

@ -111,6 +111,7 @@
#define OFFSET_ARMOURY_TYPE 34 + EXTRAOFFSET_WEAPONS
// C4 offsets
#define OFFSET_C4_EXPLODE_TIME 100 + EXTRAOFFSET
#define OFFSET_C4_DEFUSING 0x60 + EXTRAOFFSET
#else
// Amd64 offsets here
#define OFFSET_ARMORTYPE 137 + EXTRAOFFSET

View File

@ -338,6 +338,11 @@ native Float:cs_get_c4_explode_time(index);
native cs_set_c4_explode_time(index, Float:value);
/* Gets or sets whether the C4 is being defused.
*/
native bool:cs_get_c4_defusing(c4index);
native cs_set_c4_defusing(c4index, bool:defusing);
/**
* Called when CS internally fires a command to a player. It does this for a few
* functions, most notably rebuy/autobuy functionality. This is also used to pass