From 68d2b03e48c3d0c2b641639cc0932e50b90af711 Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Wed, 25 Apr 2007 15:40:15 +0000 Subject: [PATCH] Added amb37, amb38, amb39 and amb205: various cstrike natives. (Still need to test) --- dlls/cstrike/cstrike/cstrike.cpp | 183 +++++++++++++++++++++++++++++++ dlls/cstrike/cstrike/cstrike.h | 5 + plugins/include/cstrike.inc | 36 ++++++ 3 files changed, 224 insertions(+) diff --git a/dlls/cstrike/cstrike/cstrike.cpp b/dlls/cstrike/cstrike/cstrike.cpp index dd9c8ce5..72992f4d 100755 --- a/dlls/cstrike/cstrike/cstrike.cpp +++ b/dlls/cstrike/cstrike/cstrike.cpp @@ -1520,6 +1520,178 @@ static cell AMX_NATIVE_CALL cs_get_user_zoom(AMX *amx, cell *params) return 0; } +// Returns whether the player has a thighpack or backpack model on + +static cell AMX_NATIVE_CALL cs_get_user_submodel(AMX* amx, cell* params) +{ + // Check Player + CHECK_PLAYER(params[1]); + // Fetch player pointer + edict_t* pPlayer = MF_GetPlayerEdict(params[1]); + + return pPlayer->v.body; +} +static cell AMX_NATIVE_CALL cs_set_user_submodel(AMX* amx, cell* params) +{ + // Check Player + CHECK_PLAYER(params[1]); + // Fetch player pointer + edict_t* pPlayer = MF_GetPlayerEdict(params[1]); + + pPlayer->v.body = params[2]; + + return 1; +} +#if PAWN_CELL_SIZE == 32 +static cell AMX_NATIVE_CALL cs_get_user_lastactivity(AMX *amx, cell *params) +{ + //Return time that the user last did activity + + //Check player + CHECK_PLAYER(params[1]); + + // Make into edict pointer + edict_t *pPlayer = MF_GetPlayerEdict(params[1]); + + return amx_ftoc(*((REAL*)pPlayer->pvPrivateData + OFFSET_LASTACTIVITY)); +} + +static cell AMX_NATIVE_CALL cs_set_user_lastactivity(AMX *amx, cell *params) +{ + //set time that the user last did activity + + //Check player + CHECK_PLAYER(params[1]); + + // Make into edict pointer + edict_t *pPlayer = MF_GetPlayerEdict(params[1]); + + *((REAL*)pPlayer->pvPrivateData + OFFSET_LASTACTIVITY) = amx_ctof(params[2]); + + return 1; +} +static cell AMX_NATIVE_CALL cs_get_hostage_lastuse(AMX *amx, cell *params) +{ + //Return time that the hostage was last used + + CHECK_NONPLAYER(params[1]); + + // Make into edict pointer + edict_t* pHostage = INDEXENT(params[1]); + + // Make sure this is a hostage. + if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) { + MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname)); + return 0; + } + + return amx_ftoc(*((REAL*)pHostage->pvPrivateData + OFFSET_HOSTAGE_LASTUSE)); +} +static cell AMX_NATIVE_CALL cs_set_hostage_lastuse(AMX *amx, cell *params) +{ + //Return time that the hostage was last used + + CHECK_NONPLAYER(params[1]); + + // Make into edict pointer + edict_t* pHostage = INDEXENT(params[1]); + + // Make sure this is a hostage. + if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) { + MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname)); + return 0; + } + + *((REAL*)pHostage->pvPrivateData + OFFSET_HOSTAGE_LASTUSE) = amx_ctof(params[2]); + + return 1; +} +static cell AMX_NATIVE_CALL cs_get_hostage_nextuse(AMX* amx, cell* params) +{ + //Return time that the hostage was last used + + CHECK_NONPLAYER(params[1]); + + // Make into edict pointer + edict_t* pHostage = INDEXENT(params[1]); + + // Make sure this is a hostage. + if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) { + MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname)); + return 0; + } + + return amx_ftoc(*((REAL*)pHostage->pvPrivateData + OFFSET_HOSTAGE_NEXTUSE)); +} +static cell AMX_NATIVE_CALL cs_set_hostage_nextuse(AMX* amx, cell* params) +{ + //Return time that the hostage was last used + + CHECK_NONPLAYER(params[1]); + + // Make into edict pointer + edict_t* pHostage = INDEXENT(params[1]); + + // Make sure this is a hostage. + if (strcmp(STRING(pHostage->v.classname), "hostage_entity") != 0) { + MF_LogError(amx, AMX_ERR_NATIVE, "Entity %d (\"%s\") is not a hostage", params[1], STRING(pHostage->v.classname)); + return 0; + } + + *((REAL*)pHostage->pvPrivateData + OFFSET_HOSTAGE_NEXTUSE) = amx_ctof(params[2]); + + return 1; +} + +static cell AMX_NATIVE_CALL cs_get_c4_explode_time(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 amx_ftoc(*((REAL*)pC4->pvPrivateData + OFFSET_C4_EXPLODE_TIME)); +} +static cell AMX_NATIVE_CALL cs_set_c4_explode_time(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; + } + + *((REAL*)pC4->pvPrivateData + OFFSET_C4_EXPLODE_TIME) = amx_ctof(params[2]); + + return 1; +} + +#else + +static cell AMX_NATIVE_CALL not_on_64(AMX* amx, cell* params) +{ + MF_LogError(amx, AMX_ERR_NATIVE, "This function is not implemented on AMD64"); + + return 0; +} +#define cs_get_user_lastactivity not_on_64 +#define cs_set_user_lastactivity not_on_64 +#define cs_get_hostage_lastuse not_on_64 +#define cs_set_hostage_lastuse not_on_64 +#define cs_get_hostage_nextuse not_on_64 +#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 +#endif + AMX_NATIVE_INFO cstrike_Exports[] = { {"cs_set_user_money", cs_set_user_money}, @@ -1568,6 +1740,17 @@ AMX_NATIVE_INFO cstrike_Exports[] = { {"cs_set_armoury_type", cs_set_armoury_type}, {"cs_get_user_zoom", cs_get_user_zoom}, {"cs_set_user_zoom", cs_set_user_zoom}, + {"cs_get_user_submodel", cs_get_user_submodel}, + {"cs_set_user_submodel", cs_set_user_submodel}, + {"cs_get_user_lastactivity", cs_get_user_lastactivity}, + {"cs_set_user_lastactivity", cs_set_user_lastactivity}, + {"cs_get_hostage_lastuse", cs_get_hostage_lastuse}, + {"cs_set_hostage_lastuse", cs_set_hostage_lastuse}, + {"cs_get_hostage_nextuse", cs_get_hostage_nextuse}, + {"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}, + //------------------- <-- max 19 characters! {NULL, NULL} }; diff --git a/dlls/cstrike/cstrike/cstrike.h b/dlls/cstrike/cstrike/cstrike.h index 9a9d4bbf..a1f75397 100755 --- a/dlls/cstrike/cstrike/cstrike.h +++ b/dlls/cstrike/cstrike/cstrike.h @@ -69,6 +69,7 @@ #define OFFSET_TEAM 114 + EXTRAOFFSET #define OFFSET_CSMONEY 115 + EXTRAOFFSET #define OFFSET_PRIMARYWEAPON 116 + EXTRAOFFSET + #define OFFSET_LASTACTIVITY 124 + EXTRAOFFSET #define OFFSET_INTERNALMODEL 126 + EXTRAOFFSET #define OFFSET_NVGOGGLES 129 + EXTRAOFFSET #define OFFSET_DEFUSE_PLANT 193 + EXTRAOFFSET @@ -102,9 +103,13 @@ #define OFFSET_SILENCER_FIREMODE 74 + EXTRAOFFSET_WEAPONS // "hostage_entity" entities #define OFFSET_HOSTAGEFOLLOW 86 + EXTRAOFFSET + #define OFFSET_HOSTAGE_NEXTUSE 100 + EXTRAOFFSET + #define OFFSET_HOSTAGE_LASTUSE 483 + EXTRAOFFSET #define OFFSET_HOSTAGEID 487 + EXTRAOFFSET // "armoury_entity" #define OFFSET_ARMOURY_TYPE 34 + EXTRAOFFSET_WEAPONS + // C4 offsets + #define OFFSET_C4_EXPLODE_TIME 100 + EXTRAOFFSET #else // Amd64 offsets here #define OFFSET_ARMORTYPE 137 + EXTRAOFFSET diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index e1ea1c57..9d671dd1 100755 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -295,3 +295,39 @@ native cs_set_user_zoom(index, type, mode); /* Returns how a user is zooming during the native call. Values correspond to the above enum, but will return 0 if an error occurred. */ native cs_get_user_zoom(index); + +/* Returns the submodel setting of the player. + * If this is 1, then the user has a backpack or defuser on their model (depending on team) + */ +native cs_get_user_submodel(index); + +/* Sets the submodel setting of the player. + * If this is 1, then the user has a backpack or defuser on their model (depending on team) + * 0 removes it. + */ +native cs_set_user_submodel(index, value); + +/* Gets or sets the user's last activity time. This is the time that CS's internal afk kicker + * checks to see who has been afk too long. + */ +native Float:cs_get_user_lastactivity(index); + +native cs_set_user_lastactivity(index, Float:value); + +/* Gets or sets the time that the hostage was last used. + */ +native Float:cs_get_hostage_lastuse(index); + +native cs_set_hostage_lastuse(index, Float:value); + +/* Gets or sets the time which the hostage can next be used. + */ +native Float:cs_get_hostage_nextuse(index); + +native cs_set_hostage_nextuse(index, Float:value); + +/* Gets or sets the time in which the C4 will explode. + */ +native Float:cs_get_c4_explode_time(index); + +native cs_set_c4_explode_time(index, Float:value);