Actally it's hooking the SVC_TEMPENTITY (wich is 23) message and first param as TE_PLAYERDECAL... wich is 112.
TE_PLAYERDECAL params from include/message_const.inc
Code:
#define TE_PLAYERDECAL 112
// write_byte(TE_PLAYERDECAL)
// write_byte(playerindex)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(entity???)
// write_byte(decal number)
// [optional] write_short(model index)
the #define is the define for using it, the rest with // are informations about message parameters, that are between message_begin(msgtype, SVC_TEMPENTITY) and message_end()...
So... after knowing that I would do the following:
PHP Code:
#include <amxmodx>
#include <engine>
public plugin_init()
{
/* SVC_TEMPENTITY (event #23) event, trigger if parameter 1 is equal to 112 (TE_PLAYERDECAL) */
register_event("23", "player_spray", "a", "1=112")
}
public player_spray()
{
new id = read_data(2) /* as seen in the include, player index is the second parameter */
new iOrigin[3]
iOrigin[0] = read_data(3) /* and of course, the coordinates... */
iOrigin[1] = read_data(4)
iOrigin[2] = read_data(5)
/* you can get the rest of parameters too if you need them */
/* now, what you needed... distance... */
new iPlayerOrigin[3]
get_user_origin(id, iPlayerOrigin)
new iDistance = get_distance(iPlayerOrigin, iOrigin)
client_print(id, print_chat, "Distance to your spray: %d", iDistance)
}
easy :}
Note: not actually tested, but should work.
__________________