Raised This Month: $ Target: $400
 0% 

Solved Making an entity levitate and player follow it


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-17-2018 , 15:01   Making an entity levitate and player follow it
Reply With Quote #1

Hi,

What needs to be done so an entity can levitate in the sky and move towards a destination and all the players to be in that entity and move along with it? Basically the entity is an airplane.

Just as new round starts the entity should be spawned and all the players put in it and to follow it.
Here's a demonstration picture: https://ibb.co/e6RVUJ

Here's the code I made but it just spawns the Airplane but it doesn't move, and I don't get attached to the airplane, so I just fall down.

PHP Code:
#include < amxmodx >
#include < hamsandwich >
#include < fakemeta >
#include < engine >

#define AIRPLANE_CLASSNAME "ent_airplane"

new bool:g_bPlayerInPlane33 ];

new 
g_iAirPlaneEnt;

public 
plugin_init( )
{
    
register_logevent"OnNewRound"2"1=Round_Start" );

    
RegisterHamHam_Think"info_target""@HamThinkInfoTarget_Pre");
    
RegisterHamHam_Player_Jump"player""@HamPlayerJump_Post");
    
RegisterHamHam_Player_PreThink"player""@HamThinkPlayer_Pre");
}

public @
HamPlayerJump_Postid )
{
    if( ! 
g_bPlayerInPlaneid ] )
    return 
HAM_IGNORED;

    
set_pevidpev_movetypeMOVETYPE_TOSS );
    
set_pevidpev_gravity10.0 );

    
g_bPlayerInPlaneid ] = false;
        
    return 
HAM_IGNORED;
}


public 
OnNewRound( )
{
    
MakeAirPlane( );
}

public @
HamThinkInfoTarget_PreiEnt )
{
    if( ! 
pev_validiEnt ) )
    return 
HAM_IGNORED;
    
    new 
szClassName32 ];
    
peviEntpev_classnameszClassNamecharsmaxszClassName ) );

    static 
Float:fVelocity]; 
    
peviEntpev_velocityfVelocity );
    
    if( 
equalszClassNameAIRPLANE_CLASSNAME ) )
    {
        
set_peviEntpev_nextthinkget_gametime( ) + 0.01 );
        
        
velocity_by_aimiEnt1fVelocity );
    }
    
    return 
HAM_IGNORED;
}

public @
HamThinkPlayer_Preid )
{
    if( ! 
is_user_aliveid ) )
    return 
HAM_IGNORED;
        
    if( 
g_bPlayerInPlaneid ] )
    {
        new 
Float:fAirPlaneLocation];
        
pevg_iAirPlaneEntpev_originfAirPlaneLocation );
        
        
set_pevidpev_originfAirPlaneLocation );
    }
    
    return 
HAM_IGNORED;
}

MakeAirPlane( )
{  
    new 
Float:fOrigin] = { 3753.0, -23.03316.0 };
    new 
Float:fAngle] = { -20.3, -175.90.0 };
    
    
g_iAirPlaneEnt create_entity"info_target" );
    
    
set_pevg_iAirPlaneEntpev_classnameAIRPLANE_CLASSNAME );
    
engfuncEngFunc_SetModelg_iAirPlaneEnt"models/AirPlane.mdl" );
    
set_pevg_iAirPlaneEntpev_solidSOLID_BBOX );
    
set_pevg_iAirPlaneEntpev_movetypeMOVETYPE_NOCLIP );
    
set_pevg_iAirPlaneEntpev_originfOrigin );
    
    
engfuncEngFunc_DropToFloorg_iAirPlaneEnt );
    
    
set_pevg_iAirPlaneEntpev_nextthinkget_gametime( ) + 0.01 );
    
    new 
szPlayers32 ], iNumiTempID;
    
get_playersszPlayersiNum"a" );
    
    for( new 
iiNumi++ )
    {
        
iTempID szPlayers];
        
        
set_peviTempIDpev_solidSOLID_NOT );
        
set_peviTempIDpev_originfOrigin );
        
set_peviTempIDpev_anglesfAngle );
    }

Thanks for any help!

Last edited by edon1337; 07-18-2018 at 19:19.
edon1337 is offline
 



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


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