AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Stack Error (https://forums.alliedmods.net/showthread.php?t=155615)

nikhilgupta345 04-24-2011 11:45

Stack Error
 
Code:

L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX]    [0] lastrequest.sma::Event_DeathMsg (line 210)
L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX]    [0] lastrequest.sma::Event_DeathMsg (line 210)
L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX]    [0] lastrequest.sma::Event_DeathMsg (line 210)
L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX]    [0] colorchat.inc::FindPlayer (line 118)
L 04/24/2011 - 11:35:35: [AMXX]    [1] colorchat.inc::ColorChat (line 59)
L 04/24/2011 - 11:35:35: [AMXX]    [2] lastrequest.sma::Event_DeathMsg (line 214)
L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX]    [0] lastrequest.sma::CheckLastRequest (line 251)
L 04/24/2011 - 11:35:35: [AMXX]    [1] lastrequest.sma::Event_DeathMsg (line 224)
L 04/24/2011 - 11:35:35: [AMXX] Displaying debug trace (plugin "lastrequest.amxx")
L 04/24/2011 - 11:35:35: [AMXX] Run time error 3: stack error
L 04/24/2011 - 11:35:35: [AMXX]    [0] lastrequest.sma::CheckLastRequest (line 262)
L 04/24/2011 - 11:35:35: [AMXX]    [1] lastrequest.sma::Event_DeathMsg (line 224)

PHP Code:

public Event_DeathMsg()
{
    new 
iKiller read_data);
    new 
iVictim read_data);
    
    if( !
is_user_aliveiKiller ) || !is_user_connectediVictim ) )
        return 
PLUGIN_HANDLED;
    
    if( !
is_user_connectedg_iPrisoner ) || !is_user_connectedg_iGuard ) )
        return 
PLUGIN_HANDLED;
    
    if( 
g_bLREnabled )
        return 
PLUGIN_HANDLED;
        
    
    if( 
g_iType == ONEVSONE )
    {
        if( ( 
iVictim == g_iGuard || iVictim == g_iPrisoner ) )
        {
            new 
iReturn;
            
ExecuteForwardg_fwdGameStoppediReturng_iLastRequestChoseniKilleriVictim );
            
            new 
szName[32]; // Line 210
            
get_user_nameg_iPrisonerszName31 );
            
            if( 
iKiller == g_iPrisoner )
                
ColorChat0GREEN"[Jailbreak] ^03%s ^01won the ^03Last Request^01."szName ); // Line 214
            
            
else
                
ColorChat0GREEN"[Jailbreak] ^03%s ^01lost the ^03Last Request^01."szName );
            
            
g_iLastRequestChosen = -1;
            
g_iGuard 0;
            
g_iPrisoner 0;
            
g_iType 0;
            
            
CheckLastRequest(); // Line 224
        
}
    }
    
    return 
PLUGIN_HANDLED;
}

public 
CheckLastRequest()
{
    new 
iPlayers[32], iNum// Line 251
    
get_playersiPlayersiNum"a" );
    
    new 
iCounterTerroristsiTerrorists;
    
    new 
iPlayer;
    
    for( new 
0iNumi++ )
    {
        
iPlayer iPlayers[i];
        
        if( !
is_user_aliveiPlayer ) ) //Line 262
            
continue;
            
        switch( 
cs_get_user_teamiPlayer ) )
        {
            case 
CS_TEAM_CT:
            {
                
iCounterTerrorists++;
            }
            
            case 
CS_TEAM_T:
            {
                
iTerrorists++;
            }
        }
    }
    
    if( 
iTerrorists == && iCounterTerrorists )
    {
        
ColorChat0GREEN"[Jailbreak] ^03Last Request ^01is now ^03enabled^01." );
        
g_bLREnabled true;
    }


Get this error every time somebody dies, and the server crashes.

Any Ideas?

SonicSonedit 04-24-2011 11:53

Re: Stack Error
 
Which are lines 59, 118, 210, 224, 251, 262?

fysiks 04-24-2011 12:05

Re: Stack Error
 
Quote:

Originally Posted by SonicSonedit (Post 1456775)
Which are lines 59, 118, 210, 224, 251, 262?

He lists them as comments in the code. They seem to be inconsistent.

nikhilgupta345 04-24-2011 12:08

Re: Stack Error
 
Those two functions are separated by another function in the actual code, so they skip line numbers.

SonicSonedit 04-24-2011 12:17

Re: Stack Error
 
fysiks
Quote:

He lists them as comments in the code. They seem to be inconsistent.
Sorry, i'm blind idiot.

nikhilgupta345
1) change
PHP Code:

public CheckLastRequest()
{
    new 
iPlayers[32], iNum// Line 251
    
get_playersiPlayersiNum"a" );
    
    new 
iCounterTerroristsiTerrorists;
    
    new 
iPlayer;
    
    for( new 
0iNumi++ )
    {
        
iPlayer iPlayers[i];
        
        if( !
is_user_aliveiPlayer ) ) //Line 262
            
continue;
            
        switch( 
cs_get_user_teamiPlayer ) )
        {
            case 
CS_TEAM_CT:
            {
                
iCounterTerrorists++;
            }
            
            case 
CS_TEAM_T:
            {
                
iTerrorists++;
            }
        }
    }
    
    if( 
iTerrorists == && iCounterTerrorists )
    {
        
ColorChat0GREEN"[Jailbreak] ^03Last Request ^01is now ^03enabled^01." );
        
g_bLREnabled true;
    }


to
PHP Code:

public CheckLastRequest()
{    
    new 
iCounterTerroristsiTerrorists
    g_bLREnabled
=false
    
    
for(new id=1;id<=g_maxplayers;id++)
    {
        
        if (!
is_user_connected(id))
            continue
        
        if (!
is_user_alive(id))
            continue
            
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_CT:
                
iCounterTerrorists++
    
            case 
CS_TEAM_T:
                
iTerrorists++
        }
    }
    
    if(
iTerrorists==1&&iCounterTerrorists)
    {
        
ColorChat0GREEN"[Jailbreak] ^03Last Request ^01is now ^03enabled^01." )
        
g_bLREnabled=true
    
}


get_players aswell as get_user_weapons are rather buggy functions.

fysiks 04-24-2011 12:30

Re: Stack Error
 
get_players() works perfectly fine. The only time that I've seen anything mentioned about it being buggy was using the team flag.

If you notice, the error is does not involve get_players() it is with declaring the variables it uses.

nikhilgupta345 04-24-2011 12:30

Re: Stack Error
 
The stack error in the function CheckLastRequest() is gone, but the one in deathmsg still exists.

Errors indicate the same lines 210 and 214 from the first post.

SonicSonedit 04-24-2011 13:01

Re: Stack Error
 
fysiks
Quote:

get_players() works perfectly fine.
Sometimes it returns incorrect players, sometimes it returns duplicates, i don't know, maybe i really used it incorrectly, but i prefer not to use it. Anyway, it's more about personal opinion. Afterall, nothing will ever be as buggy as fun module.
By the way, can you take a look at http://forums.alliedmods.net/showthread.php?t=155608 ?

nikhilgupta345
Try this:
PHP Code:

public Event_DeathMsg()
{
    static 
iKilleriVictimiReturnname[32]
    
iKiller=read_data(1)
    
iVictim=read_data(2)
    
    if (!
is_user_connected(iVictim)||!is_user_connected(g_iGuard)||!is_user_connected(g_iPrisoner))
        return 
PLUGIN_HANDLED

    
if (!is_user_alive(iKiller)||g_bLREnabled||g_iType!=ONEVSONE)
        return 
PLUGIN_HANDLED

    
if ((iVictim!=g_iGuard&&Victim!=g_iPrisoner))
        return 
PLUGIN_HANDLED

    ExecuteForward
(g_fwdGameStoppediReturng_iLastRequestChoseniKilleriVictim)
    
get_user_name(g_iPrisonernamecharsmax(name))
            
    if (
iKiller==g_iPrisoner)
        
ColorChat(0GREEN"[Jailbreak] ^03%s ^01won the ^03Last Request^01."name// Line 214
    
else
        
ColorChat(0GREEN"[Jailbreak] ^03%s ^01lost the ^03Last Request^01."name)
            
    
g_iLastRequestChosen = -1;
    
g_iGuard 0;
    
g_iPrisoner 0;
    
g_iType 0;
            
    
CheckLastRequest()
    
    return 
PLUGIN_HANDLED;



fysiks 04-24-2011 13:14

Re: Stack Error
 
Quote:

Originally Posted by SonicSonedit (Post 1456834)
Anyway, it's more about personal opinion.

It's computer code. It's not personal opinion if it works correctly or not. I've never heard of it not working other than when trying to filter teams.

SonicSonedit 04-24-2011 13:16

Re: Stack Error
 
Quote:

It's computer code. It's not personal opinion if it works correctly or not. I've never heard of it not working other than when trying to filter teams.
Well, now you did :D
And about my thread, any thoughts?


All times are GMT -4. The time now is 20:00.

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