Код за потвърждение: Избери целия код
/* AMX Mod X
* UnStuck Plugin
*
* by the AMX Mod X Development Team
*
* This file is part of AMX Mod X.
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
* Official Release Link and Changelog
* http://www.extreamcs.com/forum/pluginuri-extream/amxx-untuck-t265448.html
*
*/
#include < amxmodx >
#include < fakemeta >
// Defines should be first
#define MAX_CLIENTS 32
#define START_DISTANCE 32
#define MAX_ATTEMPTS 128
#define GetPlayerHullSize(%1) ( ( pev ( %1, pev_flags ) & FL_DUCKING ) ? HULL_HEAD : HULL_HUMAN )
// Globals needed
new
g_MsgSync;
// pCvars begins
new
pCvar_Function,
pCvar_UnstEff,
pCvar_UnstWait,
pCvar_Announce [ 5 ];
new Float:gf_LastCmdTime [ MAX_CLIENTS + 1 ];
enum Coord_e
{
Float:x,
Float:y,
Float:z
};
/************************************************************************************/
// If you use a Zombie Mod and don't want zombies to cheat using untuck command
// Uncomment the Mod you Use
// Default NO Mod
#define USE_DEFAULT
// Zombie Plague 4.3 and 5.0
// #define USE_ZPMOD
// Biohazard [ALL Version]
// #define USE_BIOMOD
// Don't touch
#if defined USE_ZPMOD
#tryinclude < zombieplague >
#endif
#if defined USE_BIOMOD
#tryinclude < biohazard >
#endif
/************************************************************************************/
// Plugins begins
public plugin_init ( )
{
register_plugin ( "AMXX Unstuck", "1.7.2", "AMXX Dev Builder" ); // & CryWolf
// Main plugin
pCvar_Function = register_cvar ( "amx_unstuck", "1" );
pCvar_UnstEff = register_cvar ( "amx_autounstuckeffects", "1" );
pCvar_UnstWait = register_cvar ( "amx_autounstuckwait", "7.0" );
// Message pCvars
pCvar_Announce [ 0 ] = register_cvar ( "amx_unst_announce", "1" );
pCvar_Announce [ 1 ] = register_cvar ( "amx_ann_time", "120" );
pCvar_Announce [ 2 ] = register_cvar ( "amx_ann_type", "1" );
pCvar_Announce [ 3 ] = register_cvar ( "amx_ann_hold", "15.0" );
pCvar_Announce [ 4 ] = register_cvar ( "amx_ann_effects", "0" );
// Chat commands
register_clcmd ( "say /unstuck", "FunC_CheckStuck", -1 );
register_clcmd ( "say /stuck", "FunC_CheckStuck", -1 );
register_clcmd ( "say /unblock", "FunC_CheckStuck", -1 );
if ( get_pcvar_num ( pCvar_Announce [ 0 ] ) )
{
g_MsgSync = CreateHudSyncObj ( );
set_task ( get_pcvar_float ( pCvar_Announce [ 1 ] ), "ShowMessage", 0, _, _, "b", _ );
}
}
public ShowMessage ( )
{
switch ( get_pcvar_num ( pCvar_Announce [ 2 ] ) )
{
case 1:
{
client_print ( 0, print_chat, "[Unstuck] If you are stucked type /unstuck in chat to unstuck" );
}
case 2:
{
set_hudmessage ( 170, 255, 127, 0.02, 0.17, get_pcvar_num ( pCvar_Announce [ 4 ] ), 6.0, get_pcvar_float ( pCvar_Announce [ 3 ] ) );
ShowSyncHudMsg ( 0, g_MsgSync, "If you are stucked type /unstuck in chat to unstuck" );
}
default: return;
}
}
public FunC_CheckStuck ( const iPlayer)
{
if ( !get_pcvar_num ( pCvar_Function ) )
return 1;
new Float:f_MinFrequency = get_pcvar_float ( pCvar_UnstWait );
new Float:f_ElapsedCmdTime = get_gametime ( ) - gf_LastCmdTime [ iPlayer ];
if ( f_ElapsedCmdTime < f_MinFrequency )
{
client_print ( iPlayer, print_chat, "[AMXX] You must wait %.1f seconds before trying to free yourself.", f_MinFrequency - f_ElapsedCmdTime );
return 1;
}
gf_LastCmdTime [ iPlayer ] = get_gametime ( );
new i_Value;
if ( ( i_Value = UnstuckPlayer ( iPlayer, START_DISTANCE, MAX_ATTEMPTS ) ) != 1 )
{
switch ( i_Value )
{
case 0 : {
client_print ( iPlayer, print_chat, "[Unstuck] Couldn't find a free spot to move you too" );
}
case -1 : {
client_print ( iPlayer, print_chat, "[Unstuck] You cannot free yourself as dead player" );
}
}
}
return 1;
}
public UnstuckPlayer ( const id, const i_StartDistance, const i_MaxAttempts )
{
#if defined USE_DEFAULT
if ( is_user_alive ( id ) )
{
#endif
#if defined USE_ZPMOD
if ( is_user_alive ( id ) && !zp_get_user_zombie ( id ) )
{
#endif
#if defined USE_BIOMOD
if ( is_user_alive ( id ) && !is_user_zombie ( id ) )
{
#endif
static Float:vf_OriginalOrigin [ Coord_e ], Float:vf_NewOrigin [ Coord_e ];
static i_Attempts, i_Distance;
pev ( id, pev_origin, vf_OriginalOrigin );
i_Distance = i_StartDistance;
while ( i_Distance < 1000 )
{
i_Attempts = i_MaxAttempts;
while ( i_Attempts-- )
{
vf_NewOrigin [ x ] = random_float ( vf_OriginalOrigin [ x ] - i_Distance, vf_OriginalOrigin [ x ] + i_Distance );
vf_NewOrigin [ y ] = random_float ( vf_OriginalOrigin [ y ] - i_Distance, vf_OriginalOrigin [ y ] + i_Distance );
vf_NewOrigin [ z ] = random_float ( vf_OriginalOrigin [ z ] - i_Distance, vf_OriginalOrigin [ z ] + i_Distance );
engfunc ( EngFunc_TraceHull, vf_NewOrigin, vf_NewOrigin, DONT_IGNORE_MONSTERS, GetPlayerHullSize ( id ), id, 0 );
if ( get_tr2 ( 0, TR_InOpen ) && !get_tr2 ( 0, TR_AllSolid ) && !get_tr2 ( 0, TR_StartSolid ) )
{
engfunc ( EngFunc_SetOrigin, id, vf_NewOrigin );
effects ( id );
client_print ( id, print_chat, "[Unstuck] You have been teleported to a new location." );
return 1;
}
}
i_Distance += i_StartDistance;
}
}
return 0;
}
public effects ( id )
{
if ( get_pcvar_num ( pCvar_UnstEff ) )
{
message_begin ( MSG_ONE_UNRELIABLE, 105, { 0, 0, 0 }, id );
write_short(1<<10); // fade lasts this long duration
write_short(1<<10); // fade lasts this long hold time
write_short(1<<1); // fade type (in / out)
write_byte(20); // fade red
write_byte(255); // fade green
write_byte(255); // fade blue
write_byte(255); // fade alpha
message_end ( );
client_cmd ( id, "spk fvox/blip.wav" );
}
}