RunUpgradeEffect crashes the server
DeewaTT91 opened this issue · 2 comments
While trying to write a plugin that utilizes runupgradeeffect to temporarily deactivate a players upgrade I came across this error:
L 03/17/2023 - 17:53:07: [SM] Exception reported: Script execution timed out
L 03/17/2023 - 17:53:11: [SM] Blaming: smrpg.smx
L 03/17/2023 - 17:53:11: [SM] Call stack trace:
L 03/17/2023 - 17:53:11: [SM] [0] Call_Finish
L 03/17/2023 - 17:53:11: [SM] [1] Line 656, c:\steamcmd\steamapps\common\Counter-Strike Source Dedicated Server\outputdingens\smrpg\scripting\smrpg\smrpg_upgrades.sp::Native_RunUpgradeEffect
L 03/17/2023 - 17:53:11: [SM] [3] SMRPG_RunUpgradeEffect
L 03/17/2023 - 17:53:11: [SM] [4] Line 138, c:\steamcmd\steamapps\common\Counter-Strike Source Dedicated Server\outputdingens\smrpg\scripting\smrpg_upgrade_handicap.sp::Hook_TraceAttackPost
Edit: Nvm I found a way around it :)
What was the problem?
I was calling RunUpgradeEffect in a while loop:
while(timer != Invalid_Handle)
!RunUpgradeEffect(victim, "regen")
because I thought this would disable the plugin for the duration of the timer, but it actually crashed.
However I solved it by setting a global bool and calling it here:
public Action SMRPG_OnUpgradeEffect(int victim, const char[] shortname, int issuer)
{
// Check for the healing Upgrades
if(StrEqual(shortname, "regen") || StrEqual(shortname, "vamp"))
return g_return[victim];
return Plugin_Continue;
}