/*
*
* KZ Menu by Xellath
* Version 1.0.2
*
* CHANGELOG:
*
* -
*
* v1.0.1b - Re-release, rewritten.
* v1.0.1c - Semiclip fixed, index out of bounds error fixed aswell.
* v1.0.2 - Cleaned up the ugly code, and fixed some small errors + added 2 cvars.
*
* -
*
* CVARS:
*
* -
*
* kzmenu_enabled ( 1 | 0 ) On/Off : - Sets the state of the plugin enable/disabled. Default: 1 (on)
* kzmenu_respawndelay ( integer ) : - Value for the delay of respawning Default: 2 (seconds)
*
* -
*
* NOTE:
*
* -
*
* Previous versions is not supported!
*
* -
*/
#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;
enum _:RGBA
{
R,
G,
B,
A
};
new g_hSemiclipCvar,
g_hSemiclipColorCvar,
g_iColors[ RGBA ];
public plugin_init( )
{
register_plugin( "KZ Menu", "1.0.2", "Xellath" );
g_hEnabledCvar = register_cvar( "kzmenu_enabled", "1" );
g_hDelayCvar = register_cvar( "kzmenu_respawndelay", "2" );
g_hSemiclipCvar = register_cvar( "kzmenu_semiclip", "1" );
g_hSemiclipColorCvar = register_cvar( "kzmenu_semiclip_color", "255 255 255 85" );
CvarToRGB( g_hSemiclipColorCvar );
g_iMaxClients = get_maxplayers( );
RegisterHam( Ham_Killed, "player", "Forward_ClientKilled" );
RegisterHam( Ham_TakeDamage, "player", "Forward_ClientTakeDamage" );
register_forward( FM_AddToFullPack, "Forward_AddToFullPack", 1 );
register_clcmd( "say /kzmenu", "ClientCommand_ShowMenu" );
register_clcmd( "say /weapons", "ClientCommand_AllWeapons" );
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( iClient )
{
for( new iBool; iBool < PlayerBools; iBool++ )
{
g_bGlobalBools[ iClient ][ iBool ] = false;
}
g_iCheckpointCount[ iClient ] = 0;
}
public client_putinserver( iClient )
{
client_disconnect( iClient );
}
public Forward_ClientKilled( iVictim, iAttacker, iShouldGib )
{
if( 1 <= iVictim <= g_iMaxClients )
{
if( g_bGlobalBools[ iVictim ][ BOOL_RESPAWN ] && get_pcvar_num( g_hEnabledCvar ) )
{
set_task( get_pcvar_float( g_hDelayCvar ), "ClientCommand_RespawnPlayer", iVictim );
}
}
}
public Forward_ClientTakeDamage( iVictim, iInflictor, iAttacker, Float:fDamage, iDamagebits )
{
if( g_bGlobalBools[ iVictim ][ BOOL_FALL ] && get_pcvar_num( g_hEnabledCvar ) )
{
if( iDamagebits & DMG_FALL )
{
client_print( iVictim, print_chat, "[KZ] You took %d damage from falling!", floatround( fDamage ) );
}
}
}
public Forward_AddToFullPack( iEntityState, _e, iEnt, iHost, iHostflags, iPlayer, pSet )
{
if( iPlayer )
{
if( g_bGlobalBools[ iHost ][ BOOL_SOLID ] && g_bGlobalBools[ iEnt ][ BOOL_SOLID ] && get_pcvar_num( g_hEnabledCvar ) )
{
set_es( iEntityState, ES_Solid, SOLID_NOT );
if( get_pcvar_num( g_hSemiclipCvar ) )
{
set_es( iEntityState, ES_RenderMode, kRenderTransAlpha );
set_es( iEntityState, ES_RenderAmt, g_iColors[ A ] );
set_es( iEntityState, ES_RenderColor, g_iColors[ R ], g_iColors[ G ], g_iColors[ B ] );
}
}
}
}
public client_PreThink( iClient )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
{
return;
}
static iPlayer, LastThink;
if( LastThink > iClient )
{
for( iPlayer = 1; iPlayer <= g_iMaxClients; iPlayer++ )
{
if( !is_user_alive( iPlayer ) )
{
g_bGlobalBools[ iPlayer ][ BOOL_SOLID ] = false;
continue;
}
g_bGlobalBools[ iPlayer ][ BOOL_SOLID ] = entity_get_int( iPlayer, EV_INT_solid ) == SOLID_SLIDEBOX ? true : false;
}
}
LastThink = iClient;
if( !g_bGlobalBools[ iClient ][ BOOL_SOLID ] )
{
return;
}
for( iPlayer = 1; iPlayer <= g_iMaxClients; iPlayer++ )
{
if ( !g_bGlobalBools[ iPlayer ][ BOOL_SOLID ] || iClient == iPlayer )
{
continue;
}
entity_set_int( iPlayer, EV_INT_solid, SOLID_NOT );
g_bGlobalBools[ iPlayer ][ BOOL_RESTORED ] = true;
}
}
public client_PostThink( iClient )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
{
return;
}
static iPlayer;
for( iPlayer = 1; iPlayer <= g_iMaxClients; iPlayer++ )
{
if( g_bGlobalBools[ iPlayer ][ BOOL_RESTORED ] )
{
entity_set_int( iPlayer, EV_INT_solid, SOLID_SLIDEBOX );
g_bGlobalBools[ iPlayer ][ BOOL_RESTORED ] = false;
}
}
}
public ClientCommand_ShowMenu( iClient )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
return;
new hMenu = menu_create( "[BHOP] Menu", "KZMenuHandler" );
menu_additem( hMenu, "CheckPoint létrehozása", "1" );
menu_additem( hMenu, "Vissza az utolsó checkpointhoz!", "2", _, menu_makecallback( "KZMenuCallback" ) );
menu_additem( hMenu, "CheckPoint helyreállítása!", "3", _, menu_makecallback( "KZMenuCallback" ) );
menu_additem( hMenu, "CheckPointok törlése!", "4", _, menu_makecallback( "KZMenuCallback" ) );
menu_additem( hMenu, "Minden fegyver addolása!", "5" );
menu_additem( hMenu, "Ki-Be", "6" );
menu_display( iClient, hMenu, 0 );
}
public KZMenuCallback( iClient, hMenu, iItem )
{
return g_bGlobalBools[ iClient ][ BOOL_CHECK ] ? ITEM_ENABLED : ITEM_DISABLED;
}
public KZMenuHandler( iClient, 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( iClient );
case 2: ClientCommand_GotoCheckpoint( iClient );
case 3: ClientCommand_LastCheckpoint( iClient );
case 4: ClientCommand_ResetChecks( iClient );
case 5: ClientCommand_AllWeapons( iClient );
case 6:
{
AttributesMenu( iClient );
goto HandlerFinish;
}
}
ClientCommand_ShowMenu( iClient );
HandlerFinish:
{
menu_destroy( hMenu );
return PLUGIN_HANDLED;
}
}
public AttributesMenu( iClient )
{
new hMenu = menu_create( "KZ Menu -> On/Off Attributes Menu:", "AttributesMenuHandler" );
new szOption[ 32 ];
formatex( szOption, 31, "Godmode: %s", ( get_user_godmode( iClient ) ? "\yOn" : "\rOff" ) );
menu_additem( hMenu, szOption, "1" );
formatex( szOption, 31, "Noclip: %s^n", ( get_user_noclip( iClient ) ? "\yOn" : "\rOff" ) );
menu_additem( hMenu, szOption, "2" );
formatex( szOption, 31, "Auto-Respawning: %s", ( g_bGlobalBools[ iClient ][ BOOL_RESPAWN ] ? "\yOn" : "\rOff" ) );
menu_additem( hMenu, szOption, "3" );
formatex( szOption, 31, "Show Fall Damage: %s", ( g_bGlobalBools[ iClient ][ BOOL_FALL ] ? "\yOn" : "\rOff" ) );
menu_additem( hMenu, szOption, "4" );
menu_setprop( hMenu, MPROP_EXITNAME, "Back to main menu - KZ Menu" );
menu_display( iClient, hMenu, 0 );
}
public AttributesMenuHandler( iClient, hMenu, iItem )
{
if( iItem == MENU_EXIT )
{
menu_destroy( hMenu );
ClientCommand_ShowMenu( iClient );
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:
{
switch( get_user_godmode( iClient ) )
{
case 0: set_user_godmode( iClient, 1 );
case 1: set_user_godmode( iClient, 0 );
}
}
case 2:
{
switch( get_user_noclip( iClient ) )
{
case 0: set_user_noclip( iClient, 1 );
case 1: set_user_noclip( iClient, 0 );
}
}
case 3:
{
switch( g_bGlobalBools[ iClient ][ BOOL_RESPAWN ] )
{
case true: g_bGlobalBools[ iClient ][ BOOL_RESPAWN ] = false;
case false: g_bGlobalBools[ iClient ][ BOOL_RESPAWN ] = true;
}
}
case 4:
{
switch( g_bGlobalBools[ iClient ][ BOOL_FALL ] )
{
case true: g_bGlobalBools[ iClient ][ BOOL_FALL ] = false;
case false: g_bGlobalBools[ iClient ][ BOOL_FALL ] = true;
}
}
}
AttributesMenu( iClient );
return PLUGIN_HANDLED;
}
public ClientCommand_AllWeapons( iClient )
{
if( is_user_alive( iClient ) && get_pcvar_num( g_hEnabledCvar ) )
{
new const szWeaponNames[ ][ ] =
{
"weapon_p228",
"weapon_scout",
"weapon_xm1014",
"weapon_mac10",
"weapon_aug",
"weapon_elite",
"weapon_fiveseven",
"weapon_ump45",
"weapon_sg550",
"weapon_galil",
"weapon_famas",
"weapon_usp",
"weapon_glock18",
"weapon_awp",
"weapon_mp5navy",
"weapon_m249",
"weapon_m3",
"weapon_m4a1",
"weapon_tmp",
"weapon_g3sg1",
"weapon_deagle",
"weapon_sg552",
"weapon_ak47",
"weapon_p90"
};
for( new i; i < sizeof( szWeaponNames ); i++ )
{
give_item( iClient, szWeaponNames[ i ] );
}
}
}
public ClientCommand_CreateCheckpoint( iClient )
{
if( is_user_alive( iClient ) && get_pcvar_num( g_hEnabledCvar ) )
{
if( g_bGlobalBools[ iClient ][ BOOL_CHECK ] )
{
for( new i; i < VECTOR_SIZE; i++ )
{
g_fLastCheckpointPos[ iClient ][ i ] = g_fCheckpointPos[ iClient ][ i ];
}
}
entity_get_vector( iClient, EV_VEC_origin, g_fCheckpointPos[ iClient ] );
g_bGlobalBools[ iClient ][ BOOL_CHECK ] = true;
g_iCheckpointCount[ iClient ]++;
client_print( iClient, print_chat, "[KZ] Checkpoint %d elmentve!", g_iCheckpointCount[ iClient ] );
}
return PLUGIN_HANDLED;
}
public ClientCommand_GotoCheckpoint( iClient )
{
if( is_user_alive( iClient ) && get_pcvar_num( g_hEnabledCvar ) )
{
if( !g_bGlobalBools[ iClient ][ BOOL_CHECK ] )
{
client_print( iClient, print_chat, "[KZ] Nincsenek checkpointjaid!" );
return PLUGIN_HANDLED;
}
entity_set_vector( iClient, EV_VEC_origin, g_fLastCheckpointPos[ iClient ] );
entity_set_vector( iClient, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } );
entity_set_int( iClient, EV_INT_bInDuck, 1 );
entity_set_size( iClient, Float:{ -16.0, -16.0, -18.0 }, Float:{ 16.0, 16.0, 18.0 } );
entity_set_vector( iClient, EV_VEC_origin, g_fCheckpointPos[ iClient ] );
}
return PLUGIN_HANDLED;
}
public ClientCommand_LastCheckpoint( iClient )
{
if( is_user_alive( iClient ) && get_pcvar_num( g_hEnabledCvar ) )
{
if( !g_bGlobalBools[ iClient ][ BOOL_CHECK ] )
{
client_print( iClient, print_chat, "[KZ] Nincsenek előző checkpointjaid!" );
return PLUGIN_HANDLED;
}
client_print( iClient, print_chat, "[KZ] Visszaállás az előző checkpointra!" );
for( new i; i < VECTOR_SIZE; i++ )
{
g_fCheckpointPos[ iClient ][ i ] = g_fLastCheckpointPos[ iClient ][ i ];
}
entity_set_vector( iClient, EV_VEC_origin, g_fLastCheckpointPos[ iClient ] );
entity_set_vector( iClient, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } );
entity_set_int( iClient, EV_INT_bInDuck, 1 );
entity_set_size( iClient, Float:{ -16.0, -16.0, -18.0 }, Float:{ 16.0, 16.0, 18.0 } );
entity_set_vector( iClient, EV_VEC_origin, g_fCheckpointPos[ iClient ] );
g_bGlobalBools[ iClient ][ BOOL_CHECK ] = false;
g_iCheckpointCount[ iClient ] = 0;
}
return PLUGIN_HANDLED;
}
public ClientCommand_ResetChecks( iClient )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
{
return;
}
g_bGlobalBools[ iClient ][ BOOL_CHECK ] = false;
g_iCheckpointCount[ iClient ] = 0;
client_print( iClient, print_chat, "[KZ] Checkpointjaid törölve!" );
}
public ClientCommand_RespawnPlayer( iClient )
{
if( !get_pcvar_num( g_hEnabledCvar ) )
{
return;
}
if( is_user_alive( iClient ) )
{
client_print( iClient, print_chat, "[KZ] Meg kell halnod, hogy a respawnt használhasd!" );
return;
}
ExecuteHam( Ham_CS_RoundRespawn, iClient );
}
CvarToRGB( hCvar )
{
new szColor[ MAX_STRING_LEN ], iColor[ RGBA ][ MAX_STRING_LEN ];
get_pcvar_string( hCvar, szColor, MAX_STRING_LEN - 1 );
parse( szColor,\
iColor[ R ], MAX_STRING_LEN - 1,\
iColor[ G ], MAX_STRING_LEN - 1,\
iColor[ B ], MAX_STRING_LEN - 1,\
iColor[ A ], MAX_STRING_LEN - 1
);
for( new i; i < RGBA; i++ )
{
g_iColors[ i ] = str_to_num( iColor[ i ] );
}
}