Actually fix registering.. Again ;-;

This commit is contained in:
zaCade 2019-03-17 01:20:12 +01:00
parent 7ae1125b10
commit 1e9287a125
2 changed files with 27 additions and 42 deletions

View File

@ -221,9 +221,7 @@ public void OnEntitySpawned(int entity)
if (config.iWeaponID && config.iWeaponID == Entity_GetHammerId(entity)) if (config.iWeaponID && config.iWeaponID == Entity_GetHammerId(entity))
{ {
bool bExisting; bool bExisting = RegisterExistingItem(entity, REGISTERTYPE_WEAPON);
if ((bExisting = RegisterExistingItem(entity, REGISTERTYPE_WEAPON)))
{
if (!bExisting) if (!bExisting)
{ {
CItem item = new CItem(config); CItem item = new CItem(config);
@ -231,15 +229,10 @@ public void OnEntitySpawned(int entity)
if (RegisterItemEntity(item, entity, REGISTERTYPE_WEAPON)) if (RegisterItemEntity(item, entity, REGISTERTYPE_WEAPON))
g_hArray_Items.Push(item); g_hArray_Items.Push(item);
} }
return;
}
} }
else if (config.iButtonID && config.iButtonID == Entity_GetHammerId(entity)) else if (config.iButtonID && config.iButtonID == Entity_GetHammerId(entity))
{ {
bool bExisting; bool bExisting = RegisterExistingItem(entity, REGISTERTYPE_BUTTON);
if ((bExisting = RegisterExistingItem(entity, REGISTERTYPE_BUTTON)))
{
if (!bExisting) if (!bExisting)
{ {
CItem item = new CItem(config); CItem item = new CItem(config);
@ -247,15 +240,10 @@ public void OnEntitySpawned(int entity)
if (RegisterItemEntity(item, entity, REGISTERTYPE_BUTTON)) if (RegisterItemEntity(item, entity, REGISTERTYPE_BUTTON))
g_hArray_Items.Push(item); g_hArray_Items.Push(item);
} }
return;
}
} }
else if (config.iTriggerID && config.iTriggerID == Entity_GetHammerId(entity)) else if (config.iTriggerID && config.iTriggerID == Entity_GetHammerId(entity))
{ {
bool bExisting; bool bExisting = RegisterExistingItem(entity, REGISTERTYPE_TRIGGER);
if ((bExisting = RegisterExistingItem(entity, REGISTERTYPE_TRIGGER)))
{
if (!bExisting) if (!bExisting)
{ {
CItem item = new CItem(config); CItem item = new CItem(config);
@ -263,9 +251,6 @@ public void OnEntitySpawned(int entity)
if (RegisterItemEntity(item, entity, REGISTERTYPE_TRIGGER)) if (RegisterItemEntity(item, entity, REGISTERTYPE_TRIGGER))
g_hArray_Items.Push(item); g_hArray_Items.Push(item);
} }
return;
}
} }
} }
} }
@ -299,7 +284,7 @@ stock bool RegisterItemEntity(CItem item, int entity, int type)
{ {
switch(type) switch(type)
{ {
case(1): case REGISTERTYPE_WEAPON:
{ {
if (!item.bWeapon && (Entity_GetOwner(entity) == INVALID_ENT_REFERENCE)) if (!item.bWeapon && (Entity_GetOwner(entity) == INVALID_ENT_REFERENCE))
{ {
@ -308,7 +293,7 @@ stock bool RegisterItemEntity(CItem item, int entity, int type)
return true; return true;
} }
} }
case(2): case REGISTERTYPE_BUTTON:
{ {
if (!item.bButton && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE || (item.bWeapon && Entity_GetParent(entity) == item.iWeapon))) if (!item.bButton && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE || (item.bWeapon && Entity_GetParent(entity) == item.iWeapon)))
{ {
@ -319,7 +304,7 @@ stock bool RegisterItemEntity(CItem item, int entity, int type)
return true; return true;
} }
} }
case(3): case REGISTERTYPE_TRIGGER:
{ {
if (!item.bTrigger && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE || (item.bWeapon && Entity_GetParent(entity) == item.iWeapon))) if (!item.bTrigger && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE || (item.bWeapon && Entity_GetParent(entity) == item.iWeapon)))
{ {
@ -519,11 +504,11 @@ public Action OnButtonPress(int button, int client)
switch(aResult) switch(aResult)
{ {
case(Plugin_Continue, Plugin_Changed): case Plugin_Continue, Plugin_Changed:
{ {
switch(item.dConfig.iMode) switch(item.dConfig.iMode)
{ {
case(1): case 1:
{ {
if (item.iTimeReady < RoundToCeil(GetEngineTime())) if (item.iTimeReady < RoundToCeil(GetEngineTime()))
{ {
@ -531,7 +516,7 @@ public Action OnButtonPress(int button, int client)
} }
else return Plugin_Handled; else return Plugin_Handled;
} }
case(2): case 2:
{ {
if (item.iTimesUsed < item.dConfig.iMaxUses) if (item.iTimesUsed < item.dConfig.iMaxUses)
{ {
@ -539,7 +524,7 @@ public Action OnButtonPress(int button, int client)
} }
else return Plugin_Handled; else return Plugin_Handled;
} }
case(3): case 3:
{ {
if (item.iTimeReady < RoundToCeil(GetEngineTime()) && item.iTimesUsed < item.dConfig.iMaxUses) if (item.iTimeReady < RoundToCeil(GetEngineTime()) && item.iTimesUsed < item.dConfig.iMaxUses)
{ {
@ -548,7 +533,7 @@ public Action OnButtonPress(int button, int client)
} }
else return Plugin_Handled; else return Plugin_Handled;
} }
case(4): case 4:
{ {
if (item.iTimeReady < RoundToCeil(GetEngineTime())) if (item.iTimeReady < RoundToCeil(GetEngineTime()))
{ {

View File

@ -44,7 +44,7 @@ public void OnGameFrame()
{ {
switch(itemArray[item_mode]) switch(itemArray[item_mode])
{ {
case(1): case 1:
{ {
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime())) if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
{ {
@ -55,7 +55,7 @@ public void OnGameFrame()
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "R", itemArray[item_owner]); Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "R", itemArray[item_owner]);
} }
} }
case(2): case 2:
{ {
if (itemArray[item_uses] < itemArray[item_maxuses]) if (itemArray[item_uses] < itemArray[item_maxuses])
{ {
@ -66,7 +66,7 @@ public void OnGameFrame()
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]); Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]);
} }
} }
case(3): case 3:
{ {
if (itemArray[item_uses] < itemArray[item_maxuses]) if (itemArray[item_uses] < itemArray[item_maxuses])
{ {
@ -84,7 +84,7 @@ public void OnGameFrame()
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]); Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]);
} }
} }
case(4): case 4:
{ {
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime())) if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
{ {