AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Strip User Weapons Last CT (https://forums.alliedmods.net/showthread.php?t=244867)

Monster Truck 07-24-2014 22:37

Strip User Weapons Last CT
 
Hi, i tried to make a little plugin that strips terros weapons (primary, secondary, c4) when only 1 CT remains, but it didn't work.

- The Link to the stock i Used : Strip Primary weapon, secondary, grenades.

- This Code i made :
PHP Code:

#include < amxmodx >
#include < cstrike >
#include < stripweapons >

#define VERSION "1.2"
#define MAX_PLAYERS 32

public plugin_init( )

    
register_plugin"Strip Weapons Last CT"VERSION"Imag!ne" )

    
register_event"DeathMsg""Event_DeathMsg""a" );
}

public 
Event_DeathMsgid )
{
    new 
iPlayersCtMAX_PLAYERS ], iNumCt;
    
get_playersiPlayersCtiNumCt"ae""CT" ) ;
    
    if( 
iNumCt == )
    {
        
StripTerrosWeaponsid );
    }
}

public 
StripTerrosWeaponsid )
{
    if( 
is_user_aliveid ) && cs_get_user_teamid ) == CS_TEAM_T )
    {
        
StripWeaponsidPrimary );
        
StripWeaponsidSecondary );
        
StripWeaponsidC4 );
    }


- And The Notable error i got :
Code:

L 07/24/2014 - 19:02:58: [CSTRIKE] Player out of range (0)
Actually, I think the error is that the condition i made will check for a player that is the last CT and Terrorist together, but i really don't know how to do it otherwise.

If someone has the time to help me, i'll be really gratefull.

YamiKaitou 07-24-2014 22:44

Re: Strip User Weapons Last CT
 
Where is the rest of the code? Where is the complete error message?

hornet 07-24-2014 22:47

Re: Strip User Weapons Last CT
 
First of all, there is no arguments passed through the function header for that message.
And if you have only 1 player found with get_players(), then you can get their index with iPlayersCt[ 0 ], which you would pass to your stripping function.
However I'm not sure why your checking for the last CT but then trying to strip weapons off a T.

Eagle07 07-24-2014 23:05

Re: Strip User Weapons Last CT
 
try with
fm_strip_user_weapons( index );
include fakemeta_util.inc

hornet 07-24-2014 23:29

Re: Strip User Weapons Last CT
 
Quote:

Originally Posted by Eagle07 (Post 2173324)
try with
fm_strip_user_weapons( index );
include fakemeta_util.inc

That is completely unrelated and fakemeta_util should never be used.

Monster Truck 07-25-2014 10:06

Re: Strip User Weapons Last CT
 
Quote:

Originally Posted by YamiKaitou (Post 2173315)
Where is the rest of the code? Where is the complete error message?

This is The Only Error message i got, but it's not in the compilation as u can see it, it's in when it's activated on the server.
This is also the full code, the stock is given in the link on the first post.

Hornet, i want the server to strips all Terros weapons when it still only 1 CT left on the round.
I can't use iPlayersCt[ 0 ] in strips user weapons because it'll strip the weapons to the last CT, and i don't want to do that.

What do you mean by :
Quote:

Originally Posted by hornet (Post 2173319)
First of all, there is no arguments passed through the function header for that message.


HamletEagle 07-25-2014 11:27

Re: Strip User Weapons Last CT
 
DeathMsg doesn't have arguments passed into the header of the function,you get them with read_data.

PHP Code:

#include < amxmodx >
#include < cstrike >
#include < stripweapons >

#define VERSION "1.2"
#define MAX_PLAYERS 32

public plugin_init( )

    
register_plugin"Strip Weapons Last CT"VERSION"Imag!ne" )
    
    
register_event"DeathMsg""Event_DeathMsg""a" );
}

public 
Event_DeathMsg( )
{
    new 
iPlayersCtMAX_PLAYERS ], iNumCt;
    
get_playersiPlayersCtiNumCt"ae""CT" ) ;
    
    if( 
iNumCt == )
    {
        
StripTerrosWeapons( );
    }
}

public 
StripTerrosWeapons(  )
{
    new 
iPlayersCtMAX_PLAYERS ], iNumCt,id;
    
get_playersiPlayersCtiNumCt"ae""TERRORIST" ) ;
    
    for( new 
iiNumCti++ ) 
    {
        
id iPlayersCt ]
        
StripWeaponsidPrimary );
        
StripWeaponsidSecondary );
        
StripWeaponsidC4 );
        
    }



Blizzard_87 07-25-2014 17:54

Re: Strip User Weapons Last CT
 
Quote:

Originally Posted by Eagle07 (Post 2173324)
try with
fm_strip_user_weapons( index );
include fakemeta_util.inc

Please read the OP thread post before you give code which doesn't relate to the problem.

Monster Truck 07-25-2014 19:10

Re: Strip User Weapons Last CT
 
Thanks for the code HamletEagle, i'm testing it when i'll have the time, but i think this is the right way to do it.

Monster Truck 07-26-2014 19:53

Re: Strip User Weapons Last CT
 
It worked, if someone wants to take his code and is not experienced, change

PHP Code:

for( new iiNumCTi++ ); 

:arrow:
PHP Code:

for( new iiNumCti++ ); 

Or u'll get an error "Undefined Symbol" when u'll compile.

Edit: Nvm, got fixed :)


All times are GMT -4. The time now is 13:05.

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