Closed bklol closed 1 year ago
Not sure exactly of what you meant, but yea the whole if can be removed because the delete instruction already contains an if + sets the variable to null.
if (g_hTimerPreview[client] != null)
{
delete g_hTimerPreview[client];
g_hTimerPreview[client] = null;
}
to
if (g_hTimerPreview[client] != null)
{
if (g_iPreviewEntity[client] != INVALID_ENT_REFERENCE)
{
int entity = EntRefToEntIndex(g_iPreviewEntity[client]);
if (entity > 0 && IsValidEdict(entity))
{
SDKUnhook(entity, SDKHook_SetTransmit, Hook_SetTransmit_Preview);
AcceptEntityInput(entity, "Kill");
}
}
g_iPreviewEntity[client] = INVALID_ENT_REFERENCE;
delete g_hTimerPreview[client];
g_hTimerPreview[client] = null;
}
https://github.com/nuclearsilo583/zephyrus-store-preview-new-syntax/blob/master/addons/sourcemod/scripting/store_item_playerskins.sp#L580
you just delete timer handle,should also kill entity store in g_iPreviewEntity[client] if its not valid when player change to preview others