AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect +USE key (https://forums.alliedmods.net/showthread.php?t=168593)

enjoi. 10-01-2011 09:36

Detect +USE key
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <engine>
#include <csx>

#define PLUGIN "3RD Person Bomb Planting"
#define VERSION "1.2"
#define AUTHOR "sLiCk"

#define _Is(%1,%2) (%1&1<<%2)
#define _Set(%1,%2) %1|=1<<%2
#define _UnSet(%1,%2) %1&=~(1<<%2)
new _planting_human

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("DeathMsg""Event_DeathMsg""a")
    
register_event("BarTime""Event_BarTime""be""1=0")
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
}

public 
plugin_precache()
{
    
precache_model("models/rpgrocket.mdl")
}

public 
Event_BarTime(id)
{
    if(!
_Is(_plantingid))
        return
    
set_view(idCAMERA_NONE)
    
_UnSet(_plantingid)
}

public 
Event_DeathMsg()
{
    new 
iVictim read_data(2)
    if(!
_Is(_plantingiVictim))
        return
    
set_view(iVictimCAMERA_NONE)
    
_UnSet(_plantingiVictim)
}

public 
Event_CurWeapon(id)
{
    if(!
_Is(_plantingid))
        return
    if(
read_data(2) == CSW_C4)
        return
    
set_view(idCAMERA_NONE)
    
_UnSet(_plantingid)
}
    
public 
bomb_planting(id)
{
    if(!
_Is(_humanid))
        return
    
set_view(idCAMERA_3RDPERSON)
    
_Set(_plantingid)
}

public 
bomb_planted(id)
{
    if(!
_Is(_plantingid))
        return
    
set_view(idCAMERA_NONE)
    
_UnSet(_plantingid)
}  

public 
client_putinserver(id)
{
    if(
is_user_bot(id))
        return
    
_Set(_humanid)
}

public 
client_disconnect(id)
{
    
_UnSet(_humanid)
    
_UnSet(_plantingid)


Thats my code. I wan't it to be so when your defusing the bomb it will go into 3rd person but if you stop defusing it will go back to normal. Thanks

Either post the php for detecting or explain to me because im just learning scripting D:

EDIT: New request for it Doesn't need to be added but would like it but its fine
I've never used this method. The method is to make the player solid. Can anybody help me out and put it in the code for me and then post it in php?
PHP Code:

//Call this wherever you want.
Create_PlayerCameraid )
{
    new 
entid;
    while( (
entid find_ent_by_class(entid"PlayerCamera")) != 0)
        if( 
entity_get_edictentidEV_ENT_owner ) == id )
        {
            
attach_viewidentid );
            return;
        }
        
    
entid create_entity("info_target");
        
    if(
entid)
    {
        
entity_set_string(entid,EV_SZ_classname,"PlayerCamera");
        
entity_set_model(entid,"models/w_usp.mdl");
        
entity_set_intentidEV_INT_solidSOLID_TRIGGER);
        
entity_set_intentidEV_INT_movetypeMOVETYPE_FLY );
        
         
//Set owner
        
entity_set_edictentidEV_ENT_ownerid );
        
//Don't draw
        
entity_set_intentidEV_INT_rendermodekRenderTransTexture);
        
entity_set_floatentidEV_FL_renderamt0.0);
        
//Attach our view to this entity.
        
attach_viewidentid ); 
        
//Think!
        
entity_set_floatentidEV_FL_nextthinkget_gametime() );
    }   
}


//Requires registering a Think method for "PlayerCamera" entity. 
// OR you could save the camera's entity ID in the function above
// and call this in client_PostThink or wherever that gets called alot.
public Think_PlayerCameraentid )
{
    new 
id entity_get_edictentidEV_ENT_owner );
    
    
//Kill our entity if we hit USE key
    
new buttons entity_get_intidEV_INT_button );
    if(
buttons IN_USE)
    {
        
attach_viewidid );
        
remove_entity(entid);
        return;
    }

    new 
Float:origin[3], Float:angle[3], Float:vBack[3];
    
entity_get_vectoridEV_VEC_originorigin );
    
entity_get_vectoridEV_VEC_v_angleangle );

    
angle_vectorangleANGLEVECTOR_FORWARDvBack );

    
origin[2] += 20.0//So we're closer to the eyes.
    
    //Move back to see ourself (150 units)
    
origin[0] += (-vBack[0] * 150.0);
    
origin[1] += (-vBack[1] * 150.0);
    
origin[2] += (-vBack[2] * 150.0);

    
entity_set_originentidorigin );
    
entity_set_vectorentidEV_VEC_anglesangle );   
    
    
//For thinking only
    
entity_set_floatentidEV_FL_nextthinkget_gametime() );


code above. any help either detect +use for defusing or solid. whatever is easier for you.

bibu 10-01-2011 09:58

Re: Detect +USE key
 
You know that you're in the wrong forum and you're an idiot for changing the author name dumbass.

And also, multiple accounts ahoi.

Sylwester 10-01-2011 14:08

Re: Detect +USE key
 
Nice. The only change from version 1.1 to 1.2 was plugin name and author name...
There is no need to hook +use. Defusing can be handled in exactly the same way using bomb_defusing and bomb_defused.


All times are GMT -4. The time now is 19:40.

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