AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove Weapon (https://forums.alliedmods.net/showthread.php?t=213357)

driger38 04-13-2013 20:27

Remove Weapon
 
PHP Code:

#include <amxmodx> 
#include <fun> 

public plugin_init()  

   
register_event("HLTV""new_round""a""1=0""2=0")   


public 
new_round() 

    static 
id 
    
for (id 1id <= get_maxplayers(); id++) 
    { 
        if(
is_user_connected(id) && is_user_alive(id)) 
        { 
            
strip_user_weapons(id
            
give_item(id"weapon_knife")  
        }     
    } 


It should remove all weapon at round start, but it doesnt do that, whats wrong?

tonykaram1993 04-13-2013 21:52

Re: Remove Weapon
 
Alright, I know exactly what's happening here. I used to use HLTV event to count how many CT and T alive players there is, and I always used to get false results. If a T was killed the round before, he won't be counted. I realised that HLTV is executed almost before all the players have been spawned. Solution? I delayed the event for about 0.2 seconds and everything worked fine. Please try the following code and let me know the result:
PHP Code:

#include < amxmodx >
#include < fun >
// #include < fakemeta >

public plugin_init( ) {
    
register_plugin"Strip Test""1.0""tonykaram1993" );
    
    
register_event"HLTV",     "Event_HLTV""a""1=0""2=0" );
}

public 
Event_HLTV( ) {
    
set_task0.2"Task_DelayedHLTV" );
}

public 
Task_DelayedHLTV( ) {
    static 
iPlayers32 ], iNumiLoopiTempID;
    
get_playersiPlayersiNum"a" );
    
    for( 
iLoop 0iLoop iNumiLoop++ ) {
        
iTempID iPlayersiLoop ];
        
        
/*
            However I do not recommend you to strip players this way,
            since it could bug the player and he will not be able to 
            pickup a primary weapon anymore. If you want you can use
            the commented function below (you need to include fakemeta
            tho)
        */
        
strip_user_weaponsiTempID );
        
give_itemiTempID"weapon_knife" );
    }
}

/*
    To use the function below, you need to include fakemeta above
*/
/*StripPlayerWeapons( iPlayerID ) {
    strip_user_weapons( iPlayerID );
    set_pdata_int( iPlayerID, 116, 0 );
    
    give_item( iPlayerID, "weapon_knife" );
}*/ 


Leon M. 04-14-2013 01:09

Re: Remove Weapon
 
You should use Ham_Spawn
PHP Code:

#include <fun>
#include <fakemeta>
#include <hamsandwich>

public plugin_init(){
    
RegisterHam(Ham_Spawn"player""ham_spawn_player_post"1)
}

public 
ham_spawn_player_post(id){
    if (
is_user_alive(id)){
        
strip_user_weapons(id)
        
set_pdata_int(id1160)
        
give_item(id"weapon_knife")
        switch(
get_user_team(id)){
            case 
1give_item(id"weapon_galil")
            case 
2give_item(id"weapon_famas")
        }
    }



tonykaram1993 04-14-2013 01:16

Re: Remove Weapon
 
Quote:

Originally Posted by driger38
It should remove all weapon at round start

He did not want it at player spawn.
He could have also used RoundStart and not HLTV.

hornet 04-14-2013 02:12

Re: Remove Weapon
 
Quote:

Originally Posted by tonykaram1993 (Post 1932258)
He did not want it at player spawn.
He could have also used RoundStart and not HLTV.

Whilst thats true, its likely to be more preferable on spawn since not all players will be present at round start eg. late joiners.

ConnorMcLeod 04-14-2013 03:08

Re: Remove Weapon
 
Read this : https://forums.alliedmods.net/showth...89#post1932289

tonykaram1993 04-14-2013 03:34

Re: Remove Weapon
 
Interesting to read ConnorMcLeod.

ConnorMcLeod 04-14-2013 08:36

Re: Remove Weapon
 
What were your previous account names ?


All times are GMT -4. The time now is 10:54.

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