2004-06-24 07:36:43 +00:00
|
|
|
#include "engine.h"
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
Message Msg;
|
2004-08-30 22:24:43 +00:00
|
|
|
CVector<int> msgHooks[256];
|
2004-06-24 07:36:43 +00:00
|
|
|
int msgBlocks[256] = {0};
|
2004-05-26 05:15:40 +00:00
|
|
|
int msgDest;
|
|
|
|
int msgType;
|
|
|
|
float *msgOrigin;
|
|
|
|
edict_t *msgpEntity;
|
|
|
|
bool inhook = false;
|
|
|
|
bool inblock = false;
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
Message::Message()
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
msgparam *p = new msgparam;
|
|
|
|
m_Params.push_back(p);
|
|
|
|
m_CurParam = 0;
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
Message::~Message()
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
for (size_t i=0; i<m_Params.size(); i++)
|
|
|
|
delete m_Params[i];
|
|
|
|
|
|
|
|
m_Params.clear();
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
msgparam *Message::AdvPtr()
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
msgparam *pParam = NULL;
|
|
|
|
|
|
|
|
if (++m_CurParam >= m_Params.size())
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
pParam = new msgparam;
|
|
|
|
m_Params.push_back(pParam);
|
|
|
|
} else {
|
|
|
|
pParam = m_Params[m_CurParam];
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
2005-07-22 09:26:37 +00:00
|
|
|
|
|
|
|
return pParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::AddParam(const char *data, msgtype type)
|
|
|
|
{
|
|
|
|
msgparam *pParam = AdvPtr();
|
|
|
|
|
|
|
|
pParam->szData.assign(data);
|
|
|
|
pParam->type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::AddParam(int data, msgtype type)
|
|
|
|
{
|
|
|
|
msgparam *pParam = AdvPtr();
|
|
|
|
|
|
|
|
pParam->v.iData = data;
|
|
|
|
pParam->type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::AddParam(float data, msgtype type)
|
|
|
|
{
|
|
|
|
msgparam *pParam = AdvPtr();
|
|
|
|
|
|
|
|
pParam->v.fData = data;
|
|
|
|
pParam->type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
msgtype Message::GetParamType(size_t index)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return static_cast<msgtype>(0);
|
|
|
|
|
|
|
|
return m_Params[index]->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
float Message::GetParamFloat(size_t index)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return m_Params[index]->v.fData;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Message::GetParamString(size_t index)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return m_Params[index]->szData.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Message::GetParamInt(size_t index)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return m_Params[index]->v.iData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::SetParam(size_t index, float data)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Params[index]->v.fData = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::SetParam(size_t index, int data)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Params[index]->v.iData = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::SetParam(size_t index, const char *data)
|
|
|
|
{
|
|
|
|
if (index < 1 || index > m_CurParam)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_Params[index]->szData.assign(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::Reset()
|
|
|
|
{
|
|
|
|
m_CurParam = 0;
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t Message::Params()
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
return m_CurParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Message::Send()
|
|
|
|
{
|
|
|
|
msgparam *pParam = NULL;
|
|
|
|
|
|
|
|
for (size_t i=1; i<=m_CurParam; i++)
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
pParam = m_Params[i];
|
|
|
|
switch (pParam->type)
|
|
|
|
{
|
|
|
|
case arg_byte:
|
|
|
|
WRITE_BYTE(pParam->v.iData);
|
|
|
|
break;
|
|
|
|
case arg_char:
|
|
|
|
WRITE_CHAR(pParam->v.iData);
|
|
|
|
break;
|
|
|
|
case arg_short:
|
|
|
|
WRITE_SHORT(pParam->v.iData);
|
|
|
|
break;
|
|
|
|
case arg_long:
|
|
|
|
WRITE_LONG(pParam->v.iData);
|
|
|
|
break;
|
|
|
|
case arg_angle:
|
|
|
|
WRITE_ANGLE(pParam->v.fData);
|
|
|
|
break;
|
|
|
|
case arg_coord:
|
|
|
|
WRITE_COORD(pParam->v.fData);
|
|
|
|
break;
|
|
|
|
case arg_string:
|
|
|
|
WRITE_STRING(pParam->szData.c_str());
|
|
|
|
break;
|
|
|
|
case arg_entity:
|
|
|
|
WRITE_ENTITY(pParam->v.iData);
|
|
|
|
break;
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
|
|
|
|
{
|
|
|
|
if (msgBlocks[msg_type]) {
|
|
|
|
inblock = true;
|
2004-09-23 21:00:43 +00:00
|
|
|
msgType = msg_type;
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-08-30 22:24:43 +00:00
|
|
|
} else if (msgHooks[msg_type].size()) {
|
2004-05-26 05:15:40 +00:00
|
|
|
inhook = true;
|
|
|
|
msgDest = msg_dest;
|
|
|
|
msgType = msg_type;
|
|
|
|
msgOrigin = (float *)pOrigin;
|
|
|
|
msgpEntity = ed;
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteByte(int iValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(iValue, arg_byte);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteChar(int iValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(iValue, arg_char);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteShort(int iValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(iValue, arg_short);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteLong(int iValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(iValue, arg_long);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteAngle(float flValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(flValue, arg_angle);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteCoord(float flValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(flValue, arg_coord);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteString(const char *sz)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(sz, arg_string);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteEntity(int iValue)
|
|
|
|
{
|
|
|
|
if (inblock) {
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.AddParam(iValue, arg_entity);
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageEnd(void)
|
|
|
|
{
|
2004-08-30 22:24:43 +00:00
|
|
|
int mres = 0, mresB = 0;
|
2004-05-26 05:15:40 +00:00
|
|
|
unsigned int i = 0;
|
|
|
|
if (inblock) {
|
2004-06-26 22:46:54 +00:00
|
|
|
inblock = false;
|
2004-05-26 05:15:40 +00:00
|
|
|
if (msgBlocks[msgType] == BLOCK_ONCE)
|
|
|
|
msgBlocks[msgType] = BLOCK_NOT;
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
} else if (inhook) {
|
2004-08-30 22:24:43 +00:00
|
|
|
for (i=0; i<msgHooks[msgType].size(); i++)
|
|
|
|
{
|
|
|
|
mresB = MF_ExecuteForward(msgHooks[msgType].at(i), msgType, msgDest, ENTINDEX(msgpEntity));
|
|
|
|
if (mresB > mres)
|
|
|
|
mres = mresB;
|
|
|
|
}
|
2004-06-24 07:36:43 +00:00
|
|
|
inhook = false;
|
2004-05-26 05:15:40 +00:00
|
|
|
if (mres & 1)
|
2004-06-29 16:53:49 +00:00
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.Reset();
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-06-29 16:53:49 +00:00
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
MESSAGE_BEGIN(msgDest, msgType, msgOrigin, msgpEntity);
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.Send();
|
2004-05-26 05:15:40 +00:00
|
|
|
MESSAGE_END();
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.Reset();
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL register_message(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int len;
|
2005-07-19 16:14:52 +00:00
|
|
|
char *name = MF_GetAmxString(amx, params[2], 0, &len);
|
2004-05-26 05:15:40 +00:00
|
|
|
if (params[1]>0 && params[1] < 256) {
|
2005-07-19 16:14:52 +00:00
|
|
|
int id = MF_RegisterSPForwardByName(amx, name, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
2004-08-29 17:55:11 +00:00
|
|
|
if (id != -1)
|
|
|
|
{
|
2004-08-30 22:24:43 +00:00
|
|
|
msgHooks[params[1]].push_back(id);
|
2004-08-29 17:55:11 +00:00
|
|
|
return id;
|
|
|
|
} else {
|
2005-07-19 16:14:52 +00:00
|
|
|
MF_LogError(amx, AMX_ERR_NOTFOUND, "Could not find function \"%s\"", name);
|
2004-08-29 17:55:11 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_msg_block(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int msgid = params[1];
|
|
|
|
int block = params[2];
|
|
|
|
|
|
|
|
if (msgid < 1 || msgid > 255) {
|
|
|
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
msgBlocks[msgid] = block;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_block(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
int msgid = params[1];
|
|
|
|
|
|
|
|
if (msgid < 1 || msgid > 255) {
|
|
|
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return msgBlocks[msgid];
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_args(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
return Msg.Params();
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_argtype(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
return Msg.GetParamType(argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_arg_int(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
return Msg.GetParamInt(argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_msg_arg_int(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.SetParam(argn, params[2]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_arg_float(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
return amx_ftoc(Msg.GetParamFloat(argn));
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_msg_arg_float(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
REAL fVal = amx_ctof(params[2]);
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.SetParam(argn, fVal);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_arg_string(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
const char *szVal = Msg.GetParamString(argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
return MF_SetAmxString(amx, params[2], szVal, params[3]);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL set_msg_arg_string(AMX *amx, cell *params)
|
|
|
|
{
|
2005-07-22 09:26:37 +00:00
|
|
|
size_t argn = static_cast<size_t>(params[1]);
|
2004-05-26 05:15:40 +00:00
|
|
|
int iLen;
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
if (!inhook || argn > Msg.Params())
|
|
|
|
{
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn);
|
2004-05-26 05:15:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *szVal = MF_GetAmxString(amx, params[2], 0, &iLen);
|
|
|
|
|
2005-07-22 09:26:37 +00:00
|
|
|
Msg.SetParam(argn, szVal);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
|
|
|
|
{
|
|
|
|
if (!inhook) {
|
|
|
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-10-25 23:08:06 +00:00
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
|
|
|
|
2004-10-24 01:11:41 +00:00
|
|
|
if (msgDest >= MSG_PVS && msgDest <= MSG_PAS_R)
|
|
|
|
{
|
2004-10-25 23:08:06 +00:00
|
|
|
vec3_t vRet = (Vector)msgOrigin;
|
2004-10-24 01:11:41 +00:00
|
|
|
cAddr[0] = amx_ftoc(vRet.x);
|
|
|
|
cAddr[1] = amx_ftoc(vRet.y);
|
|
|
|
cAddr[2] = amx_ftoc(vRet.z);
|
|
|
|
} else {
|
|
|
|
cAddr[0] = 0;
|
|
|
|
cAddr[1] = 0;
|
|
|
|
cAddr[2] = 0;
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AMX_NATIVE_INFO msg_Natives[] = {
|
|
|
|
{"register_message", register_message},
|
|
|
|
|
|
|
|
{"set_msg_block", set_msg_block},
|
|
|
|
{"get_msg_block", get_msg_block},
|
|
|
|
|
|
|
|
{"get_msg_args", get_msg_args},
|
|
|
|
{"get_msg_argtype", get_msg_argtype},
|
|
|
|
{"get_msg_arg_int", get_msg_arg_int},
|
|
|
|
{"set_msg_arg_int", set_msg_arg_int},
|
|
|
|
{"get_msg_arg_float", get_msg_arg_float},
|
|
|
|
{"set_msg_arg_float", set_msg_arg_float},
|
|
|
|
{"get_msg_arg_string", get_msg_arg_string},
|
|
|
|
{"set_msg_arg_string", set_msg_arg_string},
|
|
|
|
{"get_msg_origin", get_msg_origin},
|
|
|
|
|
|
|
|
{NULL, NULL},
|
2004-05-26 06:19:50 +00:00
|
|
|
};
|