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_bPlayerInPlane[ 33 ];
new g_iAirPlaneEnt;
public plugin_init( )
{
register_logevent( "OnNewRound", 2, "1=Round_Start" );
RegisterHam( Ham_Think, "info_target", "@HamThinkInfoTarget_Pre", 0 );
RegisterHam( Ham_Player_Jump, "player", "@HamPlayerJump_Post", 1 );
RegisterHam( Ham_Player_PreThink, "player", "@HamThinkPlayer_Pre", 0 );
}
public @HamPlayerJump_Post( id )
{
if( ! g_bPlayerInPlane[ id ] )
return HAM_IGNORED;
set_pev( id, pev_movetype, MOVETYPE_TOSS );
set_pev( id, pev_gravity, 10.0 );
g_bPlayerInPlane[ id ] = false;
return HAM_IGNORED;
}
public OnNewRound( )
{
MakeAirPlane( );
}
public @HamThinkInfoTarget_Pre( iEnt )
{
if( ! pev_valid( iEnt ) )
return HAM_IGNORED;
new szClassName[ 32 ];
pev( iEnt, pev_classname, szClassName, charsmax( szClassName ) );
static Float:fVelocity[ 3 ];
pev( iEnt, pev_velocity, fVelocity );
if( equal( szClassName, AIRPLANE_CLASSNAME ) )
{
set_pev( iEnt, pev_nextthink, get_gametime( ) + 0.01 );
velocity_by_aim( iEnt, 1, fVelocity );
}
return HAM_IGNORED;
}
public @HamThinkPlayer_Pre( id )
{
if( ! is_user_alive( id ) )
return HAM_IGNORED;
if( g_bPlayerInPlane[ id ] )
{
new Float:fAirPlaneLocation[ 3 ];
pev( g_iAirPlaneEnt, pev_origin, fAirPlaneLocation );
set_pev( id, pev_origin, fAirPlaneLocation );
}
return HAM_IGNORED;
}
MakeAirPlane( )
{
new Float:fOrigin[ 3 ] = { 3753.0, -23.0, 3316.0 };
new Float:fAngle[ 3 ] = { -20.3, -175.9, 0.0 };
g_iAirPlaneEnt = create_entity( "info_target" );
set_pev( g_iAirPlaneEnt, pev_classname, AIRPLANE_CLASSNAME );
engfunc( EngFunc_SetModel, g_iAirPlaneEnt, "models/AirPlane.mdl" );
set_pev( g_iAirPlaneEnt, pev_solid, SOLID_BBOX );
set_pev( g_iAirPlaneEnt, pev_movetype, MOVETYPE_NOCLIP );
set_pev( g_iAirPlaneEnt, pev_origin, fOrigin );
engfunc( EngFunc_DropToFloor, g_iAirPlaneEnt );
set_pev( g_iAirPlaneEnt, pev_nextthink, get_gametime( ) + 0.01 );
new szPlayers[ 32 ], iNum, iTempID;
get_players( szPlayers, iNum, "a" );
for( new i; i < iNum; i++ )
{
iTempID = szPlayers[ i ];
set_pev( iTempID, pev_solid, SOLID_NOT );
set_pev( iTempID, pev_origin, fOrigin );
set_pev( iTempID, pev_angles, fAngle );
}
}
Thanks for any help!