Raised This Month: $ Target: $400
 0% 

Detect +USE key


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
enjoi.
Veteran Member
Join Date: Mar 2011
Old 10-01-2011 , 09:36   Detect +USE key
Reply With Quote #1

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.
__________________
Block Maker v6.0 []
Point Slay v3.0 []
Contact [ PM ]

Last edited by enjoi.; 10-01-2011 at 09:44. Reason: add
enjoi. is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 10-01-2011 , 09:58   Re: Detect +USE key
Reply With Quote #2

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.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-01-2011 , 14:08   Re: Detect +USE key
Reply With Quote #3

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.
__________________
Impossible is Nothing
Sylwester 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 19:40.


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