Raised This Month: $ Target: $400
 0% 

Remove Weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
driger38
Senior Member
Join Date: Apr 2011
Old 04-13-2013 , 20:27   Remove Weapon
Reply With Quote #1

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?
driger38 is offline
tonykaram1993
Senior Member
Join Date: Mar 2013
Location: This World
Old 04-13-2013 , 21:52   Re: Remove Weapon
Reply With Quote #2

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" );
}*/ 
__________________
My Plugins:
UltimatePlugin
UltimateSurf
UltimateAdmin
Code:
rcon version | rcon amxx version | rcon meta version
rcon amxx plugins | rcon meta list | rcon status
I AM INACTIVE ON THIS FORUM - For direct contact: [email protected]

Last edited by tonykaram1993; 04-13-2013 at 21:53.
tonykaram1993 is offline
Leon M.
Senior Member
Join Date: Apr 2009
Location: Germany
Old 04-14-2013 , 01:09   Re: Remove Weapon
Reply With Quote #3

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")
        }
    }

__________________
  • ZapTic - Paintball (Version 7.1.3 b1303)
  • Your #1 CS Paintball Server since 2008
  • 85.131.163.101:27015

Last edited by Leon M.; 04-14-2013 at 01:09.
Leon M. is offline
tonykaram1993
Senior Member
Join Date: Mar 2013
Location: This World
Old 04-14-2013 , 01:16   Re: Remove Weapon
Reply With Quote #4

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.
__________________
My Plugins:
UltimatePlugin
UltimateSurf
UltimateAdmin
Code:
rcon version | rcon amxx version | rcon meta version
rcon amxx plugins | rcon meta list | rcon status
I AM INACTIVE ON THIS FORUM - For direct contact: [email protected]
tonykaram1993 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-14-2013 , 02:12   Re: Remove Weapon
Reply With Quote #5

Quote:
Originally Posted by tonykaram1993 View Post
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.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-14-2013 , 03:08   Re: Remove Weapon
Reply With Quote #6

Read this : https://forums.alliedmods.net/showth...89#post1932289
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tonykaram1993
Senior Member
Join Date: Mar 2013
Location: This World
Old 04-14-2013 , 03:34   Re: Remove Weapon
Reply With Quote #7

Interesting to read ConnorMcLeod.
__________________
My Plugins:
UltimatePlugin
UltimateSurf
UltimateAdmin
Code:
rcon version | rcon amxx version | rcon meta version
rcon amxx plugins | rcon meta list | rcon status
I AM INACTIVE ON THIS FORUM - For direct contact: [email protected]

Last edited by tonykaram1993; 04-14-2013 at 12:25.
tonykaram1993 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-14-2013 , 08:36   Re: Remove Weapon
Reply With Quote #8

What were your previous account names ?
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-14-2013 at 08:37.
ConnorMcLeod 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 10:54.


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