From fb0d7287203a1f24d31a63107c7d09f620188e93 Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sat, 19 Aug 2006 23:02:01 +0000 Subject: [PATCH] optimized a stock and created message_stocks.inc (am29627) --- plugins/include/engine_stocks.inc | 46 +-------------------------- plugins/include/message_stocks.inc | 50 ++++++++++++++++++++++++++++++ plugins/include/messages.inc | 1 + 3 files changed, 52 insertions(+), 45 deletions(-) create mode 100644 plugins/include/message_stocks.inc diff --git a/plugins/include/engine_stocks.inc b/plugins/include/engine_stocks.inc index 22116dfa..c8e13be9 100755 --- a/plugins/include/engine_stocks.inc +++ b/plugins/include/engine_stocks.inc @@ -84,12 +84,7 @@ stock get_entity_flags(ent) /* Get the distance between two entities */ stock get_entity_distance(ent1, ent2) { - new Float:orig1[3], Float:orig2[3] - - entity_get_vector(ent1, EV_VEC_origin, orig1) - entity_get_vector(ent2, EV_VEC_origin, orig2) - - return floatround(get_distance_f(orig1, orig2)) + return floatround(entity_range(ent1, ent2)) } /* Get grenade thrown by this user */ @@ -154,45 +149,6 @@ stock get_speed(ent) return floatround(vector_length(Vel)) } -/* Creates a death message. */ -stock make_deathmsg(killer,victim,headshot,weapon[]) -{ - message_begin(MSG_ALL,get_user_msgid("DeathMsg"),{0,0,0},0) - write_byte( killer ) - write_byte( victim ) - - new mod_name[32] - get_modname(mod_name,31) - if (equal(mod_name,"cstrike") || equal(mod_name,"czero") || equal(mod_name,"csv15") || equal(mod_name,"cs13")) - write_byte( headshot ) - write_string( weapon ) - message_end() - - return 1 -} - -/* Creates a death message. */ -stock dod_make_deathmsg(killer,victim,weaponNUM) -{ - - message_begin(MSG_ALL,get_user_msgid("DeathMsg"),{0,0,0},0) - write_byte( killer ) - write_byte( victim ) - write_byte( weaponNUM) - message_end() - - return 1 -} - -/* Kills a user without a message. */ -stock user_silentkill(index) -{ - set_msg_block(get_user_msgid("DeathMsg"),BLOCK_ONCE) - user_kill(index,1) - - return 1 -} - /* Set rendering of an entity */ stock set_rendering(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16) { diff --git a/plugins/include/message_stocks.inc b/plugins/include/message_stocks.inc new file mode 100644 index 00000000..7edf1c8f --- /dev/null +++ b/plugins/include/message_stocks.inc @@ -0,0 +1,50 @@ +/* Message Stocks +* +* by the AMX Mod X Development Team +* +* This file is provided as is (no warranties). +* +*/ + +#if defined _message_stocks_included + #endinput +#endif +#define _message_stocks_included + +/* Creates a death message. */ +stock dod_make_deathmsg(killer, victim, weaponNUM) +{ + message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0); + write_byte(killer); + write_byte(victim); + write_byte(weaponNUM); + message_end(); + + return 1; +} + +/* Kills a user without a message. */ +stock user_silentkill(index) +{ + set_msg_block(get_user_msgid("DeathMsg"), BLOCK_ONCE); + user_kill(index, 1); + + return 1; +} + +/* Creates a death message. */ +stock make_deathmsg(killer, victim, headshot, weapon[]) +{ + message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0); + write_byte(killer); + write_byte(victim); + + new mod_name[32]; + get_modname(mod_name, 31); + if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13")) + write_byte(headshot); + write_string(weapon); + message_end(); + + return 1; +} diff --git a/plugins/include/messages.inc b/plugins/include/messages.inc index 0999520c..521e066e 100644 --- a/plugins/include/messages.inc +++ b/plugins/include/messages.inc @@ -11,6 +11,7 @@ #define _coremsg_included #include +#include /* These functinos are used to generate client messages. * You may generate menu, smoke, shockwaves, thunderlights,