PDA

View Full Version : Run time error 7: "Stack underflow"?


vvhy
19/06/2012, 05:23 AM
I am using a plugin crashdetect and here are one of the errors I am getting:

Note* this is only one of the errors just like this I am getting about different functions on the script

[15:02:18] [debug] Stack index (STK) is 0xAC6240, stack top (STP) is 0xAC6238
[15:02:18] [debug] Run time error 7: "Stack underflow"
[15:02:18] [debug] #0 00000008 in ArmyGates () from Gammode.amx
[15:02:18] [debug] Backtrace (most recent call first):


and here is ArmyGates

public ArmyGates()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(PlayerToPoint(10.0, i, -1530.15380859,482.34051514,8.83757210) && ArmyGate == 0)
{
if(gTeam[i] == TEAM_ARMY)
{
MoveObject(ArmyGate, -1540.15380859,482.34051514,8.83757210, 5);
ArmyGate =1;
SetTimer("ArmyGatesClose",7000,0);
}
}
}
}

Faisal_khan
19/06/2012, 06:02 AM
Explain this line why do you need this:if(PlayerToPoint(10.0, i, -1530.15380859,482.34051514,8.83757210) && ArmyGate == 0)
I mean the ArmyGate == 0 part. Try removing it. If problem still persists, paste your ArmyGate define.
Wish you luck!

HuSs3n
19/06/2012, 07:51 AM
you should add IsPlayerConnected condition in your loop
also replace PlayerToPoint with IsPlayerInRangeOfPoint

vvhy
19/06/2012, 05:17 PM
@Faisal_khan
I don't think player to point is the problem because none of the other errors I am getting have that, the only thing in common they all have is
for(new i=0; i<MAX_PLAYERS; i++)

@HuSs3n I don't think IsPlayerConnected would be the problem because I also tried ******'s foreach and I think it has IsPlayerConnected included with it.

@****** I did not get any errors or warnings upon compilation.

niels44
19/06/2012, 07:25 PM
mate, you forgot a return? try this:
public ArmyGates()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(PlayerToPoint(10.0, i, -1530.15380859,482.34051514,8.83757210) && ArmyGate == 0)
{
if(gTeam[i] == TEAM_ARMY)
{
MoveObject(ArmyGate, -1540.15380859,482.34051514,8.83757210, 5);
ArmyGate =1;
SetTimer("ArmyGatesClose",7000,0);
}
}
}
return 1;
}

i always have to use returns at end of public callback :D

vvhy
19/06/2012, 07:35 PM
I am using it as a timer so it doesn't need a return I don't think, but also the issue I am having is Stack underflow and it has it in several places in my script this was just the shortest of them so I could easily post it on the forums.

Babul
19/06/2012, 08:43 PM
SetTimer("ArmyGatesClose",7000,0);

inside a loop? bad idea, idk if its relevant here, since just 1 player will triger that timer.. but what happens, if there is another player (same team) close? i bet the timer will get set twice, and only 1 returns?

HuSs3n
19/06/2012, 08:47 PM
you have to use this
http://forum.sa-mp.com/showthread.php?t=249897

to get more information from your crashdetect plugin and know in which line exactly the error occours