Added param availability check + 2 more params in the forward

This commit is contained in:
OciXCrom 2018-01-02 14:52:49 +01:00
parent b4170b451c
commit a3f5769058
3 changed files with 12 additions and 6 deletions

View File

@ -2861,12 +2861,14 @@ static cell AMX_NATIVE_CALL set_user_flags(AMX *amx, cell *params) /* 4 param */
if (id > 31) if (id > 31)
id = 31; id = 31;
if(params[4]) int oldflags = pPlayer->flags[id];
if((*params / sizeof(cell) >= 4) && params[4])
pPlayer->flags[id] = flag; pPlayer->flags[id] = flag;
else else
pPlayer->flags[id] |= flag; pPlayer->flags[id] |= flag;
executeForwards(FF_ClientFlagsUpdated, static_cast<cell>(pPlayer->index), pPlayer->flags[id]); executeForwards(FF_ClientFlagsUpdated, static_cast<cell>(pPlayer->index), oldflags, pPlayer->flags[id], id);
return 1; return 1;
} }
@ -2891,8 +2893,10 @@ static cell AMX_NATIVE_CALL remove_user_flags(AMX *amx, cell *params) /* 3 param
if (id > 31) if (id > 31)
id = 31; id = 31;
int oldflags = pPlayer->flags[id];
pPlayer->flags[id] &= ~flag; pPlayer->flags[id] &= ~flag;
executeForwards(FF_ClientFlagsUpdated, static_cast<cell>(pPlayer->index), pPlayer->flags[id]); executeForwards(FF_ClientFlagsUpdated, static_cast<cell>(pPlayer->index), oldflags, pPlayer->flags[id], id);
return 1; return 1;
} }

View File

@ -517,7 +517,7 @@ int C_Spawn(edict_t *pent)
FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_STRING, FP_DONE); FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_STRING, FP_DONE);
FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE); FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE);
FF_ClientConnectEx = registerForward("client_connectex", ET_STOP, FP_CELL, FP_STRING, FP_STRING, FP_ARRAY, FP_DONE); FF_ClientConnectEx = registerForward("client_connectex", ET_STOP, FP_CELL, FP_STRING, FP_STRING, FP_ARRAY, FP_DONE);
FF_ClientFlagsUpdated = registerForward("client_flags_updated", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE); FF_ClientFlagsUpdated = registerForward("client_flags_updated", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
CoreCfg.OnAmxxInitialized(); CoreCfg.OnAmxxInitialized();

View File

@ -163,11 +163,13 @@ forward client_connectex(id, const name[], const ip[], reason[128]);
* Called after the client's admin flags are changed. * Called after the client's admin flags are changed.
* *
* @param id Client index * @param id Client index
* @param flags New client flags * @param oldflags Old client flags
* @param newflags New client flags
* @param set Flag set id
* *
* @noreturn * @noreturn
*/ */
forward client_flags_updated(id, flags); forward client_flags_updated(id, oldflags, newflags, set);
/** /**
* Called when the client gets a valid SteamID. * Called when the client gets a valid SteamID.