Raised This Month: $ Target: $400
 0% 

how to grab a model


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Zpoke
Senior Member
Join Date: Aug 2009
Location: Sweden
Old 07-28-2010 , 06:30   how to grab a model
Reply With Quote #1

.: Description :.

can someone try to explain how to add a grab command so i can grab and move around the model.. ?


PHP Code:
#include <amxmodx>
#include <fun>
#include <fakemeta>
#define PLUGIN  "MarioMod"
#define AUTHOR  "zpoke"
#define VERSION "1.0"
#define ENT_CLASSNAME "zpoke_item"
#define TIMER_THINKTIME 0.025
new const g_mdl[] = "models/teleporter.mdl";
new 
Float:fOrigin];
new 
toucher_name32 ];
new 
g_item
new g_forward
public plugin_init()
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
register_clcmd"say /item""mainmenu" );
    
g_forward register_forwardFM_Touch"hook_Touch" );
    
register_forwardFM_Think"hook_Think");
}
public 
plugin_precache()
    
precache_modelg_mdl );
public 
mainmenuid )
{
    new 
menu menu_create"\rItem menu:""menu_handler" );
    
    
menu_additemmenu"\wCreate item""1" );
    
    
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
menu_displayidmenu);
}
public 
menu_handleridmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], iName64 ];
    new 
accesscallback;
    
    
menu_item_getinfomenuitemaccessdata5iName63callback );
    
    new 
key str_to_numdata );
    
    switch( 
key )
    {
        case 
1:
        {
            
create_itemid )   
        }   
    }
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}
create_itemid )
{
    new 
Float:mins[3], Float:maxs[3];
    
    
mins Float:{ -15.0, -15.0, -36.0 };
    
maxs Float:{ 15.015.036.0 };
    
    
pevidpev_originfOrigin );
    
    
g_item engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );
    
    
engfuncEngFunc_SetModelg_itemg_mdl ) ;
    
engfuncEngFunc_SetSizeg_itemminsmaxs );
    
engfuncEngFunc_SetOriging_itemfOrigin );
    
set_pevg_itempev_solidSOLID_TRIGGER );
    
set_pevg_itempev_movetypeMOVETYPE_NONE );
    
set_pevg_itempev_classname"zpoke_item" );
    
engfuncEngFunc_DropToFloorg_item );
    
    
set_pevg_itempev_nextthinkget_gametime() + TIMER_THINKTIME) ;
    
    
fOrigin] -= 100;
    
set_pevidpev_originfOrigin )
}   
stock set_rendering2(indexfxrgbrenderamount)
{
    
set_pevindexpev_renderfxfx );
    new 
Float:RenderColor[3];
    
    
RenderColor[0] = float);
    
RenderColor[1] = float);
    
RenderColor[2] = float);
    
    
set_pevindexpev_rendercolorRenderColor );
    
set_pevindexpev_rendermoderender );
    
set_pevindexpev_renderamtfloatamount ) );
}
public 
hook_Thinkent )
{
    if( 
ent == g_item )
    {
        
//Making entity rotate
        
new Float:angles[3];
        
peventpev_anglesangles );
        
        
angles[0] += 5.0
        angles
[1] += 5.0
        angles
[2] += 5.0
        
        set_pev
entpev_anglesangles );
        
        
set_rendering2entkRenderFxGlowShellrandom255 ), random255 ), random255 ), kRenderTransAlpha50 );
        
        
set_peventpev_nextthinkget_gametime() + TIMER_THINKTIME );
    }
    return 
FMRES_HANDLED;
}
public 
hook_Touchentid )
{
    if( !
is_user_aliveid ) )
        return 
FMRES_IGNORED;
    
    
//Get classname of the entity touched
    
new classname[32];
    
peventpev_classnameclassname31);
    
    
//Get name of the toucher
    
get_user_nameidtoucher_name31 );
    
    if( 
equalclassnameENT_CLASSNAME ) )
    {
        
action_touchedentid )
        
unregister_forwardFM_Touchg_forward );
    }
    
    return 
FMRES_HANDLED;
}

action_touchedentid )
{   
    
print_color0"%s touched the model."toucher_name );
    
client_cmdid"speak ^"fvox/boop^"");
    
    
remove_itement )
    
//give exp here
}
remove_itement )
{
    if ( 
pev_valident ) ) 
    {
        new 
classname32 ];
        
peventpev_classnameclassname31 );
        
        if( 
equalclassname"zpoke_item" ) )
            
engfunc(EngFunc_RemoveEntityent );
    }
}
print_colorindex, const sFormat[], any:...)
{
    new 
players[32], count 1
    
    
if ( index players[0] = index; else get_playersplayerscount"ch" )
    
    for ( new 
0counti++ )
    {
        new 
message[256];
        new 
len formatexmessage255"^x01[MarioMod]:^x04 " )
        
vformatmessage[len], 255 lensFormat)
        
message[192] = '^0'
        
        
message_beginindex MSG_ONE MSG_ALLget_user_msgid("SayText"), _index )
        
write_byteplayers[0] )
        
write_stringmessage )
        
message_end()
    }
    return 
1


Last edited by Zpoke; 07-28-2010 at 06:34.
Zpoke is offline
 


Thread Tools
Display Modes

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 00:12.


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