From 2d327e8d14ca2874a493d077294a6bb0b7f6892f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bergstr=C3=B6m?= Date: Tue, 9 Mar 2004 08:53:06 +0000 Subject: [PATCH] backwards comp. intitial version --- plugins/include/xtrafun.inc | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 plugins/include/xtrafun.inc diff --git a/plugins/include/xtrafun.inc b/plugins/include/xtrafun.inc new file mode 100755 index 00000000..a75dc236 --- /dev/null +++ b/plugins/include/xtrafun.inc @@ -0,0 +1,105 @@ +/* Xtrafun backwards compatibility +* +* by the AMX Mod X Development Team +* These natives were originally made by SpaceDude, EJ, and JustinHoMi. +* +* This file is provided as is (no warranties). +*/ + +#if !defined _xtrafun_included + #define _xtrafun_included + +#if !defined _engine_included + #include +#endif + +/* Gets the velocity of an entity */ +stock get_entity_velocity(index, velocity[3]) { + new Float:vector[3] + entity_get_vector(index, EV_VEC_velocity, vector) + FVecIVec(vector, velocity) +} + +/* Sets the velocity of an entity */ +stock set_entity_velocity(index, velocity[3]) { + new Float:vector[3] + IVecFVec(velocity, vector) + entity_set_vector(index, EV_VEC_velocity, vector) +} + +/* Gets the origin of an entity */ +stock get_entity_origin(index, origin[3]) { + new Float:vector[3] + entity_get_vector(index, EV_VEC_origin, vector) + FVecIVec(vector, origin) +} + +/* Sets the origin of an entity */ +stock set_entity_origin(index, origin[3]) { + new Float:vector[3] + IVecFVec(originvector) + entity_set_vector(index, EV_VEC_origin, vector) +} + +/* Gets the velocity of a player */ +stock get_user_velocity(index, velocity[3]) { + get_entity_velocity(index, velocity) +} + +/* Sets the velocity of a player */ +stock set_user_velocity(index, velocity[3]) { + set_entity_velocity(index, velocity) +} + +/* Get the index of the grenade belonging to index. + * Model of grenade is returned in model[]. + * Specify the grenadeindex to start searching from, + * or leave it at 0 to search from the start. + * Returns grenade index. + * Paths + models of grenades in Counter-Strike: + * HEGRENADE = "models/w_hegrenade.mdl" + * FLASHBANG = "models/w_flashbang.mdl" + * SMOKEGRENADE = "models/w_smokegrenade.mdl" */ +stock get_grenade_index(index, model[], len, grenadeindex = 0) { + new entfind = grenadeindex + new entowner = index + + for (;;) { + entfind = find_entity(entfind, "grenade") + + if (entfind && is_valid_ent(entfind)) { + if (entity_get_edict(entFind, EV_ENT_owner) == entowner) { + entity_get_string(entfind, EV_SZ_model, model) + return entfind + } + } + else { + // Eventually comes here if loop fails to find a grenade with specified owner. + return 0; + } + } +} + +/* Find the number of entities in the game */ +stock current_num_ents() { + return entity_count(); +} + +enum { + classname = 0, + target, + targetname +} + +/* Find an entity ID from start_from_ent id (use 0 to start from + * the beginning, category is either "classname", "target" or + * "targetname", value is the name you are searching for */ +stock find_entity(start_from_ent, category, value[]) { + switch (category) { + case target: return find_entity_by_target(start_from_ent, value) + case targetname: return find_ent_by_tname(start_from_ent, value) + default: return find_entity_by_class(start_from_ent, value) + } +} + +#endif // _xtrafun_included \ No newline at end of file