2004-09-19 17:29:08 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <amxmodx>
|
|
|
|
#include <ns>
|
|
|
|
|
|
|
|
#define START_DISTANCE 32 // The first search distance for finding a free location in the map
|
|
|
|
#define MAX_ATTEMPTS 128 // How many times to search in an area for a free space
|
|
|
|
#define BLOCKED_MASKS MASK_PLAYER_STUNNED | MASK_ENSNARED | MASK_ALIEN_EMBRYO
|
|
|
|
|
|
|
|
new Float:g_lastcmdtime[33]
|
|
|
|
|
2007-08-02 16:37:57 +00:00
|
|
|
new amx_unstuck_frequency;
|
|
|
|
|
|
|
|
public plugin_init()
|
|
|
|
{
|
2004-09-19 17:29:08 +00:00
|
|
|
register_plugin("UnStuck",AMXX_VERSION_STR,"AMXX Dev Team")
|
2007-08-02 16:37:57 +00:00
|
|
|
amx_unstuck_frequency=register_cvar("amx_unstuck_frequency", "4.0")
|
2004-09-19 17:29:08 +00:00
|
|
|
register_clcmd("say_team /stuck", "unStuck")
|
|
|
|
register_clcmd("say /stuck", "unStuck")
|
|
|
|
register_clcmd("say_team /unstuck", "unStuck")
|
|
|
|
register_clcmd("say /unstuck", "unStuck")
|
|
|
|
}
|
|
|
|
|
2007-08-02 16:37:57 +00:00
|
|
|
public unStuck(id)
|
|
|
|
{
|
|
|
|
new Float:minfrequency = get_pcvar_float(amx_unstuck_frequency);
|
2004-09-19 17:29:08 +00:00
|
|
|
new Float:elapsedcmdtime = get_gametime() - g_lastcmdtime[id]
|
2007-08-02 16:37:57 +00:00
|
|
|
if ( elapsedcmdtime < minfrequency )
|
|
|
|
{
|
2004-09-19 18:05:13 +00:00
|
|
|
client_print(id, print_chat, "[AMXX] You must wait %.1f seconds before trying to free yourself", minfrequency - elapsedcmdtime)
|
2004-09-19 17:29:08 +00:00
|
|
|
return PLUGIN_HANDLED
|
|
|
|
}
|
|
|
|
g_lastcmdtime[id] = get_gametime()
|
2007-08-02 16:37:57 +00:00
|
|
|
|
|
|
|
new val;
|
|
|
|
|
|
|
|
// 1=success,0=no valid spot,-1=invalid state,-2=invalid class
|
|
|
|
if ((val=ns_unstick_player(id,START_DISTANCE,MAX_ATTEMPTS))!=1)
|
|
|
|
{
|
|
|
|
switch(val)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "[AMXX] Couldn't find a free spot to move you too.");
|
|
|
|
}
|
|
|
|
case -1:
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "[AMXX] You cannot free yourself while stunned or webbed.");
|
|
|
|
}
|
|
|
|
case -2:
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "[AMXX] You cannot free yourself as a commander or while evolving.");
|
|
|
|
}
|
|
|
|
case -3:
|
|
|
|
{
|
|
|
|
client_print(id, print_chat, "[AMXX] You cannot free yourself as a spectator or from the ready room.");
|
2004-09-19 17:29:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-02 16:37:57 +00:00
|
|
|
return PLUGIN_CONTINUE;
|
|
|
|
}
|