Raised This Month: $ Target: $400
 0% 

Strip Weapons Stack error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
n0br41ner
Senior Member
Join Date: May 2012
Location: Planet Earth
Old 12-04-2012 , 12:48   Strip Weapons Stack error
Reply With Quote #1

Code:
L 12/04/2012 - 19:39:23: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20121204.log")
L 12/04/2012 - 19:39:23: [AMXX] Displaying debug trace (plugin "test.amxx")
L 12/04/2012 - 19:39:23: [AMXX] Run time error 3: stack error
I figured out what piece of code is triggering this but i cannot see how it can cause it, since in other places i use it the same way and nothing like this happens.

PHP Code:
register_event"TextMsg",         "Event_RestartRound",     "a",     "1=4""2=#Game_will_restart_in" );

public 
Event_RestartRound( ) {
    
// ...

    
StripPlayerWeaponsg_iPlayersg_iChosenPlayer ] ); 
    
// This line is causing the error - when i comment it, the error does not happen
    // Do not worry, g_iPlayers[ g_iChosenPlayer ] is indeed a valid player
    
    // ...
}

public 
StripPlayerWeaponsiPlayerID ) {
    
strip_user_weaponsiPlayerID );
    
set_pdata_intiPlayerID116);
    
    
give_itemiPlayerID"weapon_knife" );

__________________

Last edited by n0br41ner; 12-05-2012 at 16:15.
n0br41ner is offline
xDrugz
Senior Member
Join Date: Jul 2011
Location: return 4;
Old 12-04-2012 , 16:28   Re: Strip Weapons Stack error
Reply With Quote #2

what actually you trying to do ?
__________________
xDrugz is offline
n0br41ner
Senior Member
Join Date: May 2012
Location: Planet Earth
Old 12-05-2012 , 01:19   Re: Strip Weapons Stack error
Reply With Quote #3

What i am trying to do is when the round restarts (sv_restart 1 or sv_restartround 1), to reset everything on the players (strip weapons, unglow them, health 100, armor 100, ...).

All the other things are working except this one.
__________________
n0br41ner is offline
xDrugz
Senior Member
Join Date: Jul 2011
Location: return 4;
Old 12-05-2012 , 02:10   Re: Strip Weapons Stack error
Reply With Quote #4

Quote:
Originally Posted by n0br41ner View Post
What i am trying to do is when the round restarts (sv_restart 1 or sv_restartround 1), to reset everything on the players (strip weapons, unglow them, health 100, armor 100, ...).

All the other things are working except this one.
Code:
#include < amxmodx >
#include < fun >

public plugin_init() 
{
    register_event( "TextMsg", "Event_RestartRound", "a", "2=#Game_will_restart_in" );
}

public Event_RestartRound()
{
    new players[ 32 ], pnum, player;
    get_players( players, pnum );
    
    for( new i = 0; i < pnum; i++ )
    {
        player = players[ i ];
        
        if( !is_user_alive( player ) || !is_user_connected( player ) )
            continue;
        
        set_task( 0.1, "StripWeapons", player );
    }
    
    return PLUGIN_CONTINUE;
}

public StripWeapons( id )
{
    strip_user_weapons( id );
    give_item( id, "weapon_knife" );
}
__________________
xDrugz is offline
n0br41ner
Senior Member
Join Date: May 2012
Location: Planet Earth
Old 12-05-2012 , 03:55   Re: Strip Weapons Stack error
Reply With Quote #5

1. I do not want to strip all players, i know how to do it.
2. Why are you checking if player is alive or connected, just use "a" flag with get_players( )
3. strip_user_weapons( ) sometime glitches the player and he cannot pick up a primary weapon anymore, thats why i am using the StripPlayerWeapons( ) from Connor
4. Why the set_task? Can't you simply use it directly (do you have to wait for 0.1 seconds?)
5. I want to issue the commands on 2 specific players:
PHP Code:
public ForceEndLastRequestiPrisoneriGuard ) {
    
set_user_healthiPrisoner100 );
    
set_user_healthiGuard100 );
    
    
cs_set_user_armoriPrisoner0CS_ARMOR_NONE );
    
cs_set_user_armoriGuard0CS_ARMOR_NONE );
    
    
// I commented the following two lines because this is were i get the error
    // StripPlayerWeapons( iPrisoner );
    // StripPlayerWeapons( iGuard );
    
    
g_iChosenLR LR_NONE;
    
g_bLRStarted false;
    
    
g_iLastRequestPLAYER_OFFICER ] = 0;
    
g_iLastRequestPLAYER_PRISONER ] = 0;

    
client_print0print_chat"%s Last Request has been cancelled due to a restart round."g_strPrefix );

__________________
n0br41ner is offline
n0br41ner
Senior Member
Join Date: May 2012
Location: Planet Earth
Old 12-05-2012 , 04:16   Re: Strip Weapons Stack error
Reply With Quote #6

I was able to fix the error. First i tried only using strip_user_weapons( ) and it did crash.
Therefore i talked to my freind NumB and he wrote a function to strip the weapons of a player, and i used that and it worked.

Props to NumB xD
__________________
n0br41ner is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 12-05-2012 , 06:48   Re: Strip Weapons Stack error
Reply With Quote #7

Quote:
Originally Posted by n0br41ner View Post
I was able to fix the error. First i tried only using strip_user_weapons( ) and it did crash.
Therefore i talked to my freind NumB and he wrote a function to strip the weapons of a player, and i used that and it worked.

Props to NumB xD
Well, you could post the function here, someone will need help about this, and solution isn't provided in thread ;)
OvidiuS is offline
Send a message via Skype™ to OvidiuS
n0br41ner
Senior Member
Join Date: May 2012
Location: Planet Earth
Old 12-05-2012 , 07:52   Re: Strip Weapons Stack error
Reply With Quote #8

PHP Code:
// Function by MPNumB - credits to him

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
 
#define MAX_ITEM_TYPES 6
#define m_rgpPlayerItems 367
#define m_pActiveItem 373
 
#define m_pNext 42
#define m_iId 43

public plugin_init( ){
    
register_clcmd"say test""remove_player_weapons" );
}
 
public 
remove_player_weapons(iPlrId)
{
        new 
iEntiWpnTypeiWeapons;
        
iWeapons pev(iPlrIdpev_weapons);
       
        if( ~
iWeapons&(1<<CSW_KNIFE) )
                
give_item(iPlrId"weapon_knife");
       
        for( new 
iSlotiSlot<MAX_ITEM_TYPESiSlot++ )
        {
                
iEnt get_pdata_cbase(iPlrId, (m_rgpPlayerItems+iSlot), 5);
               
                while( 
iEnt>)
                {
                        
iWpnType get_pdata_int(iEntm_iId4);
                       
                        if( 
iWpnType==CSW_C4 )
                                
engclient_cmd(iPlrId"drop""weapon_c4");
                        else if( 
iWpnType!=CSW_KNIFE )
                        {
                                if( 
ExecuteHamB(Ham_RemovePlayerItemiPlrIdiEnt) )
                                        
ExecuteHamB(Ham_Item_KilliEnt);
                               
                                
iWeapons &= ~(1<<iWpnType);
                        }
                        
//else // may have curweapon message glitches
                        //{
                        //      if( get_pdata_cbase(iPlrId, m_pActiveItem, 5)!=iEnt )
                        //              engclient_cmd(iPlrId, "weapon_knife");
                        //}
                       
                        
iEnt get_pdata_cbase(iEntm_pNext4);
                }
        }
       
        
iEnt get_pdata_cbase(iPlrIdm_pActiveItem5);
        if( 
iEnt>)
        {
                if( 
get_pdata_int(iEntm_iId4)!=CSW_KNIFE )
                        
engclient_cmd(iPlrId"weapon_knife");
        }
        else
                
engclient_cmd(iPlrId"weapon_knife");
       
        
set_pev(iPlrIdpev_weaponsiWeapons);

__________________
n0br41ner is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:37.


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