AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run time error 3: stack error (https://forums.alliedmods.net/showthread.php?t=82735)

Flasher 12-29-2008 01:34

Run time error 3: stack error
 
1 Attachment(s)
I has written AntiEGON plugin (http://forums.alliedmods.net/showthread.php?t=82626), it works fine, but sometimes log "Run time error 3: stack error". This error happens rarely (once a day for server with max 8 clients).
Tried many ways to solve this problem with no luck. Here is beta version of plugin, error log and debug log written by plugin.
From log you can see that function CurrentWeaponChanged is entered recursively. Doen't know why this can happen. Subscription on event CurWeapon is marked with "1=10", so it should happen only if weapon is EGON. And in function start I check if weapon is EGON. No reports about wrong weapon happens.
This is normal way it works:
Code:

L 12/29/2008 - 10:19:15: ver: 1.5.2b in:  client_command, 4072
L 12/29/2008 - 10:19:15: ver: 1.5.2b out: client_command, 4052
L 12/29/2008 - 10:19:16: ver: 1.5.2b in:  WeaponPicked, 4072
L 12/29/2008 - 10:19:16: ver: 1.5.2b out: WeaponPicked, 4072
L 12/29/2008 - 10:19:16: ver: 1.5.2b in:  CurrentWeaponChanged, 4072
L 12/29/2008 - 10:19:16: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 3, player id: 5, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:19:16: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:19:16: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:19:16: ver: 1.5.2b 3. player has weapon: 12
L 12/29/2008 - 10:19:16: ver: 1.5.2b out: CurrentWeaponChanged, 3800
L 12/29/2008 - 10:19:22: ver: 1.5.2b in:  client_putinserver, 4072
L 12/29/2008 - 10:19:22: ver: 1.5.2b out: client_putinserver, 4072

Adn this is when it enters CurrentWeaponChanged recursively:
Code:

L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  client_command, 4072
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: client_command, 4052
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  WeaponPicked, 4072
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: WeaponPicked, 4072
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 4072
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 3764
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 3456
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 3148
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 2840
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 2532
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 2224
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 1916
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 1608
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 1300
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 992
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 684
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 376
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. isHaveWeapon: 1, weapon num: 2, player id: 7, prev weapon id: 2, prev weapon name: weapon_9mmhandgun
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 1
L 12/29/2008 - 10:21:22: ver: 1.5.2b 3. player has weapon: 2
L 12/29/2008 - 10:21:22: ver: 1.5.2b in:  CurrentWeaponChanged, 68
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 104
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 412
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 720
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 1028
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 1336
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 1644
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 1952
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 2260
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 2568
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 2876
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 3184
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 3492
L 12/29/2008 - 10:21:22: ver: 1.5.2b out: CurrentWeaponChanged, 3800
L 12/29/2008 - 10:21:23: ver: 1.5.2b in:  client_command, 4072
L 12/29/2008 - 10:21:23: ver: 1.5.2b out: client_command, 4052

Command issued (thru engclient_cmd) in both ways is "weapon_9mmhandgun". So I doesn't know why it sometimes enters CurrentWeaponChanged again.

Hawk552 12-29-2008 01:49

Re: Run time error 3: stack error
 
For starters:

Code:
log_to_file("antiegon.log", "ver: %s Bad weapon received: %i", weapon);

This will give you a parameter error.

I don't know the problem but try removing this for now:

Code:
engclient_cmd(plrid, weapname);

Of course you'll have to add it back eventually, but that's the only thing I can see that could cause any sort of recursion.

Flasher 12-29-2008 01:58

Re: Run time error 3: stack error
 
Quote:

Originally Posted by Hawk552 (Post 734776)
For starters:

Code:
log_to_file("antiegon.log", "ver: %s Bad weapon received: %i", weapon);

This will give you a parameter error.

Thanks. As offten this is an copy paste error :oops:. I hope if function enters this line I any way would have error reporting.
Quote:

Originally Posted by Hawk552 (Post 734776)
I don't know the problem but try removing this for now:

Code:
engclient_cmd(plrid, weapname);

Of course you'll have to add it back eventually, but that's the only thing I can see that could cause any sort of recursion.

This is the main call in function without it this plugin is for nothing.
And sorry I doesn't write - mentioned error happens rarely (once a day for server with max 8 clients). I doesn't know how to reproduce error. If I remove this call error will definetely disappear, because this call lead to recurcive.

Hawk552 12-29-2008 03:00

Re: Run time error 3: stack error
 
You could try running the command "lastinv" and let the engine do all the work for you including checks.

Flasher 12-29-2008 04:10

Re: Run time error 3: stack error
 
Quote:

Originally Posted by Hawk552 (Post 734794)
You could try running the command "lastinv" and let the engine do all the work for you including checks.

I pass this thru. If player issue drop command and player has EGON it is select as most destructive weapon. And "lastinv" do nothing in this case because player dropped weapon.

I can add the check if function is called recursive. But it will be better to solve the source of the problem.

Hawk552 12-29-2008 14:46

Re: Run time error 3: stack error
 
If you're trying to make sure they don't use the EGON, why don't you just gather all their weapons every time they pick one up, then if the EGON is one of them, make them switch to it and drop it. If it's the only one, give them another weapon (like a crowbar) then make them drop it.

Flasher 12-29-2008 15:09

Re: Run time error 3: stack error
 
I tried with drop - looks funny - you are moving to EGON it is picked up then dropped before you. You moving to it, picks it up and again it dropped. :)
And if drop then I have to give atomic ammo (or how they are named) to player to compensate.
Main idea was: if player picks up EGON it should get ammo for gauss gun (the same ammo as for EGON). And the player can't use, select or even see that he has EGON.
This is all done with this simple plugin, but sometimes it behave wrong.

If I would tried to go aonther way it will be this: if user pickup EGON, then strip weapon from player completely (drop and remove), then give ammo that he loose. When EGON is dropped, ammo in weapon box is near half of player has (i.e. not constant). So as you can see this is not easy way. May be some day I will have time to do this. But I think that may be it will be easier to solve problem with current plugin.
Yes, I understand that this will draw you time or anyone that will try to help. But may be this bug is not within plugin, but within AMXX or Metamod and we can find and fix it? I doesn't know. I am not well know AMXX and HL engine to decide.

Thanks for helping!


All times are GMT -4. The time now is 09:14.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.