Add or adjust a bunch of safety checks (#433)
This commit is contained in:
@ -214,7 +214,7 @@ static cell AMX_NATIVE_CALL console_print(AMX *amx, cell *params) /* 2 param */
|
||||
{
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
{
|
||||
if (len > 126) // Client console truncates after byte 127. (126 + \n = 127)
|
||||
{
|
||||
@ -247,7 +247,7 @@ static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
{
|
||||
g_langMngr.SetDefLang(i);
|
||||
msg = format_amxstring(amx, params, 3, len);
|
||||
@ -280,7 +280,7 @@ static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
{
|
||||
g_langMngr.SetDefLang(index);
|
||||
|
||||
@ -427,7 +427,7 @@ static cell AMX_NATIVE_CALL show_motd(AMX *amx, cell *params) /* 3 param */
|
||||
{
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
UTIL_ShowMOTD(pPlayer->pEdict, sToShow, ilen, szHead);
|
||||
}
|
||||
} else {
|
||||
@ -444,7 +444,7 @@ static cell AMX_NATIVE_CALL show_motd(AMX *amx, cell *params) /* 3 param */
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
UTIL_ShowMOTD(pPlayer->pEdict, sToShow, ilen, szHead);
|
||||
}
|
||||
|
||||
@ -524,7 +524,7 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
{
|
||||
g_langMngr.SetDefLang(i);
|
||||
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 2, len));
|
||||
@ -551,7 +551,7 @@ static cell AMX_NATIVE_CALL show_hudmessage(AMX *amx, cell *params) /* 2 param *
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (pPlayer->ingame)
|
||||
if (pPlayer->ingame && !pPlayer->IsBot())
|
||||
{
|
||||
if (aut)
|
||||
{
|
||||
@ -787,22 +787,27 @@ static cell AMX_NATIVE_CALL is_user_alive(AMX *amx, cell *params) /* 1 param */
|
||||
|
||||
if (index < 1 || index > gpGlobals->maxClients)
|
||||
{
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (!pPlayer->ingame)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_bmod_tfc)
|
||||
{
|
||||
edict_t *e = pPlayer->pEdict;
|
||||
if (e->v.flags & FL_SPECTATOR ||
|
||||
(!e->v.team || !e->v.playerclass))
|
||||
{
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);
|
||||
return pPlayer->IsAlive() ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_amxx_verstring(AMX *amx, cell *params) /* 2 params */
|
||||
@ -1106,6 +1111,12 @@ static cell AMX_NATIVE_CALL user_has_weapon(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
if (!pPlayer->ingame)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEntity = pPlayer->pEdict;
|
||||
|
||||
if (params[3] == -1)
|
||||
@ -1344,17 +1355,20 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
|
||||
} else {
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||
|
||||
pPlayer->keys = keys;
|
||||
pPlayer->menu = menuid;
|
||||
pPlayer->vgui = false;
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
pPlayer->keys = keys;
|
||||
pPlayer->menu = menuid;
|
||||
pPlayer->vgui = false;
|
||||
|
||||
if (time == -1)
|
||||
pPlayer->menuexpire = INFINITE;
|
||||
else
|
||||
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
|
||||
if (time == -1)
|
||||
pPlayer->menuexpire = INFINITE;
|
||||
else
|
||||
pPlayer->menuexpire = gpGlobals->time + static_cast<float>(time);
|
||||
|
||||
pPlayer->page = 0;
|
||||
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
|
||||
pPlayer->page = 0;
|
||||
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -87,6 +87,7 @@ void Client_TeamInfo(void* mValue)
|
||||
case 1:
|
||||
if (index < 1 || index > gpGlobals->maxClients) break;
|
||||
char* msg = (char*)mValue;
|
||||
if (!msg) break;
|
||||
g_players[index].team = msg;
|
||||
g_teamsIds.registerTeam(msg, -1);
|
||||
g_players[index].teamId = g_teamsIds.findTeamId(msg);
|
||||
|
@ -1434,8 +1434,15 @@ int C_Cmd_Argc(void)
|
||||
// Only here we may find out who is an owner.
|
||||
void C_SetModel(edict_t *e, const char *m)
|
||||
{
|
||||
if (e->v.owner && m[7]=='w' && m[8]=='_' && m[9]=='h')
|
||||
g_grenades.put(e, 1.75, 4, GET_PLAYER_POINTER(e->v.owner));
|
||||
if (!m || strcmp(m, "models/w_hegrenade.mdl") != 0)
|
||||
{
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
if (e->v.owner)
|
||||
{
|
||||
g_grenades.put(e, 1.75f, 4, GET_PLAYER_POINTER(e->v.owner));
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
Reference in New Issue
Block a user