added fix for binlog bug with failed plugins
added experimental emsg natives fixed target's velbyaim bug find added native for setting player curweapon
This commit is contained in:
parent
d3af14c957
commit
9dcdba439a
@ -3932,6 +3932,11 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL is_user_hacking(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
return g_bmod_cstrike ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
memset(get_amxaddr(amx, params[1]), params[2], params[3] * sizeof(cell));
|
memset(get_amxaddr(amx, params[1]), params[2], params[3] * sizeof(cell));
|
||||||
@ -3939,6 +3944,27 @@ static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL amxx_setpl_curweap(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_NATIVE, "Invalid client %d", params[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPlayer *p = GET_PLAYER_POINTER_I(params[1]);
|
||||||
|
|
||||||
|
if (!p->ingame)
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_NATIVE, "Player %d not ingame", params[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->current = params[2];
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO amxmodx_Natives[] =
|
AMX_NATIVE_INFO amxmodx_Natives[] =
|
||||||
{
|
{
|
||||||
{"abort", amx_abort},
|
{"abort", amx_abort},
|
||||||
@ -4043,6 +4069,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
|
|||||||
{"is_user_bot", is_user_bot},
|
{"is_user_bot", is_user_bot},
|
||||||
{"is_user_connected", is_user_connected},
|
{"is_user_connected", is_user_connected},
|
||||||
{"is_user_connecting", is_user_connecting},
|
{"is_user_connecting", is_user_connecting},
|
||||||
|
{"is_user_hacking", is_user_hacking},
|
||||||
{"is_user_hltv", is_user_hltv},
|
{"is_user_hltv", is_user_hltv},
|
||||||
{"lang_exists", lang_exists},
|
{"lang_exists", lang_exists},
|
||||||
{"log_amx", log_amx},
|
{"log_amx", log_amx},
|
||||||
|
@ -338,4 +338,6 @@ struct func_s
|
|||||||
const char *desc;
|
const char *desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern enginefuncs_t *g_pEngTable;
|
||||||
|
|
||||||
#endif // AMXMODX_H
|
#endif // AMXMODX_H
|
||||||
|
@ -227,32 +227,43 @@ void BinLog::WritePluginDB(FILE *fp)
|
|||||||
if (c && pl->isDebug())
|
if (c && pl->isDebug())
|
||||||
c = 2;
|
c = 2;
|
||||||
fwrite(&c, sizeof(char), 1, fp);
|
fwrite(&c, sizeof(char), 1, fp);
|
||||||
len = (char)strlen(pl->getName());
|
if (c)
|
||||||
fwrite(&len, sizeof(char), 1, fp);
|
|
||||||
len++;
|
|
||||||
fwrite(pl->getName(), sizeof(char), len, fp);
|
|
||||||
int natives, publics;
|
|
||||||
AMX *amx = pl->getAMX();
|
|
||||||
amx_NumNatives(amx, &natives);
|
|
||||||
amx_NumPublics(amx, &publics);
|
|
||||||
fwrite(&natives, sizeof(int), 1, fp);
|
|
||||||
fwrite(&publics, sizeof(int), 1, fp);
|
|
||||||
char name[34];
|
|
||||||
for (int i=0; i<natives; i++)
|
|
||||||
{
|
{
|
||||||
amx_GetNative(amx, i, name);
|
len = (char)strlen(pl->getName());
|
||||||
len = (char)strlen(name);
|
|
||||||
fwrite(&len, sizeof(char), 1, fp);
|
fwrite(&len, sizeof(char), 1, fp);
|
||||||
len++;
|
len++;
|
||||||
fwrite(name, sizeof(char), len, fp);
|
fwrite(pl->getName(), sizeof(char), len, fp);
|
||||||
}
|
int natives, publics;
|
||||||
for (int i=0; i<publics; i++)
|
AMX *amx = pl->getAMX();
|
||||||
{
|
amx_NumNatives(amx, &natives);
|
||||||
amx_GetPublic(amx, i, name);
|
amx_NumPublics(amx, &publics);
|
||||||
len = (char)strlen(name);
|
fwrite(&natives, sizeof(int), 1, fp);
|
||||||
|
fwrite(&publics, sizeof(int), 1, fp);
|
||||||
|
char name[34];
|
||||||
|
for (int i=0; i<natives; i++)
|
||||||
|
{
|
||||||
|
amx_GetNative(amx, i, name);
|
||||||
|
len = (char)strlen(name);
|
||||||
|
fwrite(&len, sizeof(char), 1, fp);
|
||||||
|
len++;
|
||||||
|
fwrite(name, sizeof(char), len, fp);
|
||||||
|
}
|
||||||
|
for (int i=0; i<publics; i++)
|
||||||
|
{
|
||||||
|
amx_GetPublic(amx, i, name);
|
||||||
|
len = (char)strlen(name);
|
||||||
|
fwrite(&len, sizeof(char), 1, fp);
|
||||||
|
len++;
|
||||||
|
fwrite(name, sizeof(char), len, fp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char empty[] = " ";
|
||||||
|
len = 1;
|
||||||
fwrite(&len, sizeof(char), 1, fp);
|
fwrite(&len, sizeof(char), 1, fp);
|
||||||
len++;
|
fwrite(empty, sizeof(char), len, fp);
|
||||||
fwrite(name, sizeof(char), len, fp);
|
int no = 0;
|
||||||
|
fwrite(&no, sizeof(int), 1, fp);
|
||||||
|
fwrite(&no, sizeof(int), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ float *msgOrigin;
|
|||||||
edict_t *msgpEntity;
|
edict_t *msgpEntity;
|
||||||
bool inhook = false;
|
bool inhook = false;
|
||||||
bool inblock = false;
|
bool inblock = false;
|
||||||
|
enginefuncs_t *g_pEngTable = NULL;
|
||||||
|
|
||||||
void ClearMessages()
|
void ClearMessages()
|
||||||
{
|
{
|
||||||
@ -651,6 +652,114 @@ static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL emessage_begin(AMX *amx, cell *params) /* 4 param */
|
||||||
|
{
|
||||||
|
int numparam = *params / sizeof(cell);
|
||||||
|
float vecOrigin[3];
|
||||||
|
cell *cpOrigin;
|
||||||
|
|
||||||
|
if (params[2] < 1 || ((params[2] > 63) // maximal number of engine messages
|
||||||
|
&& !GET_USER_MSG_NAME(PLID, params[2], NULL)))
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_NATIVE, "Plugin called message_begin with an invalid message id (%d).", params[2]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (params[1])
|
||||||
|
{
|
||||||
|
case MSG_BROADCAST:
|
||||||
|
case MSG_ALL:
|
||||||
|
case MSG_SPEC:
|
||||||
|
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, NULL);
|
||||||
|
break;
|
||||||
|
case MSG_PVS: case MSG_PAS:
|
||||||
|
case MSG_PVS_R: case MSG_PAS_R:
|
||||||
|
if (numparam < 3)
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpOrigin = get_amxaddr(amx, params[3]);
|
||||||
|
|
||||||
|
vecOrigin[0] = static_cast<float>(*cpOrigin);
|
||||||
|
vecOrigin[1] = static_cast<float>(*(cpOrigin + 1));
|
||||||
|
vecOrigin[2] = static_cast<float>(*(cpOrigin + 2));
|
||||||
|
|
||||||
|
g_pEngTable->pfnMessageBegin(params[1], params[2], vecOrigin, NULL);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case MSG_ONE_UNRELIABLE:
|
||||||
|
case MSG_ONE:
|
||||||
|
if (numparam < 4)
|
||||||
|
{
|
||||||
|
LogError(amx, AMX_ERR_NATIVE, "Invalid number of parameters passed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, INDEXENT(params[4]));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL emessage_end(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnMessageEnd();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_byte(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteByte(params[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_char(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteChar(params[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_short(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteShort(params[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_long(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteLong(params[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_entity(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteEntity(params[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_angle(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteAngle(static_cast<float>(params[1]));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_coord(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
g_pEngTable->pfnWriteCoord(static_cast<float>(params[1]));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL ewrite_string(AMX *amx, cell *params) /* 1 param */
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
g_pEngTable->pfnWriteString(get_amxstring(amx, params[1], 3, a));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO msg_Natives[] =
|
AMX_NATIVE_INFO msg_Natives[] =
|
||||||
{
|
{
|
||||||
{"message_begin", message_begin},
|
{"message_begin", message_begin},
|
||||||
@ -680,5 +789,17 @@ AMX_NATIVE_INFO msg_Natives[] =
|
|||||||
{"set_msg_arg_string", set_msg_arg_string},
|
{"set_msg_arg_string", set_msg_arg_string},
|
||||||
{"get_msg_origin", get_msg_origin},
|
{"get_msg_origin", get_msg_origin},
|
||||||
|
|
||||||
|
{"emessage_begin", emessage_begin},
|
||||||
|
{"emessage_end", emessage_end},
|
||||||
|
|
||||||
|
{"ewrite_angle", ewrite_angle},
|
||||||
|
{"ewrite_byte", ewrite_byte},
|
||||||
|
{"ewrite_char", ewrite_char},
|
||||||
|
{"ewrite_coord", ewrite_coord},
|
||||||
|
{"ewrite_entity", ewrite_entity},
|
||||||
|
{"ewrite_long", ewrite_long},
|
||||||
|
{"ewrite_short", ewrite_short},
|
||||||
|
{"ewrite_string", ewrite_string},
|
||||||
|
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -1351,6 +1351,8 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||||||
// This will also call modules Meta_Query and Meta_Attach functions
|
// This will also call modules Meta_Query and Meta_Attach functions
|
||||||
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), now);
|
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), now);
|
||||||
|
|
||||||
|
GET_HOOK_TABLES(PLID, &g_pEngTable, NULL, NULL);
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
|
|||||||
int iVelocity = params[2];
|
int iVelocity = params[2];
|
||||||
cell *vRet = get_amxaddr(amx, params[3]);
|
cell *vRet = get_amxaddr(amx, params[3]);
|
||||||
Vector vVector = Vector(0, 0, 0);
|
Vector vVector = Vector(0, 0, 0);
|
||||||
|
edict_t *pEnt = NULL;
|
||||||
|
|
||||||
if (iEnt < 0 || iEnt > gpGlobals->maxEntities)
|
if (iEnt < 0 || iEnt > gpGlobals->maxEntities)
|
||||||
{
|
{
|
||||||
@ -75,24 +76,24 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iEnt <= gpGlobals->maxClients && !GET_PLAYER_POINTER_I(iEnt)->ingame)
|
if (iEnt > 0 && iEnt <= gpGlobals->maxClients)
|
||||||
{
|
{
|
||||||
LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", iEnt);
|
if (!GET_PLAYER_POINTER_I(iEnt)->ingame)
|
||||||
return 0;
|
{
|
||||||
}
|
LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not ingame)", iEnt);
|
||||||
else if (iEnt != 0 && FNullEnt(INDEXENT(iEnt)))
|
return 0;
|
||||||
{
|
}
|
||||||
LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", iEnt);
|
pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict;
|
||||||
return 0;
|
} else {
|
||||||
|
pEnt = INDEXENT(iEnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edict_t *pEnt;
|
if (!pEnt)
|
||||||
|
{
|
||||||
if (iEnt >= 1 || iEnt <= gpGlobals->maxClients)
|
LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d (nullent)", iEnt);
|
||||||
pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict;
|
return 0;
|
||||||
else
|
}
|
||||||
pEnt = INDEXENT(iEnt);
|
|
||||||
|
|
||||||
MAKE_VECTORS(pEnt->v.v_angle);
|
MAKE_VECTORS(pEnt->v.v_angle);
|
||||||
vVector = gpGlobals->v_forward * iVelocity;
|
vVector = gpGlobals->v_forward * iVelocity;
|
||||||
|
Loading…
Reference in New Issue
Block a user