Можете ли вы сохранить положение игрока, направление камеры, гравитацию, с которой он был сохранен в этом плагине?
Код:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < engine >
#include < fun >
#pragma semicolon 1
const MAX_CLIENTS = 32;
const MAX_STRING_LEN = 10;
const VECTOR_SIZE = 3;
enum _:PlayerBools
{
BOOL_CHECK,
BOOL_FALL,
BOOL_RESPAWN,
BOOL_SOLID,
BOOL_RESTORED
};
new bool:g_bGlobalBools[ MAX_CLIENTS + 1 ][ PlayerBools ];
new Float:g_fCheckpointPos[ MAX_CLIENTS + 1 ][ VECTOR_SIZE ],
Float:g_fLastCheckpointPos[ MAX_CLIENTS + 1 ][ VECTOR_SIZE ],
g_iCheckpointCount[ MAX_CLIENTS + 1 ];
new g_hEnabledCvar,
g_hDelayCvar;
new g_iMaxClients;
public plugin_init( )
{
register_plugin( "KZ Menu", "1.0.2", "Xellath" );
g_iMaxClients = get_maxplayers( );
register_clcmd( "say /kzmenu", "ClientCommand_ShowMenu" );
register_clcmd( "say /checkpoint", "ClientCommand_CreateCheckpoint" );
register_clcmd( "say /cp", "ClientCommand_CreateCheckpoint" );
register_clcmd( "say /gocheck", "ClientCommand_GotoCheckpoint" );
register_clcmd( "say /tp", "ClientCommand_GotoCheckpoint" );
register_clcmd( "say /stuck", "ClientCommand_LastCheckpoint" );
register_clcmd( "say /respawn", "ClientCommand_RespawnPlayer" );
register_clcmd( "say /reset", "ClientCommand_ResetChecks" );
}
public client_disconnect( id )
{
for( new iBool; iBool < PlayerBools; iBool++ )
{
g_bGlobalBools[ id ][ iBool ] = false;
}
g_iCheckpointCount[ id ] = 0;
}
public ClientCommand_ShowMenu( id )
{
new hMenu = menu_create( "CP Menu:", "KZMenuHandler" );
menu_additem( hMenu, "Create CP", "1" );
menu_additem( hMenu, "Go to CP", "2", _, menu_makecallback( "KZMenuCallback" ) );
menu_additem( hMenu, "Revert to previous CP", "3", _, menu_makecallback( "KZMenuCallback" ) );
menu_additem( hMenu, "Reset CP^n", "4", _, menu_makecallback( "KZMenuCallback" ) );
menu_display( id, hMenu, 0 );
}
public KZMenuCallback( id, hMenu, iItem )
{
return g_bGlobalBools[ id ][ BOOL_CHECK ] ? ITEM_ENABLED : ITEM_DISABLED;
}
public KZMenuHandler( id, hMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy( hMenu );
return PLUGIN_HANDLED;
}
new szInfo[ 3 ];
new iAccess, iCallback;
menu_item_getinfo( hMenu, iItem, iAccess, szInfo, 2, _, _, iCallback );
switch( str_to_num( szInfo ) )
{
case 1: ClientCommand_CreateCheckpoint( id );
case 2: ClientCommand_GotoCheckpoint( id );
case 3: ClientCommand_LastCheckpoint( id );
case 4: ClientCommand_ResetChecks( id );
case 5:
{
goto HandlerFinish;
}
}
ClientCommand_ShowMenu( id );
HandlerFinish:
{
menu_destroy( hMenu );
return PLUGIN_HANDLED;
}
}
public ClientCommand_CreateCheckpoint( id )
{
if( is_user_alive( id ) )
{
if( g_bGlobalBools[ id ][ BOOL_CHECK ] )
{
for( new i; i < VECTOR_SIZE; i++ )
{
g_fLastCheckpointPos[ id ][ i ] = g_fCheckpointPos[ id ][ i ];
}
}
entity_get_vector( id, EV_VEC_origin, g_fCheckpointPos[ id ] );
g_bGlobalBools[ id ][ BOOL_CHECK ] = true;
g_iCheckpointCount[ id ]++;
client_print( id, print_chat, "[KZ] Checkpoint %d saved!", g_iCheckpointCount[ id ] );
}
return PLUGIN_HANDLED;
}
public ClientCommand_GotoCheckpoint( id )
{
if( is_user_alive( id ) )
{
if( !g_bGlobalBools[ id ][ BOOL_CHECK ] )
{
client_print( id, print_chat, "[KZ] You don't have a checkpoint." );
return PLUGIN_HANDLED;
}
entity_set_vector( id, EV_VEC_origin, g_fLastCheckpointPos[ id ] );
entity_set_vector( id, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } );
entity_set_int( id, EV_INT_bInDuck, 1 );
entity_set_size( id, Float:{ -16.0, -16.0, -18.0 }, Float:{ 16.0, 16.0, 18.0 } );
entity_set_vector( id, EV_VEC_origin, g_fCheckpointPos[ id ] );
}
return PLUGIN_HANDLED;
}
public ClientCommand_LastCheckpoint( id )
{
if( is_user_alive( id ) )
{
if( !g_bGlobalBools[ id ][ BOOL_CHECK ] )
{
client_print( id, print_chat, "[KZ] You don't have a previous checkpoint." );
return PLUGIN_HANDLED;
}
client_print( id, print_chat, "[KZ] Reverting to last checkpoint." );
for( new i; i < VECTOR_SIZE; i++ )
{
g_fCheckpointPos[ id ][ i ] = g_fLastCheckpointPos[ id ][ i ];
}
entity_set_vector( id, EV_VEC_origin, g_fLastCheckpointPos[ id ] );
entity_set_vector( id, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } );
entity_set_int( id, EV_INT_bInDuck, 1 );
entity_set_size( id, Float:{ -16.0, -16.0, -18.0 }, Float:{ 16.0, 16.0, 18.0 } );
entity_set_vector( id, EV_VEC_origin, g_fCheckpointPos[ id ] );
}
return PLUGIN_HANDLED;
}
public ClientCommand_ResetChecks( id )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
{
return;
}
g_bGlobalBools[ id ][ BOOL_CHECK ] = false;
g_iCheckpointCount[ id ] = 0;
client_print( id, print_chat, "[KZ] Your checkpoints is now resetted!" );
}
public ClientCommand_RespawnPlayer( id )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
{
return;
}
if( is_user_alive( id ) )
{
client_print( id, print_chat, "[KZ] You have to be dead to use respawn." );
return;
}
ExecuteHam( Ham_CS_RoundRespawn, id );
}