AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Switching Primary to secondary (https://forums.alliedmods.net/showthread.php?t=127535)

DIREKTOR 05-22-2010 07:34

Switching Primary to secondary
 
Well is it possible to make script that will Switch to user secondary weapon (usp) and then to Knife Like pressing "Q" Rapidly .I wanna add that script insted of fm_strip_user_weapons(id); . Please Help me

Seta00 05-22-2010 09:15

Re: Switching Primary to secondary
 
client_cmd("slot3;slot2");
=P

Edit: Wait, what weapon should be on user's hand at the end of the script?

Bugsy 05-22-2010 10:49

Re: Switching Primary to secondary
 
This will simulate pressing Q but only to toggle between pistol and knife.

Let me know if you need anything changed, here's how it works:
  • Holding pistol, primary, grenade, or C4 (anything other than knife) - Switch to knife
  • Holding knife - Switch to pistol
  • Holding knife but do not have a pistol - Do nothing
  • Holding nothing - Do nothing

PHP Code:

#include <fakemeta>
#include <hamsandwich>

public TogglePistolKnifeiPlayer )
{    
    static const 
m_pActiveItem 373;
    static const 
m_rpgPlayerItems_Slot2 369
    static const 
m_iId 43;

    static 
iActiveItem;
    static 
szWeapon19 ];
    static 
iEntity;
    
    
iActiveItem get_pdata_cbaseiPlayer m_pActiveItem );
    
    if( 
iActiveItem )
    {
        if ( 
ExecuteHamHam_Item_ItemSlot iActiveItem ) == )
        {
            
iEntity get_pdata_cbaseiPlayer m_rpgPlayerItems_Slot2 );
            
            if ( 
iEntity )
            {
                
get_weaponnameget_pdata_intiEntity m_iId ) , szWeapon charsmaxszWeapon ) );
                
engclient_cmdiPlayer szWeapon );
            }
        }
        else
        {
            
engclient_cmdiPlayer "weapon_knife" );    
        }
    }


or
PHP Code:

public TogglePistolKnifeiPlayer )
{    
    static const 
m_pActiveItem 373;
    static 
iActiveItem;

    
iActiveItem get_pdata_cbaseiPlayer m_pActiveItem );
    
    if( 
iActiveItem )
        
client_cmdiPlayer , ( ExecuteHamHam_Item_ItemSlot iActiveItem ) == ) ? "slot2;wait;wait;wait;+attack;wait;-attack" "slot3;wait;wait;wait;+attack;wait;-attack" );



DIREKTOR 05-22-2010 11:11

Re: Switching Primary to secondary
 
I figured it myself but thanks anyway


All times are GMT -4. The time now is 03:52.

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