changed repo to lgsm-cs-funmaps

This commit is contained in:
zino
2023-11-20 16:30:06 +01:00
parent c1e5704385
commit 7639da7306
790 changed files with 0 additions and 14 deletions

View File

@@ -0,0 +1,866 @@
/* AMX Mod X script.
* Admin Base Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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.
*/
// Uncomment for SQL version
// #define USING_SQL
#include <amxmodx>
#include <amxmisc>
#if defined USING_SQL
#include <sqlx>
#endif
//new Vector:AdminList;
new AdminCount;
new PLUGINNAME[] = "AMX Mod X"
#define ADMIN_LOOKUP (1<<0)
#define ADMIN_NORMAL (1<<1)
#define ADMIN_STEAM (1<<2)
#define ADMIN_IPADDR (1<<3)
#define ADMIN_NAME (1<<4)
new g_cmdLoopback[16]
new bool:g_CaseSensitiveName[33];
// pcvars
new amx_mode;
new amx_password_field;
new amx_default_access;
public plugin_init()
{
#if defined USING_SQL
register_plugin("Admin Base (SQL)", AMXX_VERSION_STR, "AMXX Dev Team")
#else
register_plugin("Admin Base", AMXX_VERSION_STR, "AMXX Dev Team")
#endif
register_dictionary("admin.txt")
register_dictionary("common.txt")
amx_mode=register_cvar("amx_mode", "1")
amx_password_field=register_cvar("amx_password_field", "_pw")
amx_default_access=register_cvar("amx_default_access", "")
register_cvar("amx_vote_ratio", "0.02")
register_cvar("amx_vote_time", "10")
register_cvar("amx_vote_answers", "1")
register_cvar("amx_vote_delay", "60")
register_cvar("amx_last_voting", "0")
register_cvar("amx_show_activity", "2")
register_cvar("amx_votekick_ratio", "0.40")
register_cvar("amx_voteban_ratio", "0.40")
register_cvar("amx_votemap_ratio", "0.40")
set_cvar_float("amx_last_voting", 0.0)
#if defined USING_SQL
register_srvcmd("amx_sqladmins", "adminSql")
register_cvar("amx_sql_table", "admins")
#endif
register_cvar("amx_sql_host", "127.0.0.1")
register_cvar("amx_sql_user", "root")
register_cvar("amx_sql_pass", "")
register_cvar("amx_sql_db", "amx")
register_cvar("amx_sql_type", "mysql")
register_concmd("amx_reloadadmins", "cmdReload", ADMIN_CFG)
register_concmd("amx_addadmin", "addadminfn", ADMIN_RCON, "<playername|auth> <accessflags> [password] [authtype] - add specified player as an admin to users.ini")
format(g_cmdLoopback, 15, "amxauth%c%c%c%c", random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'), random_num('A', 'Z'))
register_clcmd(g_cmdLoopback, "ackSignal")
remove_user_flags(0, read_flags("z")) // Remove 'user' flag from server rights
new configsDir[64]
get_configsdir(configsDir, 63)
server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file
server_cmd("exec %s/sql.cfg", configsDir)
// Create a vector of 5 cells to store the info.
//AdminList=vector_create(5);
#if defined USING_SQL
server_cmd("amx_sqladmins")
#else
format(configsDir, 63, "%s/users.ini", configsDir)
loadSettings(configsDir) // Load admins accounts
#endif
}
public client_connect(id)
{
g_CaseSensitiveName[id] = false;
}
public addadminfn(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new idtype = ADMIN_STEAM | ADMIN_LOOKUP
if (read_argc() >= 5)
{
new t_arg[16]
read_argv(4, t_arg, 15)
if (equali(t_arg, "steam") || equali(t_arg, "steamid") || equali(t_arg, "auth"))
{
idtype = ADMIN_STEAM
}
else if (equali(t_arg, "ip"))
{
idtype = ADMIN_IPADDR
}
else if (equali(t_arg, "name") || equali(t_arg, "nick"))
{
idtype = ADMIN_NAME
if (equali(t_arg, "name"))
idtype |= ADMIN_LOOKUP
} else {
console_print(id, "[%s] Unknown id type ^"%s^", use one of: steamid, ip, name", PLUGINNAME, t_arg)
return PLUGIN_HANDLED
}
}
new arg[33]
read_argv(1, arg, 32)
new player = -1
if (idtype & ADMIN_STEAM)
{
if (containi(arg, "STEAM_0:") == -1)
{
idtype |= ADMIN_LOOKUP
player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS)
} else {
new _steamid[44]
static _players[32], _num, _pv
get_players(_players, _num)
for (new _i=0; _i<_num; _i++)
{
_pv = _players[_i]
get_user_authid(_pv, _steamid, sizeof(_steamid)-1)
if (!_steamid[0])
continue
if (equal(_steamid, arg))
{
player = _pv
break
}
}
if (player < 1)
{
idtype &= ~ADMIN_LOOKUP
}
}
}
else if (idtype & ADMIN_NAME)
{
player = cmd_target(id, arg, CMDTARGET_ALLOW_SELF | CMDTARGET_NO_BOTS)
if (player)
idtype |= ADMIN_LOOKUP
else
idtype &= ~ADMIN_LOOKUP
}
else if (idtype & ADMIN_IPADDR)
{
new len = strlen(arg)
new dots, chars
for (new i = 0; i < len; i++)
{
if (arg[i] == '.')
{
if (!chars || chars > 3)
break
if (++dots > 3)
break
chars = 0
} else {
chars++
}
if (dots != 3 || !chars || chars > 3)
{
idtype |= ADMIN_LOOKUP
player = find_player("dh", arg)
}
}
}
if (idtype & ADMIN_LOOKUP && !player)
{
console_print(id, "%L", id, "CL_NOT_FOUND")
return PLUGIN_HANDLED
}
new flags[64]
read_argv(2, flags, 63)
new password[64]
if (read_argc() >= 4)
read_argv(3, password, 63)
new auth[33]
new Comment[33]; // name of player to pass to comment field
if (idtype & ADMIN_LOOKUP)
{
get_user_name(player, Comment, sizeof(Comment)-1)
if (idtype & ADMIN_STEAM)
{
get_user_authid(player, auth, 32)
}
else if (idtype & ADMIN_IPADDR)
{
get_user_ip(player, auth, 32)
}
else if (idtype & ADMIN_NAME)
{
get_user_name(player, auth, 32)
}
} else {
copy(auth, 32, arg)
}
new type[16], len
if (idtype & ADMIN_STEAM)
len += format(type[len], 15-len, "c")
else if (idtype & ADMIN_IPADDR)
len += format(type[len], 15-len, "d")
if (strlen(password) > 0)
len += format(type[len], 15-len, "a")
else
len += format(type[len], 15-len, "e")
AddAdmin(id, auth, flags, password, type, Comment)
cmdReload(id, ADMIN_CFG, 0)
if (player > 0)
{
new name[32]
get_user_info(player, "name", name, 31)
accessUser(player, name)
}
return PLUGIN_HANDLED
}
AddAdmin(id, auth[], accessflags[], password[], flags[], comment[]="")
{
#if defined USING_SQL
new error[128], errno
new Handle:info = SQL_MakeStdTuple()
new Handle:sql = SQL_Connect(info, errno, error, 127)
if (sql == Empty_Handle)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_CON", error)
//backup to users.ini
#endif
// Make sure that the users.ini file exists.
new configsDir[64]
get_configsdir(configsDir, 63)
format(configsDir, 63, "%s/users.ini", configsDir)
if (!file_exists(configsDir))
{
console_print(id, "[%s] File ^"%s^" doesn't exist.", PLUGINNAME, configsDir)
return
}
// Make sure steamid isn't already in file.
new line = 0, textline[256], len
const SIZE = 63
new line_steamid[SIZE + 1], line_password[SIZE + 1], line_accessflags[SIZE + 1], line_flags[SIZE + 1], parsedParams
// <name|ip|steamid> <password> <access flags> <account flags>
while ((line = read_file(configsDir, line, textline, 255, len)))
{
if (len == 0 || equal(textline, ";", 1))
continue // comment line
parsedParams = parse(textline, line_steamid, SIZE, line_password, SIZE, line_accessflags, SIZE, line_flags, SIZE)
if (parsedParams != 4)
continue // Send warning/error?
if (containi(line_flags, flags) != -1 && equal(line_steamid, auth))
{
console_print(id, "[%s] %s already exists!", PLUGINNAME, auth)
return
}
}
// If we came here, steamid doesn't exist in users.ini. Add it.
new linetoadd[512]
if (comment[0]==0)
{
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
}
else
{
formatex(linetoadd, 511, "^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^" ; %s", auth, password, accessflags, flags, comment)
}
console_print(id, "Adding:^n%s", linetoadd)
if (!write_file(configsDir, linetoadd))
console_print(id, "[%s] Failed writing to %s!", PLUGINNAME, configsDir)
#if defined USING_SQL
}
new table[32]
get_cvar_string("amx_sql_table", table, 31)
new Handle:query = SQL_PrepareQuery(sql, "SELECT * FROM `%s` WHERE (`auth` = '%s')", table, auth)
if (!SQL_Execute(query))
{
SQL_QueryError(query, error, 127)
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
} else if (SQL_NumResults(query)) {
console_print(id, "[%s] %s already exists!", PLUGINNAME, auth)
} else {
console_print(id, "Adding to database:^n^"%s^" ^"%s^" ^"%s^" ^"%s^"", auth, password, accessflags, flags)
SQL_QueryAndIgnore(sql, "REPLACE INTO `%s` (`auth`, `password`, `access`, `flags`) VALUES ('%s', '%s', '%s', '%s')", table, auth, password, accessflags, flags)
}
SQL_FreeHandle(query)
SQL_FreeHandle(sql)
SQL_FreeHandle(info)
#endif
}
public plugin_cfg()
{
set_task(6.1, "delayed_load")
}
public delayed_load()
{
new configFile[128], curMap[64], configDir[128]
get_configsdir(configDir, sizeof(configDir)-1)
get_mapname(curMap, sizeof(curMap)-1)
new i=0;
while (curMap[i] != '_' && curMap[i++] != '^0') {/*do nothing*/}
if (curMap[i]=='_')
{
// this map has a prefix
curMap[i]='^0';
formatex(configFile, sizeof(configFile)-1, "%s/maps/prefix_%s.cfg", configDir, curMap);
if (file_exists(configFile))
{
server_cmd("exec %s", configFile);
}
}
get_mapname(curMap, sizeof(curMap)-1)
formatex(configFile, sizeof(configFile)-1, "%s/maps/%s.cfg", configDir, curMap)
if (file_exists(configFile))
{
server_cmd("exec %s", configFile)
}
}
loadSettings(szFilename[])
{
new File=fopen(szFilename,"r");
if (File)
{
new Text[512];
new Flags[32];
new Access[32]
new AuthData[44];
new Password[32];
while (!feof(File))
{
fgets(File,Text,sizeof(Text)-1);
trim(Text);
// comment
if (Text[0]==';')
{
continue;
}
Flags[0]=0;
Access[0]=0;
AuthData[0]=0;
Password[0]=0;
// not enough parameters
if (parse(Text,AuthData,sizeof(AuthData)-1,Password,sizeof(Password)-1,Access,sizeof(Access)-1,Flags,sizeof(Flags)-1) < 2)
{
continue;
}
admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
AdminCount++;
}
fclose(File);
}
if (AdminCount == 1)
{
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
}
else
{
server_print("[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
}
return 1;
}
#if defined USING_SQL
public adminSql()
{
new table[32], error[128], type[12], errno
new Handle:info = SQL_MakeStdTuple()
new Handle:sql = SQL_Connect(info, errno, error, 127)
get_cvar_string("amx_sql_table", table, 31)
SQL_GetAffinity(type, 11)
if (sql == Empty_Handle)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_CON", error)
//backup to users.ini
new configsDir[64]
get_configsdir(configsDir, 63)
format(configsDir, 63, "%s/users.ini", configsDir)
loadSettings(configsDir) // Load admins accounts
return PLUGIN_HANDLED
}
new Handle:query
if (equali(type, "sqlite"))
{
if (!sqlite_TableExists(sql, table))
{
SQL_QueryAndIgnore(sql, "CREATE TABLE %s ( auth TEXT NOT NULL DEFAULT '', password TEXT NOT NULL DEFAULT '', access TEXT NOT NULL DEFAULT '', flags TEXT NOT NULL DEFAULT '' )", table)
}
query = SQL_PrepareQuery(sql, "SELECT auth, password, access, flags FROM %s", table)
} else {
SQL_QueryAndIgnore(sql, "CREATE TABLE IF NOT EXISTS `%s` ( `auth` VARCHAR( 32 ) NOT NULL, `password` VARCHAR( 32 ) NOT NULL, `access` VARCHAR( 32 ) NOT NULL, `flags` VARCHAR( 32 ) NOT NULL ) COMMENT = 'AMX Mod X Admins'", table)
query = SQL_PrepareQuery(sql,"SELECT `auth`,`password`,`access`,`flags` FROM `%s`", table)
}
if (!SQL_Execute(query))
{
SQL_QueryError(query, error, 127)
server_print("[AMXX] %L", LANG_SERVER, "SQL_CANT_LOAD_ADMINS", error)
} else if (!SQL_NumResults(query)) {
server_print("[AMXX] %L", LANG_SERVER, "NO_ADMINS")
} else {
AdminCount = 0
/** do this incase people change the query order and forget to modify below */
new qcolAuth = SQL_FieldNameToNum(query, "auth")
new qcolPass = SQL_FieldNameToNum(query, "password")
new qcolAccess = SQL_FieldNameToNum(query, "access")
new qcolFlags = SQL_FieldNameToNum(query, "flags")
new AuthData[44];
new Password[44];
new Access[32];
new Flags[32];
while (SQL_MoreResults(query))
{
SQL_ReadResult(query, qcolAuth, AuthData, sizeof(AuthData)-1);
SQL_ReadResult(query, qcolPass, Password, sizeof(Password)-1);
SQL_ReadResult(query, qcolAccess, Access, sizeof(Access)-1);
SQL_ReadResult(query, qcolFlags, Flags, sizeof(Flags)-1);
admins_push(AuthData,Password,read_flags(Access),read_flags(Flags));
++AdminCount;
SQL_NextRow(query)
}
if (AdminCount == 1)
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
}
else
{
server_print("[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
}
SQL_FreeHandle(query)
SQL_FreeHandle(sql)
SQL_FreeHandle(info)
}
return PLUGIN_HANDLED
}
#endif
public cmdReload(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
//strip original flags (patch submitted by mrhunt)
remove_user_flags(0, read_flags("z"))
admins_flush();
#if !defined USING_SQL
new filename[128]
get_configsdir(filename, 127)
format(filename, 63, "%s/users.ini", filename)
AdminCount = 0;
loadSettings(filename); // Re-Load admins accounts
if (id != 0)
{
if (AdminCount == 1)
{
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMIN");
}
else
{
console_print(id, "[AMXX] %L", LANG_SERVER, "LOADED_ADMINS", AdminCount);
}
}
#else
AdminCount = 0
adminSql()
if (id != 0)
{
if (AdminCount == 1)
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMIN")
else
console_print(id, "[AMXX] %L", LANG_SERVER, "SQL_LOADED_ADMINS", AdminCount)
}
#endif
new players[32], num, pv
new name[32]
get_players(players, num)
for (new i=0; i<num; i++)
{
pv = players[i]
get_user_name(pv, name, 31)
accessUser(pv, name)
}
return PLUGIN_HANDLED
}
getAccess(id, name[], authid[], ip[], password[])
{
new index = -1
new result = 0
static Count;
static Flags;
static Access;
static AuthData[44];
static Password[32];
g_CaseSensitiveName[id] = false;
Count=admins_num();
for (new i = 0; i < Count; ++i)
{
Flags=admins_lookup(i,AdminProp_Flags);
admins_lookup(i,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
if (Flags & FLAG_AUTHID)
{
if (equal(authid, AuthData))
{
index = i
break
}
}
else if (Flags & FLAG_IP)
{
new c = strlen(AuthData)
if (AuthData[c - 1] == '.') /* check if this is not a xxx.xxx. format */
{
if (equal(AuthData, ip, c))
{
index = i
break
}
} /* in other case an IP must just match */
else if (equal(ip, AuthData))
{
index = i
break
}
}
else
{
if (Flags & FLAG_CASE_SENSITIVE)
{
if (Flags & FLAG_TAG)
{
if (contain(name, AuthData) != -1)
{
index = i
g_CaseSensitiveName[id] = true
break
}
}
else if (equal(name, AuthData))
{
index = i
g_CaseSensitiveName[id] = true
break
}
}
else
{
if (Flags & FLAG_TAG)
{
if (containi(name, AuthData) != -1)
{
index = i
break
}
}
else if (equali(name, AuthData))
{
index = i
break
}
}
}
}
if (index != -1)
{
Access=admins_lookup(index,AdminProp_Access);
if (Flags & FLAG_NOPASS)
{
result |= 8
new sflags[32]
get_flags(Access, sflags, 31)
set_user_flags(id, Access)
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
}
else
{
admins_lookup(index,AdminProp_Password,Password,sizeof(Password)-1);
if (equal(password, Password))
{
result |= 12
set_user_flags(id, Access)
new sflags[32]
get_flags(Access, sflags, 31)
log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, sflags, ip)
}
else
{
result |= 1
if (Flags & FLAG_KICK)
{
result |= 2
log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", name, get_user_userid(id), authid, AuthData, ip)
}
}
}
}
else if (get_pcvar_float(amx_mode) == 2.0)
{
result |= 2
}
else
{
new defaccess[32]
get_pcvar_string(amx_default_access, defaccess, 31)
if (!strlen(defaccess))
{
copy(defaccess, 32, "z")
}
new idefaccess = read_flags(defaccess)
if (idefaccess)
{
result |= 8
set_user_flags(id, idefaccess)
}
}
return result
}
accessUser(id, name[] = "")
{
remove_user_flags(id)
new userip[32], userauthid[32], password[32], passfield[32], username[32]
get_user_ip(id, userip, 31, 1)
get_user_authid(id, userauthid, 31)
if (name[0])
{
copy(username, 31, name)
}
else
{
get_user_name(id, username, 31)
}
get_pcvar_string(amx_password_field, passfield, 31)
get_user_info(id, passfield, password, 31)
new result = getAccess(id, username, userauthid, userip, password)
if (result & 1)
{
client_cmd(id, "echo ^"* %L^"", id, "INV_PAS")
}
if (result & 2)
{
client_cmd(id, "%s", g_cmdLoopback)
return PLUGIN_HANDLED
}
if (result & 4)
{
client_cmd(id, "echo ^"* %L^"", id, "PAS_ACC")
}
if (result & 8)
{
client_cmd(id, "echo ^"* %L^"", id, "PRIV_SET")
}
return PLUGIN_CONTINUE
}
public client_infochanged(id)
{
if (!is_user_connected(id) || !get_pcvar_num(amx_mode))
{
return PLUGIN_CONTINUE
}
new newname[32], oldname[32]
get_user_name(id, oldname, 31)
get_user_info(id, "name", newname, 31)
if (g_CaseSensitiveName[id])
{
if (!equal(newname, oldname))
{
accessUser(id, newname)
}
}
else
{
if (!equali(newname, oldname))
{
accessUser(id, newname)
}
}
return PLUGIN_CONTINUE
}
public ackSignal(id)
{
server_cmd("kick #%d ^"%L^"", get_user_userid(id), id, "NO_ENTRY")
return PLUGIN_HANDLED
}
public client_authorized(id)
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
public client_putinserver(id)
{
if (!is_dedicated_server() && id == 1)
return get_pcvar_num(amx_mode) ? accessUser(id) : PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}

View File

@@ -0,0 +1,402 @@
/* AMX Mod X
* Admin Chat Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
new g_msgChannel
#define MAX_CLR 10
new g_Colors[MAX_CLR][] = {"COL_WHITE", "COL_RED", "COL_GREEN", "COL_BLUE", "COL_YELLOW", "COL_MAGENTA", "COL_CYAN", "COL_ORANGE", "COL_OCEAN", "COL_MAROON"}
new g_Values[MAX_CLR][] = {{255, 255, 255}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {227, 96, 8}, {45, 89, 116}, {103, 44, 38}}
new Float:g_Pos[4][] = {{0.0, 0.0}, {0.05, 0.55}, {-1.0, 0.2}, {-1.0, 0.7}}
new amx_show_activity;
new g_AdminChatFlag = ADMIN_CHAT;
public plugin_init()
{
new admin_chat_id
register_plugin("Admin Chat", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminchat.txt")
register_dictionary("common.txt")
register_clcmd("say", "cmdSayChat", ADMIN_CHAT, "@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message")
register_clcmd("say_team", "cmdSayAdmin", 0, "@<text> - displays message to admins")
register_concmd("amx_say", "cmdSay", ADMIN_CHAT, "<message> - sends message to all players")
admin_chat_id = register_concmd("amx_chat", "cmdChat", ADMIN_CHAT, "<message> - sends message to admins")
register_concmd("amx_psay", "cmdPsay", ADMIN_CHAT, "<name or #userid> <message> - sends private message")
register_concmd("amx_tsay", "cmdTsay", ADMIN_CHAT, "<color> <message> - sends left side hud message to all players")
register_concmd("amx_csay", "cmdTsay", ADMIN_CHAT, "<color> <message> - sends center hud message to all players")
amx_show_activity = get_cvar_pointer("amx_show_activity");
if (amx_show_activity == 0)
{
amx_show_activity = register_cvar("amx_show_activity", "2");
}
new str[1]
get_concmd(admin_chat_id, str, 0, g_AdminChatFlag, str, 0, -1)
}
public cmdSayChat(id)
{
if (!access(id, g_AdminChatFlag))
{
return PLUGIN_CONTINUE
}
new said[6], i = 0
read_argv(1, said, 5)
while (said[i] == '@')
{
i++
}
if (!i || i > 3)
{
return PLUGIN_CONTINUE
}
new message[192], a = 0
read_args(message, 191)
remove_quotes(message)
switch (said[i])
{
case 'r': a = 1
case 'g': a = 2
case 'b': a = 3
case 'y': a = 4
case 'm': a = 5
case 'c': a = 6
case 'o': a = 7
}
new n, s = i
if (a)
{
n++
s++
}
while (said[s] && isspace(said[s]))
{
n++
s++
}
new name[32], authid[32], userid
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
log_amx("Chat: ^"%s<%d><%s><>^" tsay ^"%s^"", name, userid, authid, message[i + n])
log_message("^"%s<%d><%s><>^" triggered ^"amx_tsay^" (text ^"%s^") (color ^"%L^")", name, userid, authid, message[i + n], "en", g_Colors[a])
if (++g_msgChannel > 6 || g_msgChannel < 3)
{
g_msgChannel = 3
}
new Float:verpos = g_Pos[i][1] + float(g_msgChannel) / 35.0
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], g_Pos[i][0], verpos, 0, 6.0, 6.0, 0.5, 0.15, -1)
switch ( get_pcvar_num(amx_show_activity) )
{
case 3, 4:
{
new maxpl = get_maxplayers();
for (new pl = 1; pl <= maxpl; pl++)
{
if (is_user_connected(pl) && !is_user_bot(pl))
{
if (is_user_admin(pl))
{
show_hudmessage(pl, "%s : %s", name, message[i + n])
client_print(pl, print_notify, "%s : %s", name, message[i + n])
}
else
{
show_hudmessage(pl, "%s", message[i + n])
client_print(pl, print_notify, "%s", message[i + n])
}
}
}
}
case 2:
{
show_hudmessage(0, "%s : %s", name, message[i + n])
client_print(0, print_notify, "%s : %s", name, message[i + n])
}
default:
{
show_hudmessage(0, "%s", message[i + n])
client_print(0, print_notify, "%s", message[i + n])
}
}
return PLUGIN_HANDLED
}
public cmdSayAdmin(id)
{
new said[2]
read_argv(1, said, 1)
if (said[0] != '@')
return PLUGIN_CONTINUE
new message[192], name[32], authid[32], userid
new players[32], inum
read_args(message, 191)
remove_quotes(message)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message[1])
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message[1])
if (is_user_admin(id))
format(message, 191, "(%L) %s : %s", id, "ADMIN", name, message[1])
else
format(message, 191, "(%L) %s : %s", id, "PLAYER", name, message[1])
get_players(players, inum)
for (new i = 0; i < inum; ++i)
{
// dont print the message to the client that used the cmd if he has ADMIN_CHAT to avoid double printing
if (players[i] != id && get_user_flags(players[i]) & g_AdminChatFlag)
client_print(players[i], print_chat, "%s", message)
}
client_print(id, print_chat, "%s", message)
return PLUGIN_HANDLED
}
public cmdChat(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new message[192], name[32], players[32], inum, authid[32], userid
read_args(message, 191)
remove_quotes(message)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
get_players(players, inum)
log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message)
format(message, 191, "(ADMINS) %s : %s", name, message)
console_print(id, "%s", message)
for (new i = 0; i < inum; ++i)
{
if (access(players[i], g_AdminChatFlag))
client_print(players[i], print_chat, "%s", message)
}
return PLUGIN_HANDLED
}
public cmdSay(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new message[192], name[32], authid[32], userid
read_args(message, 191)
remove_quotes(message)
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
client_print(0, print_chat, "%L", LANG_PLAYER, "PRINT_ALL", name, message)
console_print(id, "%L", LANG_PLAYER, "PRINT_ALL", name, message)
log_amx("Chat: ^"%s<%d><%s><>^" say ^"%s^"", name, userid, authid, message)
log_message("^"%s<%d><%s><>^" triggered ^"amx_say^" (text ^"%s^")", name, userid, authid, message)
return PLUGIN_HANDLED
}
public cmdPsay(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new name[32]
read_argv(1, name, 31)
new priv = cmd_target(id, name, 0)
if (!priv)
return PLUGIN_HANDLED
new length = strlen(name) + 1
get_user_name(priv, name, 31);
new message[192], name2[32], authid[32], authid2[32], userid, userid2
get_user_authid(id, authid, 31)
get_user_name(id, name2, 31)
userid = get_user_userid(id)
read_args(message, 191)
if (message[0] == '"' && message[length] == '"') // HLSW fix
{
message[0] = ' '
message[length] = ' '
length += 2
}
remove_quotes(message[length])
get_user_name(priv, name, 31)
if (id && id != priv)
client_print(id, print_chat, "(%s) %s : %s", name, name2, message[length])
client_print(priv, print_chat, "(%s) %s : %s", name, name2, message[length])
console_print(id, "(%s) %s : %s", name, name2, message[length])
get_user_authid(priv, authid2, 31)
userid2 = get_user_userid(priv)
log_amx("Chat: ^"%s<%d><%s><>^" psay ^"%s<%d><%s><>^" ^"%s^"", name2, userid, authid, name, userid2, authid2, message[length])
log_message("^"%s<%d><%s><>^" triggered ^"amx_psay^" against ^"%s<%d><%s><>^" (text ^"%s^")", name2, userid, authid, name, userid2, authid2, message[length])
return PLUGIN_HANDLED
}
public cmdTsay(id, level, cid)
{
if (!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED
new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0
read_argv(0, cmd, 15)
new bool:tsay = (tolower(cmd[4]) == 't')
read_args(message, 191)
remove_quotes(message)
parse(message, color, 15)
new found = 0, a = 0
new lang[3], langnum = get_langsnum()
for (new i = 0; i < MAX_CLR; ++i)
{
for (new j = 0; j < langnum; j++)
{
get_lang(j, lang)
format(color2, 15, "%L", lang, g_Colors[i])
if (equali(color, color2))
{
a = i
found = 1
break
}
}
if (found == 1)
break
}
new length = found ? (strlen(color) + 1) : 0
if (++g_msgChannel > 6 || g_msgChannel < 3)
g_msgChannel = 3
new Float:verpos = (tsay ? 0.55 : 0.1) + float(g_msgChannel) / 35.0
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
userid = get_user_userid(id)
set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, -1)
switch ( get_pcvar_num(amx_show_activity) )
{
case 3, 4:
{
new maxpl = get_maxplayers();
for (new pl = 1; pl <= maxpl; pl++)
{
if (is_user_connected(pl) && !is_user_bot(pl))
{
if (is_user_admin(pl))
{
show_hudmessage(pl, "%s : %s", name, message[length])
client_print(pl, print_notify, "%s : %s", name, message[length])
}
else
{
show_hudmessage(pl, "%s", message[length])
client_print(pl, print_notify, "%s", message[length])
}
}
}
console_print(id, "%s : %s", name, message[length])
}
case 2:
{
show_hudmessage(0, "%s : %s", name, message[length])
client_print(0, print_notify, "%s : %s", name, message[length])
console_print(id, "%s : %s", name, message[length])
}
default:
{
show_hudmessage(0, "%s", message[length])
client_print(0, print_notify, "%s", message[length])
console_print(id, "%s", message[length])
}
}
log_amx("Chat: ^"%s<%d><%s><>^" %s ^"%s^"", name, userid, authid, cmd[4], message[length])
log_message("^"%s<%d><%s><>^" triggered ^"%s^" (text ^"%s^") (color ^"%s^")", name, userid, authid, cmd, message[length], color2)
return PLUGIN_HANDLED
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,129 @@
/* AMX Mod X
* Admin Help Plugin
*
* by the AMX Mod X Development Team
* originally developed by tcquest78
*
* 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>
#define DISPLAY_MSG // Comment to disable message on join
#define HELPAMOUNT 10 // Number of commands per page
public plugin_init()
{
register_plugin("Admin Help", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminhelp.txt")
register_concmd("amx_help", "cmdHelp", 0, "<page> [nr of cmds (only for server)] - displays this help")
}
#if defined DISPLAY_MSG
public client_putinserver(id)
{
if (is_user_bot(id))
return
set_task(15.0, "dispInfo", id)
}
public client_disconnect(id)
{
remove_task(id)
}
#endif
public cmdHelp(id, level, cid)
{
new arg1[8], flags = get_user_flags(id)
new start = read_argv(1, arg1, 7) ? str_to_num(arg1) : 1
new lHelpAmount = HELPAMOUNT
// HACK: ADMIN_ADMIN is never set as a user's actual flags, so those types of commands never show
if (flags > 0 && !(flags & ADMIN_USER))
{
flags |= ADMIN_ADMIN;
}
if (id == 0 && read_argc() == 3)
lHelpAmount = read_argv(2, arg1, 7) ? str_to_num(arg1) : HELPAMOUNT
if (--start < 0)
start = 0
new clcmdsnum = get_concmdsnum(flags, id)
if (start >= clcmdsnum)
start = clcmdsnum - 1
console_print(id, "^n----- %L -----", id, "HELP_COMS")
new info[128], cmd[32], eflags
new end = start + lHelpAmount // HELPAMOUNT
if (end > clcmdsnum)
end = clcmdsnum
for (new i = start; i < end; i++)
{
get_concmd(i, cmd, 31, eflags, info, 127, flags, id)
console_print(id, "%3d: %s %s", i + 1, cmd, info)
}
console_print(id, "----- %L -----", id, "HELP_ENTRIES", start + 1, end, clcmdsnum)
if (end < clcmdsnum)
console_print(id, "----- %L -----", id, "HELP_USE_MORE", end + 1)
else
console_print(id, "----- %L -----", id, "HELP_USE_BEGIN")
return PLUGIN_HANDLED
}
#if defined DISPLAY_MSG
public dispInfo(id)
{
client_print(id, print_chat, "%L", id, "TYPE_HELP")
new nextmap[32]
get_cvar_string("amx_nextmap", nextmap, 31)
if (get_cvar_float("mp_timelimit"))
{
new timeleft = get_timeleft()
if (timeleft > 0)
{
client_print(id, print_chat, "%L", id, "TIME_INFO_1", timeleft / 60, timeleft % 60, nextmap)
} else {
client_print(id, print_chat, "%L", id, "TIME_INFO_2", nextmap)
}
}
}
#endif

View File

@@ -0,0 +1,107 @@
/* AMX Mod X
* Slots Reservation Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
new g_ResPtr
new g_HidePtr
public plugin_init()
{
register_plugin("Slots Reservation", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminslots.txt")
register_dictionary("common.txt")
g_ResPtr = register_cvar("amx_reservation", "0")
g_HidePtr = register_cvar("amx_hideslots", "0")
}
public plugin_cfg()
{
set_task(3.0, "MapLoaded")
}
public MapLoaded()
{
if (!get_pcvar_num(g_HidePtr))
return
new maxplayers = get_maxplayers()
new players = get_playersnum(1)
new limit = maxplayers - get_pcvar_num(g_ResPtr)
setVisibleSlots(players, maxplayers, limit)
}
public client_authorized(id)
{
new maxplayers = get_maxplayers()
new players = get_playersnum(1)
new limit = maxplayers - get_pcvar_num(g_ResPtr)
if (access(id, ADMIN_RESERVATION) || (players <= limit))
{
if (get_pcvar_num(g_HidePtr) == 1)
setVisibleSlots(players, maxplayers, limit)
return PLUGIN_CONTINUE
}
new lReason[64]
format(lReason, 63, "%L", id, "DROPPED_RES")
server_cmd("kick #%d ^"%s^"", get_user_userid(id), lReason)
return PLUGIN_HANDLED
}
public client_disconnect(id)
{
if (!get_pcvar_num(g_HidePtr))
return PLUGIN_CONTINUE
new maxplayers = get_maxplayers()
setVisibleSlots(get_playersnum(1) - 1, maxplayers, maxplayers - get_pcvar_num(g_ResPtr))
return PLUGIN_CONTINUE
}
setVisibleSlots(players, maxplayers, limit)
{
new num = players + 1
if (players == maxplayers)
num = maxplayers
else if (players < limit)
num = limit
set_cvar_num("sv_visiblemaxplayers", num)
}

View File

@@ -0,0 +1,570 @@
/* AMX Mod X
* Admin Votes Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
new g_Answer[128]
new g_optionName[4][64]
new g_voteCount[4]
new g_validMaps
new g_yesNoVote
new g_coloredMenus
new g_voteCaller
new g_Execute[256]
new g_execLen
new bool:g_execResult
new Float:g_voteRatio
public plugin_init()
{
register_plugin("Admin Votes", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("adminvote.txt")
register_dictionary("common.txt")
register_dictionary("mapsmenu.txt")
register_menucmd(register_menuid("Change map to "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Choose map: "), MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4, "voteCount")
register_menucmd(register_menuid("Kick "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Ban "), MENU_KEY_1|MENU_KEY_2, "voteCount")
register_menucmd(register_menuid("Vote: "), MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4, "voteCount")
register_menucmd(register_menuid("The result: "), MENU_KEY_1|MENU_KEY_2, "actionResult")
register_concmd("amx_votemap", "cmdVoteMap", ADMIN_VOTE, "<map> [map] [map] [map]")
register_concmd("amx_votekick", "cmdVoteKickBan", ADMIN_VOTE, "<name or #userid>")
register_concmd("amx_voteban", "cmdVoteKickBan", ADMIN_VOTE, "<name or #userid>")
register_concmd("amx_vote", "cmdVote", ADMIN_VOTE, "<question> <answer#1> <answer#2>")
register_concmd("amx_cancelvote", "cmdCancelVote", ADMIN_VOTE, "- cancels last vote")
g_coloredMenus = colored_menus()
}
public cmdCancelVote(id, level, cid)
{
if (!cmd_access(id, level, cid, 0))
return PLUGIN_HANDLED
if (task_exists(99889988, 1))
{
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
log_amx("Vote: ^"%s<%d><%s><>^" cancel vote session", name, get_user_userid(id), authid)
new maxpl=get_maxplayers();
new msg[256];
for (new i = 1; i <= maxpl; i++)
{
if (is_user_connected(i) && !is_user_bot(i))
{
// HACK: ADMIN_CANC_VOTE_{1,2} keys were designed very poorly. Remove all : and %s in it.
LookupLangKey(msg, charsmax(msg), "ADMIN_CANC_VOTE_1", i);
replace_all(msg, charsmax(msg), "%s", "");
replace_all(msg, charsmax(msg), ":", "");
trim(msg);
show_activity_id(i, id, name, msg);
}
}
console_print(id, "%L", id, "VOTING_CANC")
client_print(0,print_chat,"%L",LANG_PLAYER,"VOTING_CANC")
remove_task(99889988, 1)
set_cvar_float("amx_last_voting", get_gametime())
}
else
console_print(id, "%L", id, "NO_VOTE_CANC")
return PLUGIN_HANDLED
}
public delayedExec(cmd[])
server_cmd("%s", cmd)
public autoRefuse()
{
log_amx("Vote: %L", "en", "RES_REF")
client_print(0, print_chat, "%L", LANG_PLAYER, "RES_REF")
}
public actionResult(id, key)
{
remove_task(4545454)
switch (key)
{
case 0:
{
set_task(2.0, "delayedExec", 0, g_Execute, g_execLen)
log_amx("Vote: %L", "en", "RES_ACCEPTED")
client_print(0, print_chat, "%L", LANG_PLAYER, "RES_ACCEPTED")
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
}
public checkVotes()
{
new best = 0
if (!g_yesNoVote)
{
for (new a = 0; a < 4; ++a)
if (g_voteCount[a] > g_voteCount[best])
best = a
}
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3]
new iRatio = votesNum ? floatround(g_voteRatio * float(votesNum), floatround_ceil) : 1
new iResult = g_voteCount[best]
new players[32], pnum, i
get_players(players, pnum, "c")
if (iResult < iRatio)
{
new lVotingFailed[64]
for (i = 0; i < pnum; i++)
{
format(lVotingFailed, 63, "%L", players[i], "VOTING_FAILED")
if (g_yesNoVote)
client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_1", lVotingFailed, g_voteCount[0], g_voteCount[1], iRatio)
else
client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_2", lVotingFailed, iResult, iRatio)
}
format(lVotingFailed, 63, "%L", "en", "VOTING_FAILED")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^")", lVotingFailed, iResult, iRatio)
return PLUGIN_CONTINUE
}
g_execLen = format(g_Execute, 255, g_Answer, g_optionName[best]) + 1
if (g_execResult)
{
g_execResult = false
if (is_user_connected(g_voteCaller))
{
new menuBody[512], lTheResult[32], lYes[16], lNo[16]
format(lTheResult, 31, "%L", g_voteCaller, "THE_RESULT")
format(lYes, 15, "%L", g_voteCaller, "YES")
format(lNo, 15, "%L", g_voteCaller, "NO")
new len = format(menuBody, 511, g_coloredMenus ? "\y%s: \w%s^n^n" : "%s: %s^n^n", lTheResult, g_Execute)
len += format(menuBody[len], 511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", g_voteCaller, "WANT_CONTINUE")
format(menuBody[len], 511 - len, "^n1. %s^n2. %s", lYes, lNo)
show_menu(g_voteCaller, 0x03, menuBody, 10, "The result: ")
set_task(10.0, "autoRefuse", 4545454)
}
else
set_task(2.0, "delayedExec", 0, g_Execute, g_execLen)
}
new lVotingSuccess[32]
for (i = 0; i < pnum; i++)
{
format(lVotingSuccess, 31, "%L", players[i], "VOTING_SUCCESS")
client_print(players[i], print_chat, "%L", players[i], "VOTING_RES_3", lVotingSuccess, iResult, iRatio, g_Execute)
}
format(lVotingSuccess, 31, "%L", "en", "VOTING_SUCCESS")
log_amx("Vote: %s (got ^"%d^") (needed ^"%d^") (result ^"%s^")", lVotingSuccess, iResult, iRatio, g_Execute)
return PLUGIN_CONTINUE
}
public voteCount(id, key)
{
if (get_cvar_num("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)
if (g_yesNoVote)
client_print(0, print_chat, "%L", LANG_PLAYER, key ? "VOTED_AGAINST" : "VOTED_FOR", name)
else
client_print(0, print_chat, "%L", LANG_PLAYER, "VOTED_FOR_OPT", name, key + 1)
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
public cmdVoteMap(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
new argc = read_argc()
if (argc > 5) argc = 5
g_validMaps = 0
g_optionName[0][0] = 0
g_optionName[1][0] = 0
g_optionName[2][0] = 0
g_optionName[3][0] = 0
for (new i = 1; i < argc; ++i)
{
read_argv(i, g_optionName[g_validMaps], 31)
if (is_map_valid(g_optionName[g_validMaps]))
g_validMaps++
}
if (g_validMaps == 0)
{
new lMaps[16]
format(lMaps, 15, "%L", id, (argc == 2) ? "MAP_IS" : "MAPS_ARE")
console_print(id, "%L", id, "GIVEN_NOT_VALID", lMaps)
return PLUGIN_HANDLED
}
new menu_msg[256], len = 0
new keys = 0
if (g_validMaps > 1)
{
keys = MENU_KEY_0
len = format(menu_msg, 255, g_coloredMenus ? "\y%L: \w^n^n" : "%L: ^n^n", LANG_SERVER, "CHOOSE_MAP")
new temp[128]
for (new a = 0; a < g_validMaps; ++a)
{
format(temp, 127, "%d. %s^n", a+1, g_optionName[a])
len += copy(menu_msg[len], 255-len, temp)
keys |= (1<<a)
}
format(menu_msg[len], 255-len, "^n0. %L", LANG_SERVER, "NONE")
g_yesNoVote = 0
} else {
new lChangeMap[32], lYes[16], lNo[16]
format(lChangeMap, 31, "%L", LANG_SERVER, "CHANGE_MAP_TO")
format(lYes, 15, "%L", LANG_SERVER, "YES")
format(lNo, 15, "%L", LANG_SERVER, "NO")
format(menu_msg, 255, g_coloredMenus ? "\y%s %s?\w^n^n1. %s^n2. %s" : "%s %s?^n^n1. %s^n2. %s", lChangeMap, g_optionName[0], lYes, lNo)
keys = MENU_KEY_1|MENU_KEY_2
g_yesNoVote = 1
}
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
if (argc == 2)
log_amx("Vote: ^"%s<%d><%s><>^" vote map (map ^"%s^")", name, get_user_userid(id), authid, g_optionName[0])
else
log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")", name, get_user_userid(id), authid, g_optionName[0], g_optionName[1], g_optionName[2], g_optionName[3])
new maxpl=get_maxplayers();
new msg[256];
for (new i = 1; i <= maxpl; i++)
{
if (is_user_connected(i) && !is_user_bot(i))
{
// HACK: ADMIN_VOTE_MAP_{1,2} keys were designed very poorly. Remove all : and %s in it.
LookupLangKey(msg, charsmax(msg), "ADMIN_VOTE_MAP_1", i);
replace_all(msg, charsmax(msg), "%s", "");
replace_all(msg, charsmax(msg), ":", "");
trim(msg);
show_activity_id(i, id, name, msg);
}
}
g_execResult = true
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
g_voteRatio = get_cvar_float("amx_votemap_ratio")
g_Answer = "changelevel %s"
show_menu(0, keys, menu_msg, floatround(vote_time), (g_validMaps > 1) ? "Choose map: " : "Change map to ")
set_task(vote_time, "checkVotes", 99889988)
g_voteCaller = id
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = {0, 0, 0, 0}
return PLUGIN_HANDLED
}
public cmdVote(id, level, cid)
{
if (!cmd_access(id, level, cid, 4))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
new quest[48]
read_argv(1, quest, 47)
if (contain(quest, "sv_password") != -1 || contain(quest, "rcon_password") != -1)
{
console_print(id, "%L", id, "VOTING_FORBIDDEN")
return PLUGIN_HANDLED
}
new count=read_argc();
for (new i=0;i<4 && (i+2)<count;i++)
{
read_argv(i+2, g_optionName[i], sizeof(g_optionName[])-1);
}
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
log_amx("Vote: ^"%s<%d><%s><>^" vote custom (question ^"%s^") (option#1 ^"%s^") (option#2 ^"%s^")", name, get_user_userid(id), authid, quest, g_optionName[0], g_optionName[1])
new maxpl=get_maxplayers();
new msg[256];
for (new i = 1; i <= maxpl; i++)
{
if (is_user_connected(i) && !is_user_bot(i))
{
// HACK: ADMIN_VOTE_CUS_{1,2} keys were designed very poorly. Remove all : and %s in it.
LookupLangKey(msg, charsmax(msg), "ADMIN_VOTE_CUS_1", i);
replace_all(msg, charsmax(msg), "%s", "");
replace_all(msg, charsmax(msg), ":", "");
trim(msg);
show_activity_id(i, id, name, msg);
}
}
new menu_msg[512], lVote[16]
format(lVote, 15, "%L", LANG_SERVER, "VOTE")
count-=2;
if (count>4)
{
count=4;
}
// count now shows how many options were listed
new keys=0;
for (new i=0;i<count;i++)
{
keys |= (1<<i);
}
new len=formatex(menu_msg, sizeof(menu_msg)-1, g_coloredMenus ? "\y%s: %s\w^n^n" : "%s: %s^n^n", lVote, quest);
for (new i=0;i<count;i++)
{
len+=formatex(menu_msg[len], sizeof(menu_msg) - 1 - len ,"%d. %s^n",i+1,g_optionName[i]);
}
g_execResult = false
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
g_voteRatio = get_cvar_float("amx_vote_ratio")
replace_all(quest,sizeof(quest)-1,"%","");
format(g_Answer, 127, "%s - %%s", quest)
show_menu(0, keys, menu_msg, floatround(vote_time), "Vote: ")
set_task(vote_time, "checkVotes", 99889988)
g_voteCaller = id
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = {0, 0, 0, 0}
g_yesNoVote = 0
return PLUGIN_HANDLED
}
public cmdVoteKickBan(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
console_print(id, "%L", id, "ALREADY_VOTING")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
console_print(id, "%L", id, "VOTING_NOT_ALLOW")
return PLUGIN_HANDLED
}
new cmd[32]
read_argv(0, cmd, 31)
new voteban = equal(cmd, "amx_voteban")
new arg[32]
read_argv(1, arg, 31)
new player = cmd_target(id, arg, CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF)
if (!player)
return PLUGIN_HANDLED
if (voteban && is_user_bot(player))
{
new imname[32]
get_user_name(player, imname, 31)
console_print(id, "%L", id, "ACTION_PERFORMED", imname)
return PLUGIN_HANDLED
}
new keys = MENU_KEY_1|MENU_KEY_2
new menu_msg[256], lYes[16], lNo[16], lKickBan[16]
format(lYes, 15, "%L", LANG_SERVER, "YES")
format(lNo, 15, "%L", LANG_SERVER, "NO")
format(lKickBan, 15, "%L", LANG_SERVER, voteban ? "BAN" : "KICK")
ucfirst(lKickBan)
get_user_name(player, arg, 31)
format(menu_msg, 255, g_coloredMenus ? "\y%s %s?\w^n^n1. %s^n2. %s" : "%s %s?^n^n1. %s^n2. %s", lKickBan, arg, lYes, lNo)
g_yesNoVote = 1
new bool:ipban=false;
if (voteban)
{
get_user_authid(player, g_optionName[0], sizeof(g_optionName[])-1);
// Do the same check that's in plmenu to determine if this should be an IP ban instead
if (equal("4294967295", g_optionName[0])
|| equal("HLTV", g_optionName[0])
|| equal("STEAM_ID_LAN", g_optionName[0])
|| equali("VALVE_ID_LAN", g_optionName[0]))
{
get_user_ip(player, g_optionName[0], sizeof(g_optionName[])-1, 1);
ipban=true;
}
}
else
{
num_to_str(get_user_userid(player), g_optionName[0], 31)
}
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
log_amx("Vote: ^"%s<%d><%s><>^" vote %s (target ^"%s^")", name, get_user_userid(id), authid, voteban ? "ban" : "kick", arg)
new maxpl=get_maxplayers();
new msg[256];
new right[256];
new dummy[1];
for (new i = 1; i <= maxpl; i++)
{
if (is_user_connected(i) && !is_user_bot(i))
{
formatex(lKickBan, charsmax(lKickBan), "%L", i, voteban ? "BAN" : "KICK");
// HACK: ADMIN_VOTE_FOR{1,2} keys are really weird. Tokenize and ignore the text before the :
LookupLangKey(msg, charsmax(msg), "ADMIN_VOTE_FOR_1", i);
strtok(msg, dummy, 0, right, charsmax(right), ':');
trim(right);
show_activity_id(i, id, name, right, lKickBan, arg);
}
}
g_execResult = true
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
g_voteRatio = get_cvar_float(voteban ? "amx_voteban_ratio" : "amx_votekick_ratio")
if (voteban)
{
if (ipban==true)
{
g_Answer = "addip 30.0 %s";
}
else
{
g_Answer = "banid 30.0 %s kick";
}
}
else
{
g_Answer = "kick #%s";
}
show_menu(0, keys, menu_msg, floatround(vote_time), voteban ? "Ban " : "Kick ")
set_task(vote_time, "checkVotes", 99889988)
g_voteCaller = id
console_print(id, "%L", id, "VOTING_STARTED")
g_voteCount = {0, 0, 0, 0}
return PLUGIN_HANDLED
}

View File

@@ -0,0 +1,75 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
#include <amxmodx>
#include <fun> //we want fun running for extra compatibility
#include <engine> //we want engine running for extra compatibility
#include <fakemeta>
#include <translator>
#define AMXMODX_NOAUTOLOAD
#include <cstrike>
#include <sqlx>
#define MOD_NORMAL 0
#define MOD_CSTRIKE 1
new g_ModType = MOD_NORMAL
new g_MaxPlayers
#include "core.sma"
#include "vexdum.sma"
#include "mysql.sma"
public plugin_init()
{
register_plugin("AMX Mod Compat Engine", "1.76.rc4", "AMXX Dev Team")
g_MaxPlayers = get_maxplayers()
VexdUM_Register()
}
public plugin_natives()
{
set_module_filter("Plugin_ModuleFilter")
set_native_filter("Plugin_NativeFilter")
new modname[32]
get_modname(modname, 31)
if (equali(modname, "cstrike") || equali(modname, "czero"))
{
g_ModType = MOD_CSTRIKE
}
Core_Natives()
VexdUM_Natives()
MySQL_Natives()
}
public Plugin_ModuleFilter(const module[])
{
if (equali(module, "sqlx") || equali(module, "cstrike"))
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public Plugin_NativeFilter(const name[], index, trap)
{
if (!trap)
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_connect(id)
{
VexdUM_ClientConnect(id)
}

View File

@@ -0,0 +1,301 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
Core_Natives()
{
/* implicit compatibility */
register_native("VelocityByAim", "__VelocityByAim")
register_native("load_translations", "__load_translations")
register_native("is_user_authorized", "__is_user_authorized")
register_native("get_user_money", "__get_user_money")
register_native("set_user_money", "__set_user_money")
register_native("angle_to_vector", "__angle_to_vector")
register_native("fabs", "__fabs")
register_native("asin", "__asin")
register_native("sin", "__sin")
register_native("sinh", "__sinh")
register_native("acos", "__acos")
register_native("cos", "__cos")
register_native("cosh", "__cosh")
register_native("atan", "__atan")
register_native("atan2", "__atan2")
register_native("tan", "__tan")
register_native("tanh", "__tanh")
register_native("fsqroot", "__fsqroot")
register_native("fpower", "__fpower")
register_native("flog", "__flog")
register_native("get_cmdaccess", "__get_cmdaccess")
register_native("is_translated", "__is_translated")
register_native("get_plugincmdsnum", "__get_plugincmdsnum")
register_native("get_plugincmd", "__get_plugincmd")
register_native("get_plugincvarsnum", "__get_plugincvarsnum")
register_native("get_plugincvar", "__get_plugincvar")
register_native("is_module_running", "__is_module_running")
register_native("is_plugin_running", "__is_plugin_running")
}
public __VelocityByAim(plid, num)
{
new iIndex
new iVelocity
new Float:vRetValue[3]
iIndex = get_param(1)
iVelocity = get_param(2)
new ret = velocity_by_aim(iIndex, iVelocity, vRetValue)
set_array_f(3, vRetValue, 3)
return ret
}
public __load_translations(plid, num)
{
static file[255]
get_string(1, file, 254)
return load_translations(file)
}
public __is_user_authorized(plid, num)
{
return is_user_authorized(get_param(1))
}
public __get_user_money(plid, num)
{
return get_user_money(get_param(1))
}
public __set_user_money(plid, num)
{
return set_user_money(get_param(1), get_param(2), get_param(3))
}
public __angle_to_vector(plid, num)
{
new Float:angle[3]
new Float:vRetValue[3]
get_array_f(1, angle, 3)
new ret = angle_vector(angle, get_param(2), vRetValue)
set_array_f(3, vRetValue, 3)
return ret
}
public Float:__fabs(plid, num)
{
new Float:value = get_param_f(1)
return floatabs(value)
}
public Float:__asin(plid, num)
{
new Float:value = get_param_f(1)
return floatasin(value, radian)
}
public Float:__sin(plid, num)
{
new Float:value = get_param_f(1)
return floatsin(value, radian)
}
public Float:__sinh(plid, num)
{
new Float:value = get_param_f(1)
return floatsinh(value, radian)
}
public Float:__acos(plid, num)
{
new Float:value = get_param_f(1)
return floatacos(value, radian)
}
public Float:__cos(plid, num)
{
new Float:value = get_param_f(1)
return floatcos(value, radian)
}
public Float:__cosh(plid, num)
{
new Float:value = get_param_f(1)
return floatcosh(value, radian)
}
public Float:__atan(plid, num)
{
new Float:value = get_param_f(1)
return floatatan(value, radian)
}
public Float:__atan2(plid, num)
{
new Float:value1 = get_param_f(1)
new Float:value2 = get_param_f(2)
return floatatan2(value1, value2, radian)
}
public Float:__tan(plid, num)
{
new Float:value = get_param_f(1)
return floattan(value, radian)
}
public Float:__tanh(plid, num)
{
new Float:value = get_param_f(1)
return floattanh(value, radian)
}
public Float:__fsqroot(plid, num)
{
new Float:value = get_param_f(1)
return floatsqroot(value)
}
public Float:__fpower(plid, num)
{
new Float:value = get_param_f(1)
new Float:exponent = get_param_f(2)
return floatpower(value, exponent)
}
public Float:__flog(plid, num)
{
new Float:value = get_param_f(1)
new Float:base = get_param_f(2)
return floatlog(value, base)
}
//get_cmdaccess(cmd[], accessflags[], len)
public __get_cmdaccess(plid, num)
{
static command[32], accessflags[32]
new ret
get_string(1, command, 31)
if ((ret=get_cmdaccess(command, accessflags, 31)))
{
set_string(2, accessflags, get_param(3))
}
return ret
}
public __is_translated(plid, num)
{
static string[512]
get_string(1, string, 511)
return is_translated(string)
}
public __get_plugincmdsnum(plid, num)
{
static plugin[64]
get_string(1, plugin, 63)
return get_plugincmdsnum(plugin, get_param(2))
}
public __get_plugincmd(plid, num)
{
static plugin[64]
static command[32]
static accessflags[32]
static info[512]
get_string(1, plugin, 63)
if (get_plugincmd(plugin,
get_param(2),
command,
31,
accessflags,
31,
info,
511,
get_param(9),
get_param(10)))
{
set_string(3, command, get_param(4))
set_string(5, accessflags, get_param(6))
set_string(7, info, get_param(8))
return 1
}
return 0
}
public __get_plugincvarsnum(plid, num)
{
static plugin[64]
get_string(1, plugin, 63)
return get_plugincvarsnum(plugin, get_param(2))
}
//stock get_plugincvar(plugin[], index, cvar[], len1, value[], len2, flags=0)
public __get_plugincvar(plid, num)
{
static plugin[64]
static cvar[32]
static value[512]
get_string(1, plugin, 63)
if (get_plugincvar(plugin, get_param(2), cvar, 31, value, 511, get_param(7)))
{
set_string(3, cvar, get_param(4))
set_string(5, value, get_param(6))
return 1
}
return 0
}
public __is_module_running(plid, num)
{
static module[64]
get_string(1, module, 63)
return is_module_running(module)
}
public __is_plugin_running(plid, num)
{
static plugin[64]
get_string(1, plugin, 63)
return is_plugin_running(plugin)
}

View File

@@ -0,0 +1,415 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
#define MAX_CONNECTIONS 64
new Connections[MAX_CONNECTIONS+1] = {0}
new ConnectionTracker[MAX_CONNECTIONS+1] = {0}
new ConnectionErrors[MAX_CONNECTIONS+1][255]
new ConnectionQueries[MAX_CONNECTIONS+1] = {0}
new QueryPositions[MAX_CONNECTIONS+1]
MySQL_Natives()
{
register_native("mysql_connect", "__mysql_connect")
register_native("mysql_query", "__mysql_query")
register_native("mysql_error", "__mysql_error")
register_native("mysql_close", "__mysql_close")
register_native("mysql_nextrow", "__mysql_nextrow")
register_native("mysql_getfield", "__mysql_getfield")
register_native("mysql_getresult", "__mysql_getresult")
register_native("mysql_affected_rows", "__mysql_affected_rows")
register_native("mysql_num_fields", "__mysql_num_fields")
register_native("mysql_num_rows", "__mysql_num_rows")
register_native("mysql_field_name", "__mysql_field_name")
register_native("mysql_insert_id", "__mysql_insert_id")
}
MakeConnectionIndex(Handle:cn)
{
if (ConnectionTracker[0])
{
new idx = ConnectionTracker[ConnectionTracker[0]]
ConnectionTracker[0]--
Connections[idx] = _:cn
return idx
} else {
Connections[0]++
if (Connections[0] > MAX_CONNECTIONS)
{
return 0
}
Connections[Connections[0]] = _:cn
return Connections[0]
}
return 0
}
Handle:GetConnectionIndex(idx)
{
if (idx < 1 || idx > MAX_CONNECTIONS || !Connections[idx])
{
return Empty_Handle
}
return Handle:Connections[idx]
}
FreeConnectionIndex(idx)
{
Connections[idx] = 0
ConnectionTracker[0]++
ConnectionTracker[ConnectionTracker[0]] = idx
ConnectionErrors[idx][0] = 0
ConnectionQueries[idx] = 0
QueryPositions[idx] = 0
}
/*
* Unlike the previous this does not check for a matching connection.
* Unless a plugin breaks I'm not going to take that step.
*/
public __mysql_connect(plid, num)
{
static host[255], user[128], pass[128], dbname[128], error[512]
new errcode
get_string(1, host, 254)
get_string(2, user, 127)
get_string(3, pass, 127)
get_string(4, dbname, 127)
new Handle:info = SQL_MakeDbTuple(host, user, pass, dbname)
new Handle:cn = SQL_Connect(info, errcode, error, 511)
if (cn == Empty_Handle)
{
set_string(5, error, get_param(6))
return 0
}
SQL_FreeHandle(info)
new idx = MakeConnectionIndex(cn)
if (idx == 0)
{
set_string(5, "Reached max unclosed connections", get_param(6))
return 0
}
ConnectionQueries[idx] = 0
return idx
}
public __mysql_query(plid, num)
{
static queryString[4096]
new cn_idx = get_param(1)
new Handle:cn
if ((cn=GetConnectionIndex(cn_idx)) == Empty_Handle)
{
return 0
}
vdformat(queryString, 4095, 2, 3)
new Handle:query = SQL_PrepareQuery(cn, "%s", queryString)
if (!SQL_Execute(query))
{
SQL_QueryError(query, ConnectionErrors[cn_idx], 254)
SQL_FreeHandle(query)
return 0
}
if (ConnectionQueries[cn_idx])
{
SQL_FreeHandle(Handle:ConnectionQueries[cn_idx])
}
ConnectionQueries[cn_idx] = _:query
QueryPositions[cn_idx] = 0
return 1
}
public __mysql_error(plid, num)
{
new cn_idx = get_param(1)
if (Connections[cn_idx] < 1)
{
static error[255]
format(error, 254, "Invalid connection index: %d", cn_idx)
set_string(2, error, get_param(3))
return 1
}
set_string(2, ConnectionErrors[cn_idx], get_param(3))
return 1
}
public __mysql_close(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query != Empty_Handle)
{
SQL_FreeHandle(query)
}
SQL_FreeHandle(cn)
FreeConnectionIndex(cn_idx)
return 1
}
public __mysql_nextrow(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
if (QueryPositions[cn_idx] != 0)
{
SQL_NextRow(query)
}
if (SQL_MoreResults(query))
{
return ++QueryPositions[cn_idx]
}
return 0
}
public __mysql_getresult(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
if (!SQL_MoreResults(query))
{
return 0
}
static name[64]
get_string(2, name, 63)
new column = SQL_FieldNameToNum(query, name)
if (column == -1)
{
log_error(AMX_ERR_NATIVE, "Invalid column name: %s", name)
return 0
}
switch (num)
{
case 2:
{
return SQL_ReadResult(query, column)
}
case 3:
{
new Float:fma
SQL_ReadResult(query, column, fma)
set_param_byref(3, _:fma)
}
case 4:
{
static str[2048]
SQL_ReadResult(query, column, str, 2047)
set_string(3, str, get_param_byref(4))
}
}
return 1
}
public __mysql_getfield(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
if (!SQL_MoreResults(query))
{
return 0
}
switch (num)
{
case 2:
{
return SQL_ReadResult(query, get_param(2)-1)
}
case 3:
{
new Float:fma
SQL_ReadResult(query, get_param(2)-1, fma)
set_param_byref(3, _:fma)
}
case 4:
{
static str[2048]
SQL_ReadResult(query, get_param(2)-1, str, 2047)
set_string(3, str, get_param_byref(4))
}
}
return 1
}
public __mysql_affected_rows(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_AffectedRows(query)
}
public __mysql_num_fields(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_NumColumns(query)
}
public __mysql_insert_id(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_GetInsertId(query)
}
public __mysql_num_rows(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
return SQL_NumResults(query)
}
public __mysql_field_name(plid, num)
{
new cn_idx = get_param(1)
new Handle:cn = GetConnectionIndex(cn_idx)
if (cn == Empty_Handle)
{
return 0
}
new Handle:query = Handle:ConnectionQueries[cn_idx]
if (query == Empty_Handle)
{
return 0
}
new column = get_param(2) - 1
if (column < 0 || column >= SQL_NumColumns(query))
{
return 0
}
new field[64]
SQL_FieldNumToName(query, column, field, 63)
set_string(3, field, get_param(4))
return 1
}

View File

@@ -0,0 +1,730 @@
/**
* AMX Mod Compatibility engine
* by the AMX Mod X Development Team
*/
#include <VexdUM_const>
#include <VexdUM_stock>
/* Forwards */
new g_FwdTouch
new g_FwdThink
new g_FwdSpawn
new g_FwdClientPreThink
new g_FwdClientPostThink
new g_FwdEmitSound
new g_FwdEmitAmbientSound
new g_FwdSetModel
new g_FwdTraceLine
new g_FwdSetCliKeyValue
new g_FwdKeyValue
new g_PlayerModels[33][64]
new g_PlayerModeled[33]
/* User Messages */
new g_msgDamage
new g_msgDeathMsg
new g_msgScoreInfo
new g_LastTrace = 0
VexdUM_Register()
{
/* Fakemeta Hooks */
register_forward(FM_EmitSound, "Hook_FM_EmitSound")
register_forward(FM_EmitAmbientSound, "Hook_FM_EmitAmbientSound")
register_forward(FM_SetModel, "Hook_FM_SetModel")
register_forward(FM_SetClientKeyValue, "Hook_FM_SetClientKeyValue")
register_forward(FM_KeyValue, "Hook_FM_KeyValue")
register_forward(FM_Touch, "Hook_FM_Touch")
register_forward(FM_Think, "Hook_FM_Think")
register_forward(FM_Spawn, "Hook_FM_Spawn")
register_forward(FM_PlayerPreThink, "Hook_FM_PlayerPreThink")
register_forward(FM_PlayerPostThink, "Hook_FM_PlayerPostThink")
register_forward(FM_ClientUserInfoChanged, "Hook_ClientUserInfoChanged")
// Only register the traceline forward if there actually is a plugin
// that needs it. Otherwise this will mess with set_user_hitzones
new pluginnum = get_pluginsnum();
for (new i = 0; i < pluginnum; i++)
{
if (plugin_flags(0, i) & AMX_FLAG_OLDFILE && // plugin is an AMX plugin being emulated
get_func_id("traceline", i) != -1) // plugin needs traceline
{
register_forward(FM_TraceLine, "Hook_FM_TraceLine")
break;
}
}
/* Global Forwards */
g_FwdTouch = CreateMultiForwardEx("entity_touch", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_CELL)
g_FwdThink = CreateMultiForwardEx("entity_think", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
g_FwdSpawn = CreateMultiForwardEx("entity_spawn", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
g_FwdClientPreThink = CreateMultiForwardEx("client_prethink", ET_IGNORE, FORWARD_ONLY_OLD, FP_CELL)
g_FwdClientPostThink = CreateMultiForwardEx("client_postthink", ET_IGNORE, FORWARD_ONLY_OLD, FP_CELL)
g_FwdEmitSound = CreateMultiForwardEx("emitsound", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING)
g_FwdEmitAmbientSound = CreateMultiForwardEx("emitambientsound", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING)
g_FwdSetModel = CreateMultiForwardEx("set_model", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING)
g_FwdTraceLine = CreateMultiForwardEx("traceline", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
g_FwdSetCliKeyValue = CreateMultiForwardEx("setclientkeyvalue", ET_STOP, FORWARD_ONLY_OLD, FP_CELL, FP_STRING, FP_STRING)
g_FwdKeyValue = CreateMultiForwardEx("keyvalue", ET_STOP, FORWARD_ONLY_OLD, FP_CELL)
/* User Messages */
g_msgDamage = get_user_msgid("Damage")
g_msgDeathMsg = get_user_msgid("DeathMsg")
g_msgScoreInfo = get_user_msgid("ScoreInfo")
}
VexdUM_Natives()
{
/* implicit compatibility */
register_native("is_entity", "__is_entity")
register_native("find_entity", "__find_entity")
register_native("find_entity_sphere", "__find_entity_sphere")
register_native("in_view_cone", "__in_view_cone")
register_native("get_offset_int", "__get_offset_int")
register_native("set_offset_int", "__set_offset_int")
register_native("trace_line", "__trace_line")
register_native("traceline_get_int", "__traceline_get_int")
register_native("traceline_set_int", "__traceline_set_int")
register_native("traceline_get_edict", "__traceline_get_edict")
register_native("traceline_set_edict", "__traceline_set_edict")
register_native("traceline_set_float", "__traceline_set_float")
register_native("can_see", "__can_see")
register_native("user_spawn", "__user_spawn")
register_native("get_maxentities", "__get_maxentities")
register_native("PointContents", "__PointContents")
register_native("DispatchKeyValue", "__DispatchKeyValue")
register_native("entity_use","__entity_use")
register_native("get_num_ents","__get_num_ents")
register_native("take_damage","__take_damage")
if (g_ModType == MOD_CSTRIKE)
{
register_native("set_user_model", "__cs_set_user_model")
} else {
register_native("set_user_model", "__set_user_model")
}
}
VexdUM_ClientConnect(id)
{
g_PlayerModels[id][0] = 0
g_PlayerModeled[id] =0
}
SetClientKeyValue(id, const key[], const value[])
{
new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id)
return engfunc(EngFunc_SetClientKeyValue, id, buffer, key, value)
}
GetClientKeyValue(id, const key[], value[], maxlen)
{
new buffer = engfunc(EngFunc_GetInfoKeyBuffer, id)
engfunc(EngFunc_InfoKeyValue, buffer, key, value, maxlen)
}
Death(victim, killer, weapon[64], hs)
{
if(pev(victim,pev_takedamage) > DAMAGE_NO)
{
new inflictor = pev(killer,pev_owner)
if(pev(killer,pev_flags) & (FL_CLIENT | FL_FAKECLIENT))
{
if(equal(weapon,""))
{
pev(killer,pev_viewmodel2,weapon,63)
replace(weapon,63,"models/v_","")
weapon[strlen(weapon) - 4] = '^0'
}
}
else if(inflictor > 0 && inflictor < get_maxplayers())
{
if(equal(weapon,""))
{
pev(killer,pev_viewmodel2,weapon,63)
replace(weapon,63,"weapon_","")
replace(weapon,63,"monster_","")
replace(weapon,63,"func_","")
}
if(inflictor == victim)
{
killer = victim
} else {
killer = inflictor
}
}
message_begin(MSG_ALL,g_msgDeathMsg)
write_byte(killer)
write_byte(victim)
write_byte(hs)
write_string(weapon)
message_end()
new vname[32],vauthid[32],vteam[32]
get_user_name(victim,vname,31)
get_user_authid(victim,vauthid,31)
get_user_team(victim,vteam,31)
if(victim == killer)
{
log_message("^"%s<%i><%s><%s>^" killed self with ^"%s^"^n",vname,get_user_userid(victim),
vauthid,vteam,weapon)
}
else if(pev(killer,pev_flags) & (FL_CLIENT | FL_FAKECLIENT))
{
new kname[32],kauthid[32],kteam[32],team
get_user_name(killer,kname,31)
get_user_authid(killer,kauthid,31)
team = get_user_team(killer,kteam,31)
log_message("^"%s<%i><%s><%s>^" killed ^"%s<%i><%s><%s>^" with ^"%s^"^n",kname,get_user_userid(killer),
kauthid,kteam,vname,get_user_userid(victim),vauthid,vteam,weapon)
new Float:frags
pev(killer,pev_frags,frags)
set_pev(killer,pev_frags,frags+1.0)
message_begin(MSG_ALL,g_msgScoreInfo)
write_byte(killer)
write_short(floatround(frags))
write_short(get_user_deaths(killer))
write_short(0)
write_short(team)
message_end()
pev(victim,pev_frags,frags)
set_pev(victim,pev_frags,frags+1.0)
} else {
log_message("^"%s<%i><%s><%s>^" killed by ^"%s^"^n",vname,get_user_userid(victim),vauthid,vteam,weapon)
}
set_msg_block(g_msgDeathMsg,BLOCK_ONCE)
dllfunc(DLLFunc_ClientKill,victim)
}
}
public __is_entity(plid, num)
{
new ent = get_param(1)
return is_entity(ent)
}
public __find_entity(plid, num)
{
static entstr[256]
new startEnt, type
startEnt = get_param(1)
get_string(2, entstr, 255)
type = get_param(3)
return find_entity(startEnt, entstr, type)
}
public __find_entity_sphere(plid, num)
{
new ent
new Float:orig[3]
new Float:radius
ent = get_param(1)
get_array_f(2, orig, 3)
radius = get_param_f(3)
return find_entity_sphere(ent, orig, radius)
}
public __in_view_cone(plid, num)
{
new ent
new Float:orig[3]
ent = get_param(1)
get_array_f(2, orig, 3)
return in_view_cone(ent, orig)
}
public __get_offset_int(plid, num)
{
new ent = get_param(1)
new offs = get_param(2)
new linux = get_param(3)
return get_pdata_int(ent, offs, linux)
}
public __set_offset_int(plid, num)
{
return set_offset_int(get_param(1), get_param(2), get_param(3), get_param(4))
}
public __trace_line(plid, num)
{
new ent = get_param(1)
new Float:vStart[3], Float:vEnd[3], Float:vReturn[3]
get_array_f(2, vStart, 3)
get_array_f(3, vEnd, 3)
if (ent == FM_NULLENT)
engfunc(EngFunc_TraceLine, vStart, vEnd, IGNORE_MONSTERS, 0, 0)
else
engfunc(EngFunc_TraceLine, vStart, vEnd, DONT_IGNORE_MONSTERS, ent, 0)
get_tr2(0, TraceResult:TR_vecEndPos, vReturn)
set_array_f(4, vReturn, 3)
new traceHit = get_tr2(0, TraceResult:TR_pHit)
if (!pev_valid(traceHit))
return FM_NULLENT
return traceHit
}
public __traceline_get_int(plid, num)
{
new iSet = get_param(1)
new iValue = 0
switch (iSet)
{
case TR_INT_fAllSolid:
iValue = get_tr2(g_LastTrace, TraceResult:TR_AllSolid)
case TR_INT_fStartSolid:
iValue = get_tr2(g_LastTrace, TraceResult:TR_StartSolid)
case TR_INT_fInOpen:
iValue = get_tr2(g_LastTrace, TraceResult:TR_InOpen)
case TR_INT_fInWater:
iValue = get_tr2(g_LastTrace, TraceResult:TR_InWater)
case TR_INT_iHitgroup:
iValue = get_tr2(g_LastTrace, TraceResult:TR_iHitgroup)
default:
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
}
return iValue
}
public __traceline_set_int(plid, num)
{
new iSet = get_param(1)
new iValue = get_param(2)
switch (iSet)
{
case TR_INT_fAllSolid:
set_tr2(g_LastTrace, TraceResult:TR_AllSolid, iValue)
case TR_INT_fStartSolid:
set_tr2(g_LastTrace, TraceResult:TR_StartSolid, iValue)
case TR_INT_fInOpen:
set_tr2(g_LastTrace, TraceResult:TR_InOpen, iValue)
case TR_INT_fInWater:
set_tr2(g_LastTrace, TraceResult:TR_InWater, iValue)
case TR_INT_iHitgroup:
set_tr2(g_LastTrace, TraceResult:TR_iHitgroup, iValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public __traceline_get_edict(plid, num)
{
new iSet = get_param(1)
new iValue = 0
switch (iSet)
{
case TR_ENT_pHit:
iValue = get_tr2(g_LastTrace, TraceResult:TR_pHit)
default:
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
}
return iValue
}
public __traceline_set_edict(plid, num)
{
new iSet = get_param(1)
new iValue = get_param(2)
switch (iSet)
{
case TR_ENT_pHit:
set_tr2(g_LastTrace, TraceResult:TR_pHit, iValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public Float:__traceline_get_float(plid, num)
{
new iSet = get_param(1)
new Float:fValue = 0.0
switch (iSet)
{
case TR_FL_flFraction:
get_tr2(g_LastTrace, TraceResult:TR_flFraction, fValue)
case TR_FL_flPlaneDist:
get_tr2(g_LastTrace, TraceResult:TR_flPlaneDist, fValue)
default:
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
}
return fValue
}
public __traceline_set_float(plid, num)
{
new iSet = get_param(1)
new Float:fValue = get_param_f(2)
switch (iSet)
{
case TR_FL_flFraction:
set_tr2(g_LastTrace, TraceResult:TR_flFraction, fValue)
case TR_FL_flPlaneDist:
set_tr2(g_LastTrace, TraceResult:TR_flPlaneDist, fValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public __traceline_get_vector(plid, num)
{
new iSet = get_param(1)
new Float:vValue[3]
switch (iSet)
{
case TR_VEC_vecEndPos:
get_tr2(g_LastTrace, TraceResult:TR_vecEndPos, vValue)
case TR_VEC_vecPlaneNormal:
get_tr2(g_LastTrace, TraceResult:TR_vecPlaneNormal, vValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
set_array_f(2, vValue, 3)
return 1
}
public __traceline_set_vector(plid, num)
{
new iSet = get_param(1)
new Float:vValue[3]
get_array_f(2, vValue, 3)
switch (iSet)
{
case TR_VEC_vecEndPos:
set_tr2(g_LastTrace, TraceResult:TR_vecEndPos, vValue)
case TR_VEC_vecPlaneNormal:
set_tr2(g_LastTrace, TraceResult:TR_vecPlaneNormal, vValue)
default:
{
log_error(AMX_ERR_NATIVE, "Invalid TR_ parameter")
return 0
}
}
return 1
}
public __can_see(plid, num)
{
return can_see(get_param(1), get_param(2))
}
public __user_spawn(plid, num)
{
return dllfunc(DLLFunc_Spawn, get_param(1))
}
public __set_user_model(plid, num)
{
new id = get_param(1)
if (id < 1 || id > g_MaxPlayers)
{
return 0
}
new model[64]
get_string(2, model, 63)
if (model[0] == 0)
{
if (!g_PlayerModeled[id])
{
return 0
}
g_PlayerModeled[id] = 0
g_PlayerModels[id][0] = 0
dllfunc(DLLFunc_ClientUserInfoChanged, id)
} else {
copy(g_PlayerModels[id], 63, model)
g_PlayerModeled[id] = 1
SetClientKeyValue(id, "model", model)
}
return 1
}
public __cs_set_user_model(plid, num)
{
new id = get_param(1)
new model[64]
get_string(2, model, 63)
return cs_set_user_model(id, model)
}
public __get_maxentities(plid, num)
{
return get_maxentities()
}
public __PointContents(plid, num)
{
new Float:vCheckAt[3]
get_array_f(1, vCheckAt, 3)
return point_contents(vCheckAt)
}
public __DispatchKeyValue(plid, num)
{
new ent = get_param(1)
new szClassname[32], szKey[32], szValue[32]
if (pev_valid(ent))
{
get_string(2, szKey, 31)
get_string(3, szValue, 31)
pev(ent, pev_classname, szClassname, 31)
set_kvd(0, KV_ClassName, szClassname)
set_kvd(0, KV_KeyName, szKey)
set_kvd(0, KV_Value, szValue)
set_kvd(0, KV_fHandled, 0)
dllfunc(DLLFunc_KeyValue, ent, 0)
}
return 1
}
public __entity_use(plid, num)
{
new entUsed = get_param(1)
new entOther = get_param(2)
return dllfunc(DLLFunc_Use,entUsed,entOther)
}
public __get_num_ents(plid, num)
{
return engfunc(EngFunc_NumberOfEntities)
}
public __take_damage(plid, num)
{
new victim = get_param(1)
new attacker = get_param(2)
new Float:orig[3]
get_array_f(3,orig,3)
new Float:dmg = get_param_f(4)
new bit = get_param(5)
new wpnName[64]
get_string(6,wpnName,63)
new hs = get_param(7)
if(pev(victim,pev_takedamage) > DAMAGE_NO)
{
set_pev(victim,pev_dmg_inflictor,attacker)
new Float:olddmg
pev(victim,pev_dmg_take,olddmg)
set_pev(victim,pev_dmg_take,olddmg+dmg)
message_begin(MSG_ONE, g_msgDamage, {0,0,0} , victim)
write_byte(0)
write_byte(floatround(olddmg+dmg))
write_long(bit)
write_coord(floatround(orig[0]))
write_coord(floatround(orig[1]))
write_coord(floatround(orig[2]))
message_end()
new Float:health
pev(victim,pev_health,health)
if((dmg >= health) && (health > 0.0))
{
Death(victim,attacker,wpnName,hs)
} else {
set_pev(victim,pev_health,health-dmg)
}
}
}
/*********************************
***** HOOKS *********************
*********************************/
public Hook_ClientUserInfoChanged(id, buffer)
{
if (g_PlayerModeled[id] && (pev(id, pev_deadflag) == DEAD_NO))
{
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public Hook_FM_EmitSound(entid, channel, const sample[]) //we don't care about the rest
{
new ret
ExecuteForward(g_FwdEmitSound, ret, entid, sample)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_EmitAmbientSound(entid, Float:pos[3], const sample[]) //we don't care about the rest
{
new ret
ExecuteForward(g_FwdEmitAmbientSound, ret, entid, sample)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_SetModel(entid, const model[])
{
new ret
ExecuteForward(g_FwdSetModel, ret, entid, model)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_TraceLine(Float:v1[3], Float:v2[3], noMonsters, skip_ent, ptr)
{
g_LastTrace = ptr
engfunc(EngFunc_TraceLine, v1, v2, noMonsters, skip_ent, ptr)
new ret
ExecuteForward(g_FwdTraceLine, ret, skip_ent)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_SetClientKeyValue(id, const infobuffer[], const key[], const value[])
{
new ret
ExecuteForward(g_FwdSetCliKeyValue, ret, id, key, value)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_KeyValue(ent, kvd)
{
new ret
ExecuteForward(g_FwdKeyValue, ret, ent)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_Touch(ent1, ent2)
{
new ret
ExecuteForward(g_FwdTouch, ret, ent1, ent2)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_Think(entid)
{
new ret
ExecuteForward(g_FwdThink, ret, entid)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_Spawn(entid)
{
new ret
ExecuteForward(g_FwdSpawn, ret, entid)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_PlayerPreThink(id)
{
new ret
ExecuteForward(g_FwdClientPreThink, ret, id)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}
public Hook_FM_PlayerPostThink(id)
{
new ret
if (g_PlayerModeled[id])
{
new model[64]
GetClientKeyValue(id, "model", model, 63)
if (!equal(g_PlayerModels[id], model))
{
SetClientKeyValue(id, "model", g_PlayerModels[id])
}
}
ExecuteForward(g_FwdClientPostThink, ret, id)
return (ret == PLUGIN_HANDLED) ? FMRES_SUPERCEDE : FMRES_IGNORED
}

Binary file not shown.

View File

@@ -0,0 +1,78 @@
/* AMX Mod X
* Anti Flood Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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>
new Float:g_Flooding[33] = {0.0, ...}
new g_Flood[33] = {0, ...}
new amx_flood_time;
public plugin_init()
{
register_plugin("Anti Flood", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("antiflood.txt")
register_clcmd("say", "chkFlood")
register_clcmd("say_team", "chkFlood")
amx_flood_time=register_cvar("amx_flood_time", "0.75")
}
public chkFlood(id)
{
new Float:maxChat = get_pcvar_float(amx_flood_time)
if (maxChat)
{
new Float:nexTime = get_gametime()
if (g_Flooding[id] > nexTime)
{
if (g_Flood[id] >= 3)
{
client_print(id, print_notify, "** %L **", id, "STOP_FLOOD")
g_Flooding[id] = nexTime + maxChat + 3.0
return PLUGIN_HANDLED
}
g_Flood[id]++
}
else if (g_Flood[id])
{
g_Flood[id]--
}
g_Flooding[id] = nexTime + maxChat
}
return PLUGIN_CONTINUE
}

View File

@@ -0,0 +1,494 @@
/* AMX Mod X
* Commands Menu Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
// Precache sounds from speech.ini - comment this line to disable
#define PRECACHE_SPEECHINI
/* Commands Menus */
#define MAX_CMDS_LAYERS 3
new g_cmdMenuName[MAX_CMDS_LAYERS][] =
{
"CMD_MENU",
"CONF_MENU",
"SPE_MENU"
}
new g_cmdMenuCmd[MAX_CMDS_LAYERS][] =
{
"amx_cmdmenu",
"amx_cfgmenu",
"amx_speechmenu"
}
new g_cmdMenuCfg[MAX_CMDS_LAYERS][] =
{
"cmds.ini",
"configs.ini",
"speech.ini"
}
new g_cmdMenuHelp[MAX_CMDS_LAYERS][] =
{
"- displays commands menu",
"- displays configs menu",
"- displays speech menu"
}
/* End of Commands Menu */
#define MAX_CMDS 64
#define MAX_CVARS 48
new g_cmdName[MAX_CMDS*MAX_CMDS_LAYERS][32]
new g_cmdCmd[MAX_CMDS*MAX_CMDS_LAYERS][64]
new g_cmdMisc[MAX_CMDS*MAX_CMDS_LAYERS][2]
new g_cmdNum[MAX_CMDS_LAYERS]
new g_cvarNames[MAX_CVARS][32]
new g_cvarMisc[MAX_CVARS][3]
new g_cvarCmd[MAX_CVARS*5][32]
new g_cvarCmdNum
new g_cvarNum
new g_menuPosition[33]
new g_menuSelect[33][MAX_CMDS]
new g_menuSelectNum[33]
new g_menuLayer[33]
new g_coloredMenus
public plugin_init()
{
register_plugin("Commands Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("cmdmenu.txt")
register_dictionary("common.txt")
new configsDir[64], config[64]
get_configsdir(configsDir, 63)
for (new a = 0; a < MAX_CMDS_LAYERS; ++a)
{
new MenuName[64]
format(MenuName, 63, "%L", "en", g_cmdMenuName[a])
register_menucmd(register_menuid(MenuName), 1023, "actionCmdMenu")
register_clcmd(g_cmdMenuCmd[a], "cmdCmdMenu", ADMIN_MENU, g_cmdMenuHelp[a])
format(config, 63, "%s/%s", configsDir, g_cmdMenuCfg[a])
loadCmdSettings(config, a)
}
register_menucmd(register_menuid("Cvars Menu"), 1023, "actionCvarMenu")
register_clcmd("amx_cvarmenu", "cmdCvarMenu", ADMIN_CVAR, "- displays cvars menu")
new cvars_ini_file[64];
format(cvars_ini_file, 63, "%s/%s", configsDir, "cvars.ini");
loadCvarSettings(cvars_ini_file)
g_coloredMenus = colored_menus()
}
#if defined PRECACHE_SPEECHINI
public plugin_precache( )
{
new configsDir[64], config[64];
get_configsdir( configsDir, 63 );
formatex( config, 63, "%s/%s", configsDir, "speech.ini" );
new fp = fopen( config, "rt" ); // Read file as text
if ( ! fp ) // File doesn't exists
return 0;
new szText[256];
new line = 0;
new szName[32], szSound[128], sndExt[5];
new field1[32], field2[64], field3[64];
new fieldNums = 0;
while ( line < MAX_CMDS && ! feof( fp ) ) // Loop till MAX_CMDS or EOF
{
fgets( fp, szText, 255 ); // Store line content
/* Strips newline */
new len = strlen( szText );
if ( len != 0 && szText[len-1] == '^n' ) // len != 0 because if the last line of the file is empty, there's no newline
szText[--len] = 0;
if ( len == 0 || szText[0] == ';' || szText[0] == '/' ) // Line is empty or a comment
continue;
parse( szText, szName, 31, szSound, 127 );
fieldNums = parse( szSound, field1, 31, field2, 63, field3, 63 );
if ( fieldNums == 2 && field1[0] == 's' ) // .wav (spk)
{
copy( szSound, 127, field2 );
copy( sndExt, 4, ".wav" );
}
else if ( fieldNums == 3 && field1[0] == 'm' && ( field2[0] == 'p' || field2[0] == 'l' ) ) // .mp3 (mp3 play | mp3 loop)
{
copy( szSound, 127, field3 );
copy( sndExt, 4, ".mp3" );
}
else // WTH is this sound, drop it.
continue;
replace_all( szSound, 127, "\'", "" ); // Strips all ugly (and sometimes useless) \'
if ( szSound[0] == '/' )
replace( szSound, 127, "/", "" ); // Strip leading slash
if ( sndExt[1] == 'm' || ( ! equali( szSound, "vox", 3 ) && ! equali( szSound, "fvox", 4 ) && ! equali( szSound, "barney", 6 ) && ! equali( szSound, "hgrunt", 6 ) ) )
{
// SzSound is a mp3, or a custom wav (not a vox, fvox, or default sound from HL pak)
if ( !equali( szSound[strlen(szSound)-4], sndExt ) )
add( szSound, 127, sndExt ); // Add filetype extension if it isn't already specified
if ( sndExt[1] == 'w' )
format( szSound, 127, "sound/%s", szSound ); // spk basedir is $moddir/sound, but mp3 play is $moddir, fix this for the file_exists check
if ( file_exists( szSound ) )
{
if ( sndExt[1] == 'm')
{
precache_generic( szSound ); // mp3
}
else
{
replace( szSound, 127, "sound/", "" ); // wav, strip the leading sound/ we added for our file_exists check
precache_sound( szSound );
}
}
}
line++
}
fclose( fp ); // Close file
return line;
}
#endif
/* Commands menu */
public actionCmdMenu(id, key)
{
switch (key)
{
case 8: displayCmdMenu(id, ++g_menuPosition[id])
case 9: displayCmdMenu(id, --g_menuPosition[id])
default:
{
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
new flags = g_cmdMisc[option][1]
if (flags & 1)
server_cmd("%s", g_cmdCmd[option])
else if (flags & 2)
client_cmd(id, "%s", g_cmdCmd[option])
else if (flags & 4)
client_cmd(0, "%s", g_cmdCmd[option])
if (flags & 8)
displayCmdMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayCmdMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
new limit = (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8)))
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, g_cmdMenuName[g_menuLayer[id]], pos + 1, (limit == 0) ? 1 : limit)
new end = start + 8
new keys = MENU_KEY_0
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for (new a = start; a < end; ++a)
{
if (g_cmdCmd[g_menuSelect[id][a]][0] == '-')
{
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%s^n\w", g_cmdName[g_menuSelect[id][a]])
else
len += format(menuBody[len], 511-len, "%s^n", g_cmdName[g_menuSelect[id][a]])
++b
} else {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_cmdName[g_menuSelect[id][a]])
}
}
if (end != g_menuSelectNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
new MenuName[64]
format(MenuName, 63, "%L", "en", g_cmdMenuName[g_menuLayer[id]])
show_menu(id, keys, menuBody, -1, MenuName)
}
public cmdCmdMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new szCmd[32]
read_argv(0, szCmd, 31)
new lvl = 0
while (lvl < MAX_CMDS_LAYERS)
{
if (equal(g_cmdMenuCmd[lvl], szCmd))
break
++lvl
}
g_menuLayer[id] = lvl
g_menuSelectNum[id] = 0
new a = lvl * MAX_CMDS
new d, c = 0
while (c < g_cmdNum[lvl])
{
d = a + c
if (access(id, g_cmdMisc[d][0]))
{
g_menuSelect[id][g_menuSelectNum[id]++] = d
}
++c
}
displayCmdMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
loadCmdSettings(szFilename[], level)
{
if (!file_exists(szFilename))
return 0
new text[256], szFlags[32], szAccess[32]
new a, pos = 0, c, d = level * MAX_CMDS
while (g_cmdNum[level] < MAX_CMDS && read_file(szFilename, pos++, text, 255, a))
{
if (text[0] == ';') continue
c = d + g_cmdNum[level]
if (parse(text, g_cmdName[c], 31, g_cmdCmd[c], 63, szFlags, 31, szAccess, 31) > 3)
{
while (replace(g_cmdCmd[c], 63, "\'", "^""))
{
// do nothing
}
g_cmdMisc[c][1] = read_flags(szFlags)
g_cmdMisc[c][0] = read_flags(szAccess)
g_cmdNum[level]++
}
}
return 1
}
/* Cvars menu */
public actionCvarMenu(id, key)
{
switch (key)
{
case 8: displayCvarMenu(id, ++g_menuPosition[id])
case 9: displayCvarMenu(id, --g_menuPosition[id])
default:
{
new option = g_menuSelect[id][g_menuPosition[id] * 8 + key]
new szValue[32]
get_cvar_string(g_cvarNames[option], szValue, 31)
new end = g_cvarMisc[option][2]
new start = g_cvarMisc[option][1]
for (new i = start; ; ++i)
{
if (i < end)
{
if (equal(szValue, g_cvarCmd[i]))
{
if (++i >= end)
{
i = start
}
set_cvar_string(g_cvarNames[option], g_cvarCmd[i])
break
}
} else {
set_cvar_string(g_cvarNames[option], g_cvarCmd[start])
break
}
}
displayCvarMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayCvarMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n", pos + 1, (g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
new szValue[64]
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for (new a = start; a < end; ++a)
{
get_cvar_string(g_cvarNames[g_menuSelect[id][a]], szValue, 31)
keys |= (1<<b)
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "%d. %s\R%s^n\w", b, g_cvarNames[g_menuSelect[id][a]], szValue)
else
len += format(menuBody[len], 511-len, "%d. %s %s^n", b, g_cvarNames[g_menuSelect[id][a]], szValue)
}
if (end != g_menuSelectNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody)
}
public cmdCvarMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
g_menuSelectNum[id] = 0
for (new a = 0; a < g_cvarNum; ++a)
if (access(id, g_cvarMisc[a][0]))
g_menuSelect[id][g_menuSelectNum[id]++] = a
displayCvarMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
loadCvarSettings(szFilename[])
{
if (!file_exists(szFilename))
return 0
new text[256], szValues[12][32]
new inum, a, pos = 0
new cvar_values = MAX_CVARS * 5
// a b c d
while (g_cvarNum < MAX_CVARS && read_file(szFilename, pos++, text, 255, a))
{
if (text[0] == ';') continue
inum = parse(text, g_cvarNames[g_cvarNum], 31,
szValues[0], 31, szValues[1], 31, szValues[2], 31,
szValues[3], 31, szValues[4], 31, szValues[5], 31,
szValues[6], 31, szValues[7], 31, szValues[8], 31,
szValues[9], 31, szValues[10], 31, szValues[11], 31)
inum -= 2
if (inum < 2) continue
g_cvarMisc[g_cvarNum][1] = g_cvarCmdNum
for (a = 0; a < inum && g_cvarCmdNum < cvar_values; ++a)
{
while (replace(szValues[a], 31, "\'", "^""))
{
// do nothing
}
copy(g_cvarCmd[g_cvarCmdNum], 31, szValues[a])
g_cvarCmdNum++
}
g_cvarMisc[g_cvarNum][2] = g_cvarCmdNum
g_cvarMisc[g_cvarNum][0] = read_flags(szValues[inum])
g_cvarNum++
}
return 1
}

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# AMX Mod X
#
# by the AMX Mod X Development Team
# originally developed by OLO
#
# This file is part of AMX Mod X.
# new code contributed by \malex\
test -e compiled || mkdir compiled
rm -f temp.txt
# Choose compiler binary
if test `uname` = "Darwin"; then
pc=./amxxpc_osx
else
pc=./amxxpc
fi
for sourcefile in *.sma
do
amxxfile="`echo $sourcefile | sed -e 's/\.sma$/.amxx/'`"
echo -n "Compiling $sourcefile ..."
$pc $sourcefile -ocompiled/$amxxfile >> temp.txt
echo "done"
done
less temp.txt
rm temp.txt

View File

@@ -0,0 +1,58 @@
/* AMX Mod X
* Rank Calculation
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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.
*/
/* File location: $moddir/addons/amxmodx/data/csstats.amxx */
#include <amxmodx>
/* Function calculates position in rank.
*
* Stats:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkills
* 4 - shots
* 5 - hits
* 6 - damage
* 7 - defusions
* 8 - defused
* 9 - plants
* 10 - explosions
*
* Returning cellmin as value in get_score function
* makes that rank won't be saved. */
public get_score(stats[11], body[8])
return stats[0] - stats[1] - stats[3] // kills - deaths - teamkills

View File

@@ -0,0 +1,143 @@
/* AMX Mod X
* Info. Messages Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
#define X_POS -1.0
#define Y_POS 0.20
#define HOLD_TIME 12.0
new Array:g_Values
new Array:g_Messages
new g_MessagesNum
new g_Current
#define charsof(%1) (sizeof(%1)-1)
new amx_freq_imessage;
public plugin_init()
{
g_Messages=ArrayCreate(384);
g_Values=ArrayCreate(3);
register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("imessage.txt")
register_dictionary("common.txt")
register_srvcmd("amx_imessage", "setMessage")
amx_freq_imessage=register_cvar("amx_freq_imessage", "10")
new lastinfo[8]
get_localinfo("lastinfomsg", lastinfo, 7)
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg", "")
}
public infoMessage()
{
if (g_Current >= g_MessagesNum)
g_Current = 0
// No messages, just get out of here
if (g_MessagesNum==0)
{
return;
}
new values[3];
new Message[384];
ArrayGetString(g_Messages, g_Current, Message, charsof(Message));
ArrayGetArray(g_Values, g_Current, values);
new hostname[64];
get_cvar_string("hostname", hostname, 63);
replace(Message, 380, "%hostname%", hostname);
set_hudmessage(values[0], values[1], values[2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, -1);
show_hudmessage(0, "%s", Message);
client_print(0, print_console, "%s", Message);
++g_Current;
new Float:freq_im = get_pcvar_float(amx_freq_imessage);
if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345);
}
public setMessage()
{
new Message[384];
remove_task(12345)
read_argv(1, Message, 380)
while (replace(Message, 380, "\n", "^n")) {}
new mycol[12]
new vals[3];
read_argv(2, mycol, 11) // RRRGGGBBB
vals[2] = str_to_num(mycol[6])
mycol[6] = 0
vals[1] = str_to_num(mycol[3])
mycol[3] = 0
vals[0] = str_to_num(mycol[0])
g_MessagesNum++
new Float:freq_im = get_pcvar_float(amx_freq_imessage)
ArrayPushString(g_Messages, Message);
ArrayPushArray(g_Values, vals);
if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)
return PLUGIN_HANDLED
}
public plugin_end()
{
new lastinfo[8]
num_to_str(g_Current, lastinfo, 7)
set_localinfo("lastinfomsg", lastinfo)
}

View File

@@ -0,0 +1,302 @@
/* AMX Mod X constants
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _amxconst_included
#endinput
#endif
#define _amxconst_included
#include <svn_version>
#define M_PI 3.1415926535
#define ADMIN_ALL 0 /* everyone */
#define ADMIN_IMMUNITY (1<<0) /* flag "a" */
#define ADMIN_RESERVATION (1<<1) /* flag "b" */
#define ADMIN_KICK (1<<2) /* flag "c" */
#define ADMIN_BAN (1<<3) /* flag "d" */
#define ADMIN_SLAY (1<<4) /* flag "e" */
#define ADMIN_MAP (1<<5) /* flag "f" */
#define ADMIN_CVAR (1<<6) /* flag "g" */
#define ADMIN_CFG (1<<7) /* flag "h" */
#define ADMIN_CHAT (1<<8) /* flag "i" */
#define ADMIN_VOTE (1<<9) /* flag "j" */
#define ADMIN_PASSWORD (1<<10) /* flag "k" */
#define ADMIN_RCON (1<<11) /* flag "l" */
#define ADMIN_LEVEL_A (1<<12) /* flag "m" */
#define ADMIN_LEVEL_B (1<<13) /* flag "n" */
#define ADMIN_LEVEL_C (1<<14) /* flag "o" */
#define ADMIN_LEVEL_D (1<<15) /* flag "p" */
#define ADMIN_LEVEL_E (1<<16) /* flag "q" */
#define ADMIN_LEVEL_F (1<<17) /* flag "r" */
#define ADMIN_LEVEL_G (1<<18) /* flag "s" */
#define ADMIN_LEVEL_H (1<<19) /* flag "t" */
#define ADMIN_MENU (1<<20) /* flag "u" */
#define ADMIN_ADMIN (1<<24) /* flag "y" */
#define ADMIN_USER (1<<25) /* flag "z" */
#define FLAG_KICK (1<<0) /* flag "a" */
#define FLAG_TAG (1<<1) /* flag "b" */
#define FLAG_AUTHID (1<<2) /* flag "c" */
#define FLAG_IP (1<<3) /* flag "d" */
#define FLAG_NOPASS (1<<4) /* flag "e" */
#define FLAG_CASE_SENSITIVE (1<<10) /* flag "k" */
#define PLUGIN_CONTINUE 0 /* Results returned by public functions */
#define PLUGIN_HANDLED 1 /* stop other plugins */
#define PLUGIN_HANDLED_MAIN 2 /* to use in client_command(), continue all plugins but stop the command */
/* Flags for register_cvar() */
#define FCVAR_ARCHIVE 1 /* set to cause it to be saved to vars.rc */
#define FCVAR_USERINFO 2 /* changes the client's info string */
#define FCVAR_SERVER 4 /* notifies players when changed */
#define FCVAR_EXTDLL 8 /* defined by external DLL */
#define FCVAR_CLIENTDLL 16 /* defined by the client dll */
#define FCVAR_PROTECTED 32 /* It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value */
#define FCVAR_SPONLY 64 /* This cvar cannot be changed by clients connected to a multiplayer server. */
#define FCVAR_PRINTABLEONLY 128 /* This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). */
#define FCVAR_UNLOGGED 256 /* If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log */
/* Id of weapons in CS */
#define CSW_P228 1
#define CSW_SCOUT 3
#define CSW_HEGRENADE 4
#define CSW_XM1014 5
#define CSW_C4 6
#define CSW_MAC10 7
#define CSW_AUG 8
#define CSW_SMOKEGRENADE 9
#define CSW_ELITE 10
#define CSW_FIVESEVEN 11
#define CSW_UMP45 12
#define CSW_SG550 13
#define CSW_GALI 14
#define CSW_GALIL 14
#define CSW_FAMAS 15
#define CSW_USP 16
#define CSW_GLOCK18 17
#define CSW_AWP 18
#define CSW_MP5NAVY 19
#define CSW_M249 20
#define CSW_M3 21
#define CSW_M4A1 22
#define CSW_TMP 23
#define CSW_G3SG1 24
#define CSW_FLASHBANG 25
#define CSW_DEAGLE 26
#define CSW_SG552 27
#define CSW_AK47 28
#define CSW_KNIFE 29
#define CSW_P90 30
#define CSW_VEST 31
#define CSW_VESTHELM 32
#define HIW_BERETTA 1
#define HIW_SPAS12 2
#define HIW_M4A1 3
#define HIW_MP5A4 4
#define HIW_MP5SD5 5
#define HIW_AK47 6
#define HIW_AKS74U 7
#define HIW_GLOCK 8
#define HIW_M11 9
#define HIW_M11SD 10
#define HIW_PSG1 11
#define HIW_ZASTAVA 12
#define HIW_M16A2 13
#define HIW_REMINGTON 14
#define HIW_NATOGREN 15
#define HIW_TANGOGREN 16
#define HIW_FLASHBANG 17
/* Parts of body for hits */
#define HIT_GENERIC 0 /* none */
#define HIT_HEAD 1
#define HIT_CHEST 2
#define HIT_STOMACH 3
#define HIT_LEFTARM 4
#define HIT_RIGHTARM 5
#define HIT_LEFTLEG 6
#define HIT_RIGHTLEG 7
/* Constants for emit_sound() */
/* Channels */
#define CHAN_AUTO 0
#define CHAN_WEAPON 1
#define CHAN_VOICE 2
#define CHAN_ITEM 3
#define CHAN_BODY 4
#define CHAN_STREAM 5 /* allocate stream channel from the static or dynamic area */
#define CHAN_STATIC 6 /* allocate channel from the static area */
#define CHAN_NETWORKVOICE_BASE 7 /* voice data coming across the network */
#define CHAN_NETWORKVOICE_END 500 /* network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). */
/* Attenuation values */
#define ATTN_NONE 0.00
#define ATTN_NORM 0.80
#define ATTN_IDLE 2.00
#define ATTN_STATIC 1.25
/* Pitch values */
#define PITCH_NORM 100 /* non-pitch shifted */
#define PITCH_LOW 95 /* other values are possible - 0-255, where 255 is very high */
#define PITCH_HIGH 120
/* Volume values */
#define VOL_NORM 1.0
/* Menu keys */
#define MENU_KEY_1 (1<<0)
#define MENU_KEY_2 (1<<1)
#define MENU_KEY_3 (1<<2)
#define MENU_KEY_4 (1<<3)
#define MENU_KEY_5 (1<<4)
#define MENU_KEY_6 (1<<5)
#define MENU_KEY_7 (1<<6)
#define MENU_KEY_8 (1<<7)
#define MENU_KEY_9 (1<<8)
#define MENU_KEY_0 (1<<9)
#define LANG_SERVER 0
#define LANG_PLAYER -1
/* Destination types for client_print() */
enum {
print_notify = 1,
print_console,
print_chat,
print_center,
};
/* Destination types for engclient_print() */
enum {
engprint_console = 0,
engprint_center,
engprint_chat,
};
/* Render for set_user_rendering() */
enum {
kRenderNormal = 0, /* src */
kRenderTransColor, /* c*a+dest*(1-a) */
kRenderTransTexture, /* src*a+dest*(1-a) */
kRenderGlow, /* src*a+dest -- No Z buffer checks */
kRenderTransAlpha, /* src*srca+dest*(1-srca) */
kRenderTransAdd, /* src*a+dest */
};
/* Fx for set_user_rendering() */
enum {
kRenderFxNone = 0,
kRenderFxPulseSlow,
kRenderFxPulseFast,
kRenderFxPulseSlowWide,
kRenderFxPulseFastWide,
kRenderFxFadeSlow,
kRenderFxFadeFast,
kRenderFxSolidSlow,
kRenderFxSolidFast,
kRenderFxStrobeSlow,
kRenderFxStrobeFast,
kRenderFxStrobeFaster,
kRenderFxFlickerSlow,
kRenderFxFlickerFast,
kRenderFxNoDissipation,
kRenderFxDistort, /* Distort/scale/translate flicker */
kRenderFxHologram, /* kRenderFxDistort + distance fade */
kRenderFxDeadPlayer, /* kRenderAmt is the player index */
kRenderFxExplode, /* Scale up really big! */
kRenderFxGlowShell, /* Glowing Shell */
kRenderFxClampMinScale, /* Keep this sprite from getting very small (SPRITES only!) */
};
/* Type for force_unmodified() */
enum {
force_exactfile = 0, /* File on client must exactly match server's file */
force_model_samebounds, /* For model files only, the geometry must fit in the same bbox */
force_model_specifybounds, /* For model files only, the geometry must fit in the specified bbox */
};
/* Status for get_module() */
enum {
module_none = 0,
module_query,
module_badload,
module_loaded,
module_noinfo,
module_noquery,
module_noattach,
module_old,
};
#define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */
#define AMX_FLAG_COMPACT 0x04 /* compact encoding */
#define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */
#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */
#define AMX_FLAG_OLDFILE 0x20 /* Old AMX Mod plugin */
#define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */
#define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */
#define AMX_FLAG_BROWSE 0x4000 /* busy browsing */
#define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */
#define INVALID_PLUGIN_ID -1
#define MENU_EXIT -3
#define MENU_BACK -2
#define MENU_MORE -1
#define ITEM_IGNORE 0
#define ITEM_ENABLED 1
#define ITEM_DISABLED 2
#define AMX_ERR_NATIVE 10
#define AMX_ERR_MEMACCESS 5
#define AMX_ERR_NONE 0
#define AMX_ERR_BOUNDS 4
#define AMX_ERR_STACKERR 3
#define AMX_ERR_STACKLOW 7
#define AMX_ERR_HEAPLOW 8
#define AMX_ERR_DIVIDE 11
#define AMX_ERR_NOTFOUND 19
#define AMX_ERR_PARAMS 25
#define AMX_ERR_GENERAL 27
#define INVALID_HANDLE -1
#define ET_IGNORE 0 //ignore return val
#define ET_STOP 1 //stop on PLUGIN_HANDLED
#define ET_STOP2 2 //same, except return biggest
#define ET_CONTINUE 3 //no stop, return biggest
#define FP_CELL 0
#define FP_FLOAT 1
#define FP_STRING 2
#define FP_ARRAY 4
#define FORWARD_ONLY_OLD 1
#define FORWARD_ONLY_NEW 2
#define FORWARD_ALL 3
#define SND_SPAWNING (1<<8) // we're spawing, used in some cases for ambients
#define SND_STOP (1<<5) // stop sound
#define SND_CHANGE_VOL (1<<6) // change sound vol
#define SND_CHANGE_PITCH (1<<7) // change sound pitch
enum LibType
{
LibType_Library,
LibType_Class
};
enum AdminProp
{
AdminProp_Auth = 0,
AdminProp_Password,
AdminProp_Access,
AdminProp_Flags
};

View File

@@ -0,0 +1,622 @@
/* AMX Mod X misc.
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _amxmisc_included
#endinput
#endif
#define _amxmisc_included
#if !defined _amxmodx_included
#if defined AMXMOD_BCOMPAT
#include <amxmod>
#else
#include <amxmodx>
#endif
#endif
#if defined AMXMOD_BCOMPAT
#if defined _translator_included
#define SIMPLE_T(%1) _T(%1)
#else
#define SIMPLE_T(%1) %1
#endif
#endif
stock is_user_admin(id)
{
new __flags=get_user_flags(id);
return (__flags>0 && !(__flags&ADMIN_USER));
}
stock cmd_access(id, level, cid, num, bool:accesssilent = false)
{
new has_access = 0;
if ( id==(is_dedicated_server()?0:1) )
{
has_access = 1;
}
else if ( level==ADMIN_ADMIN )
{
if ( is_user_admin(id) )
{
has_access = 1;
}
}
else if ( get_user_flags(id) & level )
{
has_access = 1;
}
else if (level == ADMIN_ALL)
{
has_access = 1;
}
if ( has_access==0 )
{
if (!accesssilent)
{
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("You have no access to that command."));
#else
console_print(id,"%L",id,"NO_ACC_COM");
#endif
}
return 0;
}
if (read_argc() < num)
{
new hcmd[32], hinfo[128], hflag;
get_concmd(cid,hcmd,31,hflag,hinfo,127,level);
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("Usage: %s %s"), hcmd, SIMPLE_T(hinfo));
#else
console_print(id,"%L: %s %s",id,"USAGE",hcmd,hinfo);
#endif
return 0;
}
return 1;
}
stock access(id,level)
{
if (level==ADMIN_ADMIN)
{
return is_user_admin(id);
}
else if (level==ADMIN_ALL)
{
return 1;
}
return (get_user_flags(id) & level);
}
/* Flags:
* 1 - obey immunity
* 2 - allow yourself
* 4 - must be alive
* 8 - can't be bot */
#define CMDTARGET_OBEY_IMMUNITY (1<<0)
#define CMDTARGET_ALLOW_SELF (1<<1)
#define CMDTARGET_ONLY_ALIVE (1<<2)
#define CMDTARGET_NO_BOTS (1<<3)
stock cmd_target(id,const arg[],flags = CMDTARGET_OBEY_IMMUNITY)
{
new player = find_player("bl",arg);
if (player)
{
if ( player != find_player("blj",arg) )
{
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("There are more clients matching to your argument"));
#else
console_print(id,"%L",id,"MORE_CL_MATCHT");
#endif
return 0;
}
}
else if ( ( player = find_player("c",arg) )==0 && arg[0]=='#' && arg[1] )
{
player = find_player("k",str_to_num(arg[1]));
}
if (!player)
{
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("Client with that name or userid not found"));
#else
console_print(id,"%L",id,"CL_NOT_FOUND");
#endif
return 0;
}
if (flags & CMDTARGET_OBEY_IMMUNITY)
{
if ((get_user_flags(player) & ADMIN_IMMUNITY) &&
((flags & CMDTARGET_ALLOW_SELF) ? (id != player) : true) )
{
new imname[32];
get_user_name(player,imname,31);
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("Client ^"%s^" has immunity"), imname);
#else
console_print(id,"%L",id,"CLIENT_IMM",imname);
#endif
return 0;
}
}
if (flags & CMDTARGET_ONLY_ALIVE)
{
if (!is_user_alive(player))
{
new imname[32];
get_user_name(player,imname,31);
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("That action can't be performed on dead client ^"%s^""), imname);
#else
console_print(id,"%L",id,"CANT_PERF_DEAD",imname);
#endif
return 0;
}
}
if (flags & CMDTARGET_NO_BOTS)
{
if (is_user_bot(player))
{
new imname[32];
get_user_name(player,imname,31);
#if defined AMXMOD_BCOMPAT
console_print(id, SIMPLE_T("That action can't be performed on bot ^"%s^""), imname);
#else
console_print(id,"%L",id,"CANT_PERF_BOT",imname);
#endif
return 0;
}
}
return player;
}
/**
* Standard method to show activity to clients connected to the server.
* This depends on the amx_show_activity cvar. See documentation for more details.
*
* @param id The user id of the person doing the action.
* @param name The name of the person doing the action.
* @param fmt The format string to display. Do not put the "ADMIN:" prefix in this.
*/
stock show_activity( id, const name[], const fmt[], any:... )
{
static __amx_show_activity;
if (__amx_show_activity == 0)
{
__amx_show_activity = get_cvar_pointer("amx_show_activity");
// if still not found, then register the cvar as a dummy
if (__amx_show_activity == 0)
{
__amx_show_activity = register_cvar("amx_show_activity", "2");
}
}
#if defined AMXMOD_BCOMPAT
new buffer[128];
format_args( buffer , 127 , 2 );
#else
new prefix[10];
if (is_user_admin(id))
{
copy(prefix, charsmax(prefix), "ADMIN");
}
else
{
copy(prefix, charsmax(prefix), "PLAYER");
}
new buffer[512];
vformat(buffer, charsmax(buffer), fmt, 4);
#endif
switch(get_pcvar_num(__amx_show_activity))
{
#if defined AMXMOD_BCOMPAT
case 2: // show name to all
{
client_print(0, print_chat, "%s %s: %s", is_user_admin(id) ? SIMPLE_T("ADMIN") : SIMPLE_T("PLAYER"), name, buffer);
}
case 1: // hide name to all
{
client_print(0, print_chat, "%s: %s", is_user_admin(id) ? SIMPLE_T("ADMIN") : SIMPLE_T("PLAYER"), buffer);
}
#else
case 5: // hide name only to admins, show nothing to normal users
{
new __maxclients=get_maxplayers();
for (new i=1; i<=__maxclients; i++)
{
if (is_user_connected(i))
{
if (is_user_admin(i))
{
client_print(i, print_chat, "%L: %s", i, prefix, buffer);
}
}
}
}
case 4: // show name only to admins, show nothing to normal users
{
new __maxclients=get_maxplayers();
for (new i=1; i<=__maxclients; i++)
{
if (is_user_connected(i))
{
if (is_user_admin(i))
{
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer);
}
}
}
}
case 3: // show name only to admins, hide name from normal users
{
new __maxclients=get_maxplayers();
for (new i=1; i<=__maxclients; i++)
{
if (is_user_connected(i))
{
if (is_user_admin(i))
{
client_print(i, print_chat, "%L %s: %s", i, prefix, name, buffer);
}
else
{
client_print(i, print_chat, "%L: %s", i, prefix, buffer);
}
}
}
}
case 2: // show name to all
{
client_print(0, print_chat, "%L %s: %s", LANG_PLAYER, prefix , name , buffer );
}
case 1: // hide name to all
{
client_print(0, print_chat, "%L: %s", LANG_PLAYER, prefix, buffer );
}
#endif
}
}
/**
* Standard method to show activity to one single client.
* This is useful for messages that get pieced together by many language keys.
* This depends on the amx_show_activity cvar. See documentation for more details.
*
* @param idtarget The user id of the person to display to. 0 is invalid.
* @param idadmin The user id of the person doing the action.
* @param name The name of the person doing the action.
* @param fmt The format string to display. Do not put the "ADMIN:" prefix in this.
*/
stock show_activity_id(idtarget, idadmin, const name[], const fmt[], any:...)
{
if (idtarget == 0 ||
!is_user_connected(idtarget) )
{
return;
}
static __amx_show_activity;
if (__amx_show_activity == 0)
{
__amx_show_activity = get_cvar_pointer("amx_show_activity");
// if still not found, then register the cvar as a dummy
if (__amx_show_activity == 0)
{
__amx_show_activity = register_cvar("amx_show_activity", "2");
}
}
static prefix[10];
if (is_user_admin(idadmin))
{
copy(prefix, charsmax(prefix), "ADMIN");
}
else
{
copy(prefix, charsmax(prefix), "PLAYER");
}
static buffer[512];
vformat(buffer, charsmax(buffer), fmt, 5);
switch(get_pcvar_num(__amx_show_activity))
{
case 5: // hide name only to admins, show nothing to normal users
{
if ( is_user_admin(idtarget) )
{
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
}
}
case 4: // show name only to admins, show nothing to normal users
{
if ( is_user_admin(idtarget) )
{
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
}
}
case 3: // show name only to admins, hide name from normal users
{
if ( is_user_admin(idtarget) )
{
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
}
else
{
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
}
}
case 2: // show name to all
{
client_print(idtarget, print_chat, "%L %s: %s", idtarget, prefix, name, buffer);
}
case 1: // hide name to all
{
client_print(idtarget, print_chat, "%L: %s", idtarget, prefix, buffer);
}
}
}
/**
* Standard method to show activity to one single client with normal language keys.
* These keys need to be in the format of standard AMXX keys:
* eg: ADMIN_KICK_1 = ADMIN: kick %s
* ADMIN_KICK_2 = ADMIN %s: kick %s
* This depends on the amx_show_activity cvar. See documentation for more details.
*
* @param KeyWithoutName The language key that does not have the name field.
* @param KeyWithName The language key that does have the name field.
* @param __AdminName The name of the person doing the action.
* @extra Pass any extra format arguments for the language key in the variable arguments list.
*/
stock show_activity_key(const KeyWithoutName[], const KeyWithName[], const ___AdminName[], any:...)
{
// The variable gets used via vformat, but the compiler doesn't know that, so it still cries.
#pragma unused ___AdminName
static __amx_show_activity;
if (__amx_show_activity == 0)
{
__amx_show_activity = get_cvar_pointer("amx_show_activity");
// if still not found, then register the cvar as a dummy
if (__amx_show_activity == 0)
{
__amx_show_activity = register_cvar("amx_show_activity", "2");
}
}
new buffer[512];
new keyfmt[256];
new i;
new __maxclients=get_maxplayers();
switch( get_pcvar_num(__amx_show_activity) )
{
case 5: // hide name to admins, display nothing to normal players
while (i++ < __maxclients)
{
if ( is_user_connected(i) )
{
if ( is_user_admin(i) )
{
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
// skip the "adminname" argument if not showing name
vformat(buffer, charsmax(buffer), keyfmt, 4);
client_print(i, print_chat, "%s", buffer);
}
}
}
case 4: // show name only to admins, display nothing to normal players
while (i++ < __maxclients)
{
if ( is_user_connected(i) )
{
if ( is_user_admin(i) )
{
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
vformat(buffer, charsmax(buffer), keyfmt, 3);
client_print(i, print_chat, "%s", buffer);
}
}
}
case 3: // show name only to admins, hide name from normal users
while (i++ < __maxclients)
{
if ( is_user_connected(i) )
{
if ( is_user_admin(i) )
{
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
vformat(buffer, charsmax(buffer), keyfmt, 3);
}
else
{
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
// skip the "adminname" argument if not showing name
vformat(buffer, charsmax(buffer), keyfmt, 4);
}
client_print(i, print_chat, "%s", buffer);
}
}
case 2: // show name to all users
while (i++ < __maxclients)
{
if ( is_user_connected(i) )
{
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithName, i);
vformat(buffer, charsmax(buffer), keyfmt, 3);
client_print(i, print_chat, "%s", buffer);
}
}
case 1: // hide name from all users
while (i++ < __maxclients)
{
if ( is_user_connected(i) )
{
LookupLangKey(keyfmt, charsmax(keyfmt), KeyWithoutName, i);
// skip the "adminname" argument if not showing name
vformat(buffer, charsmax(buffer), keyfmt, 4);
client_print(i, print_chat, "%s", buffer);
}
}
}
}
stock colored_menus()
{
new mod_name[32];
get_modname(mod_name,31);
return ( equal(mod_name,"cstrike") || equal(mod_name,"czero") || equal(mod_name,"dod") );
}
stock cstrike_running()
{
new mod_name[32];
get_modname(mod_name,31);
return ( equal(mod_name,"cstrike") || equal(mod_name,"czero") || equal(mod_name,"csv15") || equal(mod_name,"cs13") );
}
stock is_running(const mod[])
{
new mod_name[32];
get_modname(mod_name,31);
return equal(mod_name,mod);
}
stock get_basedir(name[],len)
{
return get_localinfo("amxx_basedir",name,len);
}
stock get_configsdir(name[],len)
{
return get_localinfo("amxx_configsdir",name,len);
}
stock get_datadir(name[],len)
{
return get_localinfo("amxx_datadir",name,len);
}
stock register_menu(const title[],keys,const function[],outside=0)
{
register_menucmd(register_menuid(title,outside),keys,function);
}
/* Backwards Compatibility
* don't use it! */
stock get_customdir(name[],len)
{
return get_localinfo("amxx_configsdir",name,len);
}
/* Add a menu item to Menus Front-End plugin ("amxmodmenu"):
* MENU_TEXT: Text that will be shown for this item in menu
* MENU_CMD: Command that should be executed to start menu
* MENU_ACCESS: Access required for menu
* MENU_PLUGIN: The exact case-insensitive name of plugin holding the menu command
*/
stock AddMenuItem(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[])
{
AddMenuItem_call(MENU_TEXT, MENU_CMD, MENU_ACCESS, MENU_PLUGIN, false);
}
/* Just like above, but add menu item to "amx_menu", that should also be accessible by non-admins.
*/
stock AddClientMenuItem(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[])
{
AddMenuItem_call(MENU_TEXT, MENU_CMD, MENU_ACCESS, MENU_PLUGIN, true);
}
// Internal function used by above stocks.
stock AddMenuItem_call(const MENU_TEXT[], const MENU_CMD[], const MENU_ACCESS, const MENU_PLUGIN[], const bool:ADD_TO_CLIENT_MENU)
{
new pluginid = is_plugin_loaded("Menus Front-End");
if (pluginid == -1) {
log_amx("Can't add menu item ^"%s^" from plugin ^"%s^" to menu set because the Menus Front-End plugin itself is not loaded!", MENU_TEXT, MENU_PLUGIN);
return; // Menus Front-End doesn't exist, return.
}
new filename[64], b[1];
get_plugin(pluginid, filename, 63, b, 0, b, 0, b, 0, b, 0);
new status = callfunc_begin(ADD_TO_CLIENT_MENU ? "AddClientMenu" : "AddMenu", filename);
new bool:failed = true;
switch (status)
{
case 1: failed = false;
case 0: log_amx("Run time error! (AddMenuItem_call failed)");
case -2: log_amx("Function not found! (AddMenuItem_call failed)");
case -1: log_amx("Plugin not found! (AddMenuItem_call failed)");
}
if (failed)
{
return;
}
// Item text
callfunc_push_str(MENU_TEXT);
// Cmd
callfunc_push_str(MENU_CMD);
// Access
callfunc_push_int(MENU_ACCESS);
// Menu exists in this plugin
callfunc_push_str(MENU_PLUGIN);
callfunc_end();
}
stock constraint_offset(low, high, seed, offset)
{
new numElements = high - low + 1;
offset += seed - low;
if (offset >= 0)
{
return low + (offset % numElements);
}
else
{
return high - (abs(offset) % numElements) + 1;
}
return 0; // Makes the compiler happy -_-
}
/* Returns true if the user has ANY of the provided flags
* false if they have none
*/
stock has_flag(id, const flags[])
{
return (get_user_flags(id) & read_flags(flags));
}
/* Returns true if the user has ALL of the provided flags
* false otherwise
*/
stock has_all_flags(id, const flags[])
{
new FlagsNumber=read_flags(flags);
return ((get_user_flags(id) & FlagsNumber)==FlagsNumber);
}

View File

@@ -0,0 +1,89 @@
/* VexdUM backwards compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if !defined _fakemeta_included
#include <fakemeta>
#endif
#if !defined _engine_included
#include <engine>
#endif
#if defined _vexd_bcompat_included
#endinput
#endif
#define _vexd_bcompat_included
#include <VexdUM_const>
native radius_damage(inflictor, Float:dmg, Float:orig[3], Float:rad, bit = DMG_BULLET, wpnName[]="", hs = 0);
native take_damage(victim, attacker, Float:orig[3], Float:dmg, bit = DMG_BULLET, wpnName[]="", hs = 0);
native set_user_model(id, const Model[]="");
native entity_use(eUsed, eOther);
native get_num_ents();
native DispatchKeyValue(ent, szKey[], szValue[]);
// Trace a line from Start(X, Y, Z) to End(X, Y, Z), will return the point hit in vReturn[3]
// Will return an entindex if an entity is hit.
native trace_line(ent, Float:vStart[3], Float:vEnd[3], Float:vReturn[3]);
native traceline_get_int(iVar);
native traceline_set_int(iVar, iVal);
native Float:traceline_get_float(iVar);
native traceline_set_float(iVar, Float:fVal);
native traceline_get_vector(iVar, Float:vVal[3]);
native traceline_set_vector(iVar, Float:vVal[3]);
native traceline_get_edict(iVar);
native traceline_set_edict(iVar, iEnt);
/* Wrapper around pfn_touch */
forward entity_touch(entity1, entity2);
/* Wrapper around pfn_think */
forward entity_think(entity);
/* Wrapper around pfn_spawn */
forward entity_spawn(entity);
/* Wrapper around client_PreThink */
forward client_prethink(id);
/* Wrapper around client_PostThink */
forward client_postthink(id);
//From AMX Mod:
// Called when an Emitting Sound is played Server-Side
forward emitsound(entity, const sample[]);
//From AMX Mod:
// Called when an Emitting Ambient Sound is played Server-Side
forward emitambientsound(entity, const sample[]);
//From AMX Mod:
// Called when a model spawns
forward set_model(entity, const model[]);
//From AMX Mod:
// Called whatever an entity looks at
forward traceline(entity);
//:TODO: ?
// Called when a monster is hurt by VexdUM damage natives
// forward monster_hurt(monster, attacker, damage);
//From AMX Mod:
// Called when a keyvalue is set on a player
forward setclientkeyvalue(id, key[], value[]);
//From AMX Mod:
// Called when an entity gets a keyvalue set on it from the engine.
// Use copy_keyvalue to get the keyvalue information
forward keyvalue(entity);
#include <VexdUM_stock>

View File

@@ -0,0 +1,30 @@
#if defined _vexdum_const_included
#endinput
#endif
#define _vexdum_const_included
// TraceLine Integer
enum {
TR_INT_fAllSolid, // if true, plane is not valid
TR_INT_fStartSolid, // if true, the initial point was in a solid area
TR_INT_fInOpen,
TR_INT_fInWater,
TR_INT_iHitgroup, // 0 == generic, non zero is specific body part
};
// TraceLine Float
enum {
TR_FL_flFraction, // time completed, 1.0 = didn't hit anything
TR_FL_flPlaneDist,
};
// TraceLine Vector
enum {
TR_VEC_vecEndPos, // final position
TR_VEC_vecPlaneNormal, // surface normal at impact
};
// TraceLine Edict
enum {
TR_ENT_pHit, // entity the surface is on
};

View File

@@ -0,0 +1,135 @@
/* VexdUM stocks backwards compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _vexd_bcompat_stocks_included
#endinput
#endif
#define _vexd_bcompat_stocks_included
#if !defined _engine_included
#include <engine>
#endif
stock is_entity(ent)
{
return pev_valid(ent);
}
stock get_offset_int(ent, offset, linos = 5)
{
return get_pdata_int(ent, offset, linos);
}
stock set_offset_int(ent, offset, value, linos = 5)
{
return set_pdata_int(ent, offset, value, linos);
}
stock in_view_cone(ent, Float:Orig[3])
{
return is_in_viewcone(ent, Orig);
}
stock get_maxentities()
{
return global_get(glb_maxEntities);
}
stock can_see(ent1, ent2)
{
if (is_entity(ent1) && is_entity(ent2))
{
new flags = pev(ent1, pev_flags);
if (flags & EF_NODRAW || flags & FL_NOTARGET)
{
return 0;
}
new Float:lookerOrig[3];
new Float:targetOrig[3];
new Float:temp[3];
pev(ent1, pev_origin, lookerOrig);
pev(ent1, pev_view_ofs, temp);
lookerOrig[0] += temp[0];
lookerOrig[1] += temp[1];
lookerOrig[2] += temp[2];
pev(ent2, pev_origin, targetOrig);
pev(ent2, pev_view_ofs, temp);
targetOrig[0] += temp[0];
targetOrig[1] += temp[1];
targetOrig[2] += temp[2];
engfunc(EngFunc_TraceLine, lookerOrig, targetOrig, 0, ent1, 0);
if (get_tr2(0, TraceResult:TR_InOpen) && get_tr2(0, TraceResult:TR_InWater))
{
return 0;
} else {
new Float:flFraction;
get_tr2(0, TraceResult:TR_flFraction, flFraction);
if (flFraction == 1.0 || (get_tr2(0, TraceResult:TR_pHit) == ent2))
{
return 1;
}
}
}
return 0;
}
//From AMX Mod:
// Find an entity in the world, will return -1 if nothing is found
// type = 0: "classname"
// type = 1: "globalname"
// type = 2: "model"
// type = 3: "target"
// type = 4: "targetname"
// type = 5: "netname"
// type = 6: "message"
// type = 7: "noise"
// type = 8: "noise1"
// type = 9: "noise2"
// type = 10: "noise3"
// type = 11: "viewmodel"
// type = 12: "weaponmodel"
stock vexd_find_entity(ent, szValue[], type=0)
{
static _g_FindEntTypes[13][] =
{
"classname",
"globalname",
"model",
"target",
"targetname",
"netname",
"messages",
"noise",
"noise1",
"noise2",
"noise3",
"viewmodel",
"weaponmodel"
};
if (type < 0 || type >= 13)
{
type = 0;
}
return engfunc(EngFunc_FindEntityByString, ent, _g_FindEntTypes[type], szValue);
}
#define find_entity vexd_find_entity
//From AMX Mod:
// Find an entity within a given origin and radius
stock find_entity_sphere(ent, Float:Orig[3], Float:Rad)
{
return engfunc(EngFunc_FindEntityInSphere, ent, Orig, Rad);
}

View File

@@ -0,0 +1,109 @@
/* Vexd Utility backwards compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _Vexd_Utilities_included
#endinput
#endif
#define _Vexd_Utilities_included
#include <engine>
#if defined AMXMOD_BCOMPAT
#if !defined _vexd_bcompat_included
#include <VexdUM>
#endif
#endif
stock Entvars_Get_Int(iIndex, iVariable)
return entity_get_int(iIndex, iVariable);
stock Entvars_Set_Int(iIndex, iVariable, iNewValue)
return entity_set_int(iIndex, iVariable, iNewValue);
stock Float:Entvars_Get_Float(iIndex, iVariable)
return entity_get_float(iIndex, iVariable);
stock Entvars_Set_Float(iIndex, iVariable, Float:fNewValue)
return entity_set_float(iIndex, iVariable, fNewValue);
stock Entvars_Get_Vector(iIndex, iVariable, Float:vRetVector[3])
return entity_get_vector(iIndex, iVariable, vRetVector);
stock Entvars_Set_Vector(iIndex, iVariable, Float:vNewVector[3])
return entity_set_vector(iIndex, iVariable, vNewVector);
stock Entvars_Get_Edict(iIndex, iVariable)
return entity_get_edict(iIndex, iVariable);
stock Entvars_Set_Edict(iIndex, iVariable, iNewIndex)
return entity_set_edict(iIndex, iVariable, iNewIndex);
stock Entvars_Get_String(iIndex, iVariable, szReturnValue[], iReturnLen)
return entity_get_string(iIndex, iVariable, szReturnValue, iReturnLen);
stock Entvars_Set_String(iIndex, iVariable, szNewValue[])
return entity_set_string(iIndex, iVariable, szNewValue);
stock Entvars_Get_Byte(iIndex, iVariable)
return entity_get_byte(iIndex, iVariable);
stock Entvars_Set_Byte(iIndex, iVariable, iNewValue)
return entity_set_byte(iIndex, iVariable, iNewValue);
stock CreateEntity(szClassname[])
return create_entity(szClassname);
stock ENT_SetModel(iIndex, szModel[])
return entity_set_model(iIndex, szModel);
stock ENT_SetOrigin(iIndex, Float:fNewOrigin[3])
return entity_set_origin(iIndex, fNewOrigin);
stock FindEntity(iIndex, szValue[])
return find_ent_by_class(iIndex, szValue);
stock RemoveEntity(iIndex)
return remove_entity(iIndex);
stock TraceLn(iIgnoreEnt, Float:fStart[3], Float:fEnd[3], Float:vReturn[3])
return trace_line(iIgnoreEnt, fStart, fEnd, vReturn);
stock TraceNormal(iIgnoreEnt, Float:fStart[3], Float:fEnd[3], Float:vReturn[3])
return trace_normal(iIgnoreEnt, fStart, fEnd, vReturn);
stock VecToAngles(Float:fVector[3], Float:vReturn[3])
return vector_to_angle(fVector, vReturn);
stock Float:VecLength(Float:vVector[3])
return vector_length(vVector);
stock Float:VecDist(Float:vVector[3], Float:vVector2[3])
return vector_distance(vVector, vVector2);
stock MessageBlock(iMessage, iMessageFlags)
return set_msg_block(iMessage, iMessageFlags);
stock GetMessageBlock(iMessage)
return get_msg_block(iMessage);
stock Float:HLTime()
return halflife_time();
stock FakeTouch(iToucher, iTouched)
return fake_touch(iToucher, iTouched);
stock AttachView(iIndex, iTargetIndex)
return attach_view(iIndex, iTargetIndex);
stock SetView(iIndex, ViewType)
return set_view(iIndex, ViewType);
stock SetSpeak(iIndex, iSpeakFlags)
return set_speak(iIndex, iSpeakFlags);
forward vexd_pfntouch(pToucher, pTouched);
forward ServerFrame();

View File

@@ -0,0 +1,318 @@
/* AMX Mod X Backwards Compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _amxmod_included
#endinput
#endif
#define _amxmod_included
#if !defined AMXMOD_BCOMPAT
#define AMXMOD_BCOMPAT
#endif
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fun>
#include <maths>
stock AMX_VERSION[] = "1.76-BC";
#define ADMIN_PERMBAN ADMIN_BAN //AMX Mod admin flag for permanent ban
#define ADMIN_UNBAN ADMIN_BAN //AMX Mod admin flag for unbanning
#define ADMIN_SUPREME ADMIN_IMMUNITY //AMX Mod admin flag for "super admin" (can kick, slap, ban, slay admins with Immunity)
/* Core will identify us as an "old plugin" this way. */
public __b_old_plugin = 1;
public __b_ident_vers()
{
return __b_old_plugin;
}
stock user_spawn(index)
return spawn(index);
stock get_logfile( name[], len )
return get_time("admin%m%d.log",name,len);
stock get_user_money(index)
return cs_get_user_money(index);
stock set_user_money(index,money,flash=1)
return cs_set_user_money(index,money,flash);
stock numtostr(num,string[],len)
return num_to_str(num,string,len);
stock strtonum(const string[])
return str_to_num(string);
stock build_path(path[], len, {Float,_}:... )
{
format_args(path, len, 2);
new pathlen = strlen(path);
new basedir[32];
if (containi(path, "$basedir") != -1)
{
get_localinfo("amxx_basedir", basedir, 31);
if (!basedir[0])
{
copy(basedir, 31, "addons/amxmodx");
}
if ((pathlen+strlen(basedir)-strlen("$basedir")) < len)
{
replace(path, len, "$basedir", basedir);
}
}
new dir[64], subdir[63];
if (containi(path, "$configdir") != -1)
{
get_localinfo("amxx_configsdir", dir, 63);
if (!dir[0])
{
format(dir, 63, "%s/configs", basedir);
}
if ((pathlen+strlen(basedir)-strlen("$configdir")) < len)
{
replace(path, len, "$configdir", dir);
}
dir[0] = '^0';
}
if (containi(path, "$langdir") != -1)
{
get_localinfo("amxx_datadir", subdir, 63);
if (!subdir[0])
{
format(subdir, 63, "%s/data", basedir);
}
format(dir, 63, "%s/amxmod-lang", subdir);
if ((pathlen+strlen(basedir)-strlen("$langdir")) < len)
{
replace(path, len, "$langdir", dir);
}
dir[0] = '^0';
}
if (containi(path, "$modulesdir") != -1)
{
get_localinfo("amxx_modules", dir, 63);
if (!dir[0])
{
format(dir, 63, "%s/modules", basedir);
}
if ((pathlen+strlen(basedir)-strlen("$modulesdir")) < len)
{
replace(path, len, "$modulesdir", dir);
}
dir[0] = '^0';
}
if (containi(path, "$pluginsdir") != -1)
{
get_localinfo("amx_pluginsdir", dir, 63);
if( !dir[0])
{
format(dir, 63, "%s/plugins", basedir);
}
if ((pathlen+strlen(basedir)-strlen("$pluginsdir")) < len)
{
replace(path, len, "$pluginsdir", dir);
}
dir[0] = '^0';
}
if (containi(path, "$logdir") != -1)
{
get_localinfo("amx_logs", dir, 63);
if (!dir[0])
{
format(dir, 63, "%s/logs", basedir);
}
if ((pathlen+strlen(basedir)-strlen("$logdir")) < len)
{
replace(path, len, "$logdir", dir);
}
}
return 1;
}
stock is_user_authorized(id)
{
static auth[32];
get_user_authid(id, auth, 31);
if (auth[0] == 0 || equali(auth, "STEAM_ID_PENDING"))
{
return 0;
}
return 1;
}
/* Vector AMX Mod compatibility */
#define ANGLEVECTORS_FORWARD 1
#define ANGLEVECTORS_RIGHT 2
#define ANGLEVECTORS_UP 3
stock angle_to_vector(Float:vector[3], FRU, Float:ret[3])
{
return angle_vector(vector, FRU, ret);
}
stock get_cmdaccess(cmd[], accessflags[], len)
{
new num = get_concmdsnum(-1);
new command[32], info[3];
new flags;
for (new i=0; i<num; i++)
{
get_concmd(i, command, 31, flags, info, 2, -1);
if (equal(command, cmd))
{
get_flags(flags, accessflags, len);
return 1;
}
}
return 0;
}
stock is_translated(const sentence[])
{
return (GetLangTransKey(sentence) != TransKey_Bad);
}
stock get_plugincmdsnum(plugin[], type=7)
{
new plid = find_plugin_byfile(plugin);
new our_type;
/**
* Whoever wrote this was a bit confused about the type stuff...
*/
if (type == 1) {
our_type = 1;
} else if (type == 4) {
our_type = 0;
} else {
our_type = -1;
}
new found = 0;
new total = get_concmdsnum(-1, our_type);
for (new i=0; i<total; i++)
{
if (plid == get_concmd_plid(i, -1, our_type))
{
found++;
}
}
return found;
}
stock get_plugincmd(plugin[], index, cmd[], len1, accessflags[], len2, info[], len3, destid=-1, type=7)
{
new plid = find_plugin_byfile(plugin);
new our_type;
/**
* Whoever wrote this was a bit confused about the type stuff...
*/
if (type == 1) {
our_type = 1;
} else if (type == 4) {
our_type = 0;
} else {
our_type = -1;
}
new found_iter = 0;
new total = get_concmdsnum(-1, our_type);
for (new i=0; i<total; i++)
{
if (plid == get_concmd_plid(i, -1, our_type))
{
if (found_iter == index)
{
new flags, result;
result = get_concmd(i, cmd, len1, flags, info, len3, -1, our_type);
get_flags(flags, accessflags, len2);
return result;
}
found_iter++;
}
}
/* get rid of a compiler warning */
destid = -1;
return (++destid);
}
stock get_plugincvar(plugin[], index, cvar[], len1, value[], len2, flags=0)
{
new plid = find_plugin_byfile(plugin);
new total = get_plugins_cvarsnum();
new cvar_flags, plugin_id, pcvar_handle;
new iter_id = 0;
for (new i=0; i<total; i++)
{
get_plugins_cvar(i, cvar, len1, cvar_flags, plugin_id, pcvar_handle);
if ((plugin_id == plid)
&& (!flags || (cvar_flags & flags)))
{
if (iter_id == index)
{
get_pcvar_string(pcvar_handle, value, len2);
return 1;
}
iter_id++;
}
}
return 0;
}
stock get_plugincvarsnum(plugin[], flags=0)
{
new plid = find_plugin_byfile(plugin);
new total = get_plugins_cvarsnum();
new cvar_flags, plugin_id;
new cvars_total = 0;
for (new i=0; i<total; i++)
{
get_plugins_cvar(i, "", 0, cvar_flags, plugin_id);
if ((plugin_id == plid)
&& (!flags || (cvar_flags & flags)))
{
cvars_total++;
}
}
return cvars_total;
}
stock is_module_running(const module[])
{
if (strcmp(module, "MySQL Access") == 0)
return LibraryExists("sqlx", LibType_Class);
return is_module_loaded(module) == -1 ? 0 : 1;
}
stock is_plugin_running(const plugin[])
{
new status[8];
new id, filename[1], name[1], version[1], author[1];
id = is_plugin_loaded(plugin);
get_plugin(id, filename, 0, name, 0, version, 0, author, 0, status, 7);
return strcmp(status, "running") == 0 ? id + 1 : 0;
}

View File

@@ -0,0 +1,85 @@
/* AMX Mod math functions backwards compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _maths_bcompat_included
#endinput
#endif
#define _maths_bcompat_included
#if !defined _float_included
#include <float>
#endif
stock Float:fabs(Float:value)
{
return floatabs(value);
}
stock Float:asin(Float:value)
{
return floatasin(value, radian);
}
stock Float:sin(Float:value)
{
return floatsin(value, radian);
}
stock Float:sinh(Float:value)
{
return floatsinh(value, radian);
}
stock Float:acos(Float:value)
{
return floatacos(value, radian);
}
stock Float:cos(Float:value)
{
return floatcos(value, radian);
}
stock Float:cosh(Float:value)
{
return floatcosh(value, radian);
}
stock Float:atan(Float:value)
{
return floatatan(value, radian);
}
stock Float:atan2(Float:value1, Float:value2)
{
return floatatan2(value1, value2, radian);
}
stock Float:tan(Float:value)
{
return floattan(value, radian);
}
stock Float:tanh(Float:value)
{
return floattanh(value, radian);
}
stock Float:fsqroot(Float:value)
{
return floatsqroot(value);
}
stock Float:fpower(Float:value, Float:exponent)
{
return floatpower(value, exponent);
}
stock Float:flog(Float:value, Float:base=10.0)
{
return floatlog(value, base);
}

View File

@@ -0,0 +1,20 @@
#if defined _mysql_included
#endinput
#endif
#define _mysql_included
#include <sqlx>
native mysql_connect(host[], user[], pass[], dbname[], error[], maxlength);
native mysql_query(sql, query[], {Float,_}:... );
native mysql_error(sql, dest[], maxlength);
native mysql_close(sql);
native mysql_nextrow(sql);
native mysql_getfield(sql, fieldnum, {Float,_}:... );
native mysql_getresult(sql, field[], {Float,_}:... );
native mysql_affected_rows(sql);
native mysql_num_fields(sql);
native mysql_num_rows(sql);
native mysql_field_name(sql, field, name[], length);
native mysql_insert_id(sql);

View File

@@ -0,0 +1,86 @@
/* AMX Mod X Backwards Compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _amxmod_translator_included
#endinput
#endif
#define _amxmod_translator_included
#define _translator_included
#include <amxmodx>
#include <amxmod>
#include <amxmisc>
//From AMX Mod. This is implemented in Core due to the nature of the
// translation engine and what AMX Mod did.
/* Translation backend, used by _T (since natives can't return arrays). */
native translate(const string[], destid=-1, forcelang=-1);
stock _T(const string[], destid=-1, forcelang=-1)
{
new TranslationResult[2] = {0, 0};
TranslationResult[0] = translate(string, destid, forcelang);
return TranslationResult;
}
stock load_translations(const file[])
{
static dir[255], path[255];
get_datadir(dir, 254);
format(path, 254, "%s/amxmod-lang/%s.txt", dir, file);
new fp
if (!(fp=fopen(path, "r")))
{
abort(AMX_ERR_NATIVE, "Could not find file: %s", path);
return 0;
}
static buffer[1024];
new lang[3];
new TransKey:bad_key = TransKey:-1;
new TransKey:cur_key = bad_key;
new len;
while (!feof(fp))
{
buffer[0] = 0;
fgets(fp, buffer, 1023);
len = strlen(buffer);
if (len == 0)
{
continue;
}
if (isspace(buffer[len-1]))
{
buffer[--len] = 0;
}
if (buffer[0] == '"')
{
remove_quotes(buffer);
cur_key = CreateLangKey(buffer);
AddTranslation("en", cur_key, buffer);
continue;
}
if (isspace(buffer[0]))
{
continue;
}
if ((cur_key != bad_key) && (buffer[2] == ':' && buffer[3] == '"'))
{
lang[0] = buffer[0];
lang[1] = buffer[1];
lang[2] = 0;
remove_quotes(buffer[3]);
AddTranslation(lang, cur_key, buffer[3]);
}
}
fclose(fp);
return 1;
}

View File

@@ -0,0 +1,97 @@
/* Xtrafun backwards compatibility
*
* by the AMX Mod X Development Team
* These natives were originally made by SpaceDude, EJ, and JustinHoMi.
*
* This file is provided as is (no warranties).
*/
#if !defined _xtrafun_included
#define _xtrafun_included
#if !defined _engine_included
#include <engine.inc>
#endif
/* Gets the velocity of an entity */
stock get_entity_velocity(index, velocity[3]) {
new Float:vector[3];
entity_get_vector(index, EV_VEC_velocity, vector);
FVecIVec(vector, velocity);
}
/* Sets the velocity of an entity */
stock set_entity_velocity(index, velocity[3]) {
new Float:vector[3];
IVecFVec(velocity, vector);
entity_set_vector(index, EV_VEC_velocity, vector);
}
/* Gets the origin of an entity */
stock get_entity_origin(index, origin[3]) {
new Float:vector[3];
entity_get_vector(index, EV_VEC_origin, vector);
FVecIVec(vector, origin);
}
/* Sets the origin of an entity */
stock set_entity_origin(index, origin[3]) {
new Float:vector[3];
IVecFVec(origin, vector);
entity_set_vector(index, EV_VEC_origin, vector);
}
/* Get the index of the grenade belonging to index.
* Model of grenade is returned in model[].
* Specify the grenadeindex to start searching from,
* or leave it at 0 to search from the start.
* Returns grenade index.
* Paths + models of grenades in Counter-Strike:
* HEGRENADE = "models/w_hegrenade.mdl"
* FLASHBANG = "models/w_flashbang.mdl"
* SMOKEGRENADE = "models/w_smokegrenade.mdl" */
stock get_grenade_index(index, model[], len, grenadeindex = 0) {
new entfind = grenadeindex;
new entowner = index;
for (;;) {
entfind = find_ent_by_class(entfind, "grenade");
if (entfind && is_valid_ent(entfind)) {
if (entity_get_edict(entFind, EV_ENT_owner) == entowner) {
entity_get_string(entfind, EV_SZ_model, model);
return entfind;
}
}
else {
// Eventually comes here if loop fails to find a grenade with specified owner.
return 0;
}
}
}
/* Find the number of entities in the game */
stock current_num_ents() {
return entity_count();
}
enum {
classname = 0,
target,
targetname
};
#if !defined _vexd_bcompat_included
/* Find an entity ID from start_from_ent id (use 0 to start from
* the beginning, category is either "classname", "target" or
* "targetname", value is the name you are searching for */
stock find_entity(start_from_ent, category, value[]) {
switch (category) {
case target: return find_ent_by_target(start_from_ent, value);
case targetname: return find_ent_by_tname(start_from_ent, value);
}
return find_ent_by_class(start_from_ent, value);
}
#endif
#endif // _xtrafun_included

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,254 @@
#if defined _cellarray_included
#endinput
#endif
#define _cellarray_included
enum Array
{
Invalid_Array = 0
};
/**
* These arrays are intended to be used for a form of global storage without
* requiring a #define that needs to be increased each time a person needs more
* storage.
* These are not designed to be used as a replacement for normal arrays, as
* normal arrays are faster and should be used whenever possible.
*/
/**
* Creates a handle to a dynamically sized array.
* It is very important that the cellsize you provide matches up with the buffer sizes
* that you pass with subsequent Array{Get,Set,Push} calls.
*
* @param cellsize How many cells each entry in the array is.
* @param reserved How many blank entries are created immediately when the array is created. These entries are not valid to read from until called with ArraySet.
* @return Handle to the array.
*/
native Array:ArrayCreate(cellsize=1, reserved=32);
/**
* Clears all entries from the array.
*
* @param which The array to clear.
* @return 1 on success, 0 on failure.
*/
native ArrayClear(Array:which);
/**
* Returns the number of elements in the array.
*
* @param which The array to check.
* @return How many elements are in the array.
*/
native ArraySize(Array:which);
/**
* Returns data within an array.
* Make sure the output buffer matches the size the array was created with!
*
* @param which The array to retrieve the item from.
* @param item The item to retrieve (zero-based).
* @param output The output buffer to write.
*/
native ArrayGetArray(Array:which, item, any:output[]);
/**
* Returns a single cell of data from an array.
* Use this only with arrays that were created with a cellsize of 1!
*
* @param which The array to retrieve the item from.
* @param item The item to retrieve (zero-based).
* @return The value of the cell.
*/
native any:ArrayGetCell(Array:which, item);
/**
* Returns a string value from an array.
*
* @param which The array to retrieve the item from.
* @param item The item to retrieve (zero-based).
* @param output The variable to store the value in.
* @param size Character size of the output buffer.
*/
native ArrayGetString(Array:which, item, output[], size);
/**
* Sets an item's data with that of a local buffer.
* The buffer size must match what the cellsize that the array was created with!
* The item must already exist, use ArrayPushArray to create a new item within the array.
*
* @param which The array to set the item from within.
* @param item The item to set (zero-based).
* @param input The input buffer to store.
*/
native ArraySetArray(Array:which, item, const any:input[]);
/**
* Sets an array's single cell value. Use this only on array that were created with a cellsize of 1!
* The item must already exist, use ArrayPushCell to create a new item within the array.
*
* @param which The array to set the item from within.
* @param item The item to set (zero-based).
* @param input The value to set.
*/
native ArraySetCell(Array:which, item, any:input);
/**
* Sets a string value from an array.
* The stored string will be truncated if it is longer than the cellsize the array was created with!
* The item must already exist, use ArrayPushString to create a new item within the array.
*
* @param which The array to set the item from within.
* @param item The item to set (zero-based).
* @param input The string to set the item as.
*/
native ArraySetString(Array:which, item, const input[]);
/**
* Creates a new item at the end of the array and sets its data with that of a local buffer.
* The buffer size must match what the cellsize that the array was created with!
*
* @param which The array to add the item to.
* @param input The input buffer to store.
*/
native ArrayPushArray(Array:which, const any:input[]);
/**
* Creates a new item and sets the array's single cell value.
* Use this only on array that were created with a cellsize of 1!
*
* @param which The array to add the item to.
* @param input The value to set.
*/
native ArrayPushCell(Array:which, any:input);
/**
* Creates a new element in the array and sets its value to the input buffer.
* The stored string will be truncated if it is longer than the cellsize the array was created with!
*
* @param which The array to add the item to.
* @param input The string to set the item as.
*/
native ArrayPushString(Array:which, const input[]);
/**
* Inserts an item after the selected item. All items beyond it get shifted up 1 space.
* The buffer size must match what the cellsize that the array was created with!
*
* @param which The array to add the item to.
* @param item The item to insert after.
* @param input The input buffer to store.
*/
native ArrayInsertArrayAfter(Array:which, item, const any:input[]);
/**
* Inserts an item after the selected item. All items beyond it get shifted up 1 space.
* Use this only on an array that was created with a cellsize of 1!
*
* @param which The array to add the item to.
* @param item The item to insert after.
* @param input The value to set.
*/
native ArrayInsertCellAfter(Array:which, item, any:input);
/**
* Inserts an item after the selected item. All items beyond it get shifted up 1 space.
* The stored string will be truncated if it is longer than the cellsize the array was created with!
*
* @param which The array to add the item to.
* @param item The item to insert after.
* @param input The value to set.
*/
native ArrayInsertStringAfter(Array:which, item, const input[]);
/**
* Inserts an item before the selected item. All items beyond it, and the selected item get shifted up 1 space.
* The buffer size must match what the cellsize that the array was created with!
*
* @param which The array to add the item to.
* @param item The item to insert before.
* @param input The input buffer to store.
*/
native ArrayInsertArrayBefore(Array:which, item, const any:input[]);
/**
* Inserts an item before the selected item. All items beyond it, and the selected item get shifted up 1 space.
* Use this only on an array that was created with a cellsize of 1!
*
* @param which The array to add the item to.
* @param item The item to insert after.
* @param input The value to set.
*/
native ArrayInsertCellBefore(Array:which, item, const any:input);
/**
* Inserts an item before the selected item. All items beyond it, and the selected item get shifted up 1 space.
* The stored string will be truncated if it is longer than the cellsize the array was created with!
*
* @param which The array to add the item to.
* @param item The item to insert before.
* @param input The value to set.
*/
native ArrayInsertStringBefore(Array:which, item, const input[]);
/**
* Swaps the position of two items.
*
* @param which The array that contains the items.
* @param item1 The first item to swap.
* @param item2 The second item to swap.
*/
native ArraySwap(Array:which, item1, item2);
/**
* Deletes an item from the array. All items beyond it get shifted down 1 space.
*
* @param which The array that contains the item to delete.
* @param item The item to delete.
*/
native ArrayDeleteItem(Array:which, item);
/**
* Creates a handle that is passable to a format compliant routine for printing as a string (with the %a format option).
* It is suggested to pass the function directly as a parameter to the format routine.
* The array contents must be a null-terminated string!
*
* An example usage: client_print(id, print_chat, "%a", ArrayGetStringHandle(MessageArray, i));
*
* @param which The array the string is stored in.
* @param item Which item to print the string value of.
* @return Handle to the item directly. Do not use or save stale handles.
*/
native DoNotUse:ArrayGetStringHandle(Array:which, item);
/**
* Destroys the array, and resets the handle to 0 to prevent accidental usage after it is destroyed.
*
* @param which The array to destroy.
*/
native ArrayDestroy(&Array:which);
/**
* Similar to sorting.inc's CustomSort.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(Array:array, item1, item2, const data[], data_size)
*
* array - Array handle in its current un-sorted state.
* item1, item2 - Current item pair being compared
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if item1 should go before item2
* 0 if item1 and item2 are equal
* 1 if item1 should go after item2
* Note that the parameters after item2 are all optional and you do not need to specify them.
*
* Note that unlike the sorting.inc versions, the array passed to the callback is not in mid-sorted state.
*/
native ArraySort(Array:array, const comparefunc[], data[]="", data_size=0);

View File

@@ -0,0 +1,26 @@
#if defined _celltrie_included
#endinput
#endif
#define _celltrie_included
enum Trie
{
Invalid_Trie = 0
};
native Trie:TrieCreate();
native TrieClear(Trie:handle);
native TrieSetCell(Trie:handle, const key[], any:value);
native TrieSetString(Trie:handle, const key[], const value[]);
native TrieSetArray(Trie:handle, const key[], const any:buffer[], size);
native bool:TrieGetCell(Trie:handle, const key[], &any:value);
native bool:TrieGetString(Trie:handle, const key[], output[], outputsize);
native bool:TrieGetArray(Trie:handle, const key[], any:output[], outputsize);
native bool:TrieDeleteKey(Trie:handle, const key[]);
native bool:TrieKeyExists(Trie:handle, const key[]);
native TrieDestroy(&Trie:handle);

View File

@@ -0,0 +1,44 @@
/* Core functions
*
* (c) Copyright 1998-2003, ITB CompuPhase
*
* This file is provided as is (no warranties).
*/
#if defined _core_included
#endinput
#endif
#define _core_included
native heapspace();
native funcidx(const name[]);
native numargs();
native getarg(arg, index=0);
native setarg(arg, index=0, value);
native strlen(const string[]);
native tolower(c);
native toupper(c);
native swapchars(c);
native random(max);
native min(value1, value2);
native max(value1, value2);
native clamp(value, min=cellmin, max=cellmax);
native power(value, exponent);
native sqroot(value);
native time(&hour=0,&minute=0,&second=0);
native date(&year=0,&month=0,&day=0);
native tickcount(&granularity=0);
stock abs(x)
{
return x > 0 ? x : -x;
}

View File

@@ -0,0 +1,61 @@
#if defined _csstats_included
#endinput
#endif
#define _csstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len,authid[] = "",authidlen = 0);
/* Returns number of all entries in stats. */
native get_statsnum();
/*
* new stats:
* 0 - total defusions
* 1 - bomb defused
* 2 - bomb plants
* 3 - bomb explosions
*/
native get_user_stats2(index,stats[4]);
native get_stats2(index,stats[4],authid[] = "",authidlen = 0);

View File

@@ -0,0 +1,355 @@
/* Counter-Strike functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _cstrike_included
#endinput
#endif
#define _cstrike_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib cstrike
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib cstrike
#endif
#else
#pragma library cstrike
#endif
/* Returns player deaths.
*/
native cs_get_user_deaths(index);
/* Sets player deaths.
*/
native cs_set_user_deaths(index, newdeaths);
/* Returns index of entity (does not have to be a player) which hostage is following. 0 is hostage doesn't follow anything.
* Note: this native does not work on Condition Zero, which has a different hostage AI than CS.
*/
native cs_get_hostage_foll(index);
/* Set hostage to follow entity specified in followedindex. Does not have to be a player. If followedindex is 0 the hostage will stop following.
* Note: this native does not work on Condition Zero, which has a different hostage AI than CS.
*/
native cs_set_hostage_foll(index, followedindex = 0);
/* Get unique hostage id.
*/
native cs_get_hostage_id(index);
/* Get amount of ammo in backpack on a user for a specific weapon.
* Look in amxconst.inc for weapon types: CSW_*.
* Weapons on the same line uses the same ammo type:
* awm
* scout, ak, g3
* para
* famas, m4a1, aug, sg550, galil, sg552
* m3, xm
* usp, ump, mac
* fiveseven, p90
* deagle
* p228
* glock, mp5, tmp, elites
* flash
* he
* smoke
*/
native cs_get_user_bpammo(index, weapon);
/* Restock/remove ammo in a user's backpack.
*/
native cs_set_user_bpammo(index, weapon, amount);
/* Returns 1 if user has a defuse kit.
*/
native cs_get_user_defuse(index);
/* If defusekit is 1, the user will have a defuse kit.
* You can specify a different colour for the defuse kit icon showing on hud. Default is the normal green.
* You can specify an icon. Default is "defuser". Set flash to 1 if you want the icon to flash red.
*/
native cs_set_user_defuse(index, defusekit = 1, r = 0, g = 160, b = 0, icon[] = "defuser", flash = 0);
/* Is user in buyzone? Returns 1 when true, 0 when false.
*/
native cs_get_user_buyzone(index);
/* Returns 1 when user has a primary weapon OR a shield in inventory, else 0.
*/
native cs_get_user_hasprim(index);
/* Get user model.
*/
native cs_get_user_model(index, model[], len);
/* Set user model.
*/
native cs_set_user_model(index, const model[]);
/* Use to reset model to standard selected model.
*/
native cs_reset_user_model(index);
/* Returns users money.
*/
native cs_get_user_money(index);
/* Gives money to user. If flash is 1, the difference between new and old amount will flash red or green.
*/
native cs_set_user_money(index, money, flash = 1);
/* Does user have night vision goggles?
*/
native cs_get_user_nvg(index);
/* Set nvgoggles to 1 to give night vision goggles to index. Set it to 0 to remove them.
*/
native cs_set_user_nvg(index, nvgoggles = 1);
/* Returns 1 if user has the "skill" to plant bomb, else 0. Normally this would only be true for a terrorist carrying a bomb.
*/
native cs_get_user_plant(index);
/* If plant is 1, a user will be set to be able to plant bomb within the usual bomb target areas if having one.
* You should use this if you give a player a weapon_c4, or he won't be able to plant it
* without dropping it and picking it up again (only possible for terrorists).
* If showbombicon is 1, the green C4 icon will be shown on user hud (if plant "skill" was enabled).
*/
native cs_set_user_plant(index, plant = 1, showbombicon = 1);
/* Set user team without killing player.
* If model is anything other than CS_DONTCHANGE, that will be set as player's model.
*/
enum CsInternalModel {
CS_DONTCHANGE = 0,
CS_CT_URBAN = 1,
CS_T_TERROR = 2,
CS_T_LEET = 3,
CS_T_ARCTIC = 4,
CS_CT_GSG9 = 5,
CS_CT_GIGN = 6,
CS_CT_SAS = 7,
CS_T_GUERILLA = 8,
CS_CT_VIP = 9,
CZ_T_MILITIA = 10,
CZ_CT_SPETSNAZ = 11
};
native cs_set_user_team(index, {CsTeams,_}:team, {CsInternalModel,_}:model = CS_DONTCHANGE);
/* Get team directly from player's entity.
* 1 = terrorist
* 2 = counter-terrorist
* 3 = spectator
*/
enum CsTeams {
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T = 1,
CS_TEAM_CT = 2,
CS_TEAM_SPECTATOR = 3
};
native CsTeams:cs_get_user_team(index, &{CsInternalModel,_}:model = CS_DONTCHANGE);
/* Is user vip? Returns 1 if true, 0 if false.
*/
native cs_get_user_vip(index);
/* If vip = 1, user is set to vip.
* If model = 1, then user's model will be changed to VIP model or random CT model if vip = 0.
* If scoreboard = 1, then scoreboard will be updated to show that user is VIP.
* This shouldn't be used for players on teams other than CT.
* NOTE: this is mostly useful for unsetting vips, so they can change teams and/or buy items properly.
* It does not alter game play; the one being VIP at start of round will retain internal status as VIP; terrorists
* can terminate him and accomplish their objective, etc.
*/
native cs_set_user_vip(index, vip = 1, model = 1, scoreboard = 1);
/* Returns 1 of specified user has tk:ed (team killed).
*/
native cs_get_user_tked(index);
/* Returns 1 of specified user has TKed (team killed).
* tk = 1: player has TKed
* tk = 0: player hasn't TKed
* Set subtract to how many frags to subtract. Set subtract to negative value to add frags.
*/
native cs_set_user_tked(index, tk = 1, subtract = 1);
/* Returns different values depending on if user is driving a vehicle - and if so at what speed.
* 0: no driving
* 1: driving, but standing still
* 2-4: driving, different positive speeds
* 5: driving, negative speed (backing)
* Note: these values were tested quickly, they may differ.
*/
native cs_get_user_driving(index);
/* Returns 1 if user has a shield, else 0.
*/
native cs_get_user_shield(index);
/* Returns 1 if user is using a stationary gun, else 0.
*/
native cs_get_user_stationary(index);
/* Returns armor value and sets by reference the armor type in second parameter.
*/
enum CsArmorType {
CS_ARMOR_NONE = 0, // no armor
CS_ARMOR_KEVLAR = 1, // armor
CS_ARMOR_VESTHELM = 2 // armor and helmet
};
native cs_get_user_armor(index, &CsArmorType:armortype);
/* Use this instead of fun's set_user_armor.
* Appropriate message to update client's HUD will be sent if armortype is kevlar or vesthelm.
*/
native cs_set_user_armor(index, armorvalue, CsArmorType:armortype);
/* Returns 1 if specified weapon is in burst mode.
*/
native cs_get_weapon_burst(index);
/* If burstmode = 1, weapon will be changed to burst mode, 0 and non-burst mode (semiautomatic/automatic) will be activated.
* Only GLOCK and FAMAS can enter/leave burst mode.
*/
native cs_set_weapon_burst(index, burstmode = 1);
/* Returns 1 if weapon is silenced, else 0.
*/
native cs_get_weapon_silen(index);
/* If silence = 1, weapon will be silenced, 0 and silencer will be removed. Only USP and M4A1 can be silenced.
*/
native cs_set_weapon_silen(index, silence = 1, draw_animation = 1);
/* Returns amount of ammo in weapon's clip.
*/
native cs_get_weapon_ammo(index);
/* Set amount of ammo in weapon's clip.
*/
native cs_set_weapon_ammo(index, newammo);
/* Get weapon type. Corresponds to CSW_* in amxconst.inc: 1 is CSW_P228, 2 is CSW_SCOUT and so on...
*/
native cs_get_weapon_id(index);
/* Returns 1 if no knives mode is enabled, else 0.
*/
native cs_get_no_knives();
/* Enabled no knives mode by calling this with value 1. Disabled with 0.
* No knives mode means that player will not be given a knife when spawning.
* You can still give knives (ie through fun's give_item).
*/
native cs_set_no_knives(noknives = 0);
/* Spawns a Counter-Strike player
*/
native cs_user_spawn(player);
/* Get what weapon type (CSW_*) an armoury_entity is.
*/
native cs_get_armoury_type(index);
/* Set an armoury_entity to be of specified type. You will have to set the appropriate model.
* The second argument, type, should be a CSW_* constant. Not all weapons are supported by Counter-strike.
* Supported weapons/items: CSW_MP5NAVY, CSW_TMP, CSW_P90, CSW_MAC10, CSW_AK47, CSW_SG552, CSW_M4A1, CSW_AUG, CSW_SCOUT
* CSW_G3SG1, CSW_AWP, CSW_M3, CSW_XM1014, CSW_M249, CSW_FLASHBANG, CSW_HEGRENADE, CSW_VEST, CSW_VESTHELM, CSW_SMOKEGRENADE
*/
native cs_set_armoury_type(index, type);
#define CS_MAPZONE_BUY (1<<0)
#define CS_MAPZONE_BOMBTARGET (1<<1)
#define CS_MAPZONE_HOSTAGE_RESCUE (1<<2)
#define CS_MAPZONE_ESCAPE (1<<3)
#define CS_MAPZONE_VIP_SAFETY (1<<4)
/* Returns in bitwise form if the user is in a specific map zone.
* NOTE: If user can't plant (cs_get_user_plant(index) is 0) then cs_get_user_mapzones(index) & CS_MAPZONE_BOMBTARGET will return 0 too.
*/
native cs_get_user_mapzones(index);
/* Zoom type enum. Used for get/set_user_zoom() natives.
*/
enum
{
CS_RESET_ZOOM = 0, // Reset any zoom blocking (when using this type, mode has no effect)
CS_SET_NO_ZOOM, // Disable any sort of zoom (ie: to disable zoom in all weapons use this with mode=0)
CS_SET_FIRST_ZOOM, // Set first zoom (awp style)
CS_SET_SECOND_ZOOM, // Set second zoom (awp style)
CS_SET_AUGSG552_ZOOM, // Set aug/sg552 zoom style
};
/* Sets a weapon zoom type on a player, any zoom type will work for all weapons, so you can even set an awp zoom to pistols :D
* The 2nd param has to be one of the above zoom types in the enum. Mode can only be 0 or 1.
* If mode=0 (blocking mode), the user will be forced to use the zoom type set by the native, and wont be able to change it (even by changing weapon)
* until the native resets the zoom with CS_RESET_ZOOM.
* If mode=1 the user will be able to restore back to a normal view by changing weapon.
*/
native cs_set_user_zoom(index, type, mode);
/* Returns how a user is zooming during the native call. Values correspond to the above enum, but will return 0 if an error occurred.
*/
native cs_get_user_zoom(index);
/* Returns the submodel setting of the player.
* If this is 1, then the user has a backpack or defuser on their model (depending on team)
*/
native cs_get_user_submodel(index);
/* Sets the submodel setting of the player.
* If this is 1, then the user has a backpack or defuser on their model (depending on team)
* 0 removes it.
*/
native cs_set_user_submodel(index, value);
/* Gets or sets the user's last activity time. This is the time that CS's internal afk kicker
* checks to see who has been afk too long.
*/
native Float:cs_get_user_lastactivity(index);
native cs_set_user_lastactivity(index, Float:value);
/* Gets or sets the number of hostages that a user has killed.
*/
native cs_get_user_hostagekills(index);
native cs_set_user_hostagekills(index, value);
/* Gets or sets the time that the hostage was last used.
*/
native Float:cs_get_hostage_lastuse(index);
native cs_set_hostage_lastuse(index, Float:value);
/* Gets or sets the time which the hostage can next be used.
*/
native Float:cs_get_hostage_nextuse(index);
native cs_set_hostage_nextuse(index, Float:value);
/* Gets or sets the time in which the C4 will explode.
*/
native Float:cs_get_c4_explode_time(index);
native cs_set_c4_explode_time(index, Float:value);
/* Gets or sets whether the C4 is being defused.
*/
native bool:cs_get_c4_defusing(c4index);
native cs_set_c4_defusing(c4index, bool:defusing);
/**
* Called when CS internally fires a command to a player. It does this for a few
* functions, most notably rebuy/autobuy functionality. This is also used to pass
* commands to CZ bots internally.
*
* @param id Client index.
* @param cmd Command string.
* @return PLUGIN_HANDLED to block, PLUGIN_CONTINUE for normal operation.
*/
forward CS_InternalCommand(id, const cmd[]);

View File

@@ -0,0 +1,68 @@
/* CSX functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _csx_included
#endinput
#endif
#define _csx_included
#include <csstats>
#if AMXX_VERSION_NUM >= 175
#pragma reqclass xstats
#if !defined AMXMODX_NOAUTOLOAD
#pragma defclasslib xstats csx
#endif
#else
#pragma library csx
#endif
/*
* Forwards
*/
/* Function is called after player to player attacks ,
* if players were damaged by teammate TA is set to 1 */
forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA);
/* Function is called after player death ,
* if player was killed by teammate TK is set to 1 */
forward client_death(killer,victim,wpnindex,hitplace,TK);
forward grenade_throw( index,greindex,wId );
forward bomb_planting(planter);
forward bomb_planted(planter);
forward bomb_explode(planter,defuser);
forward bomb_defusing(defuser);
forward bomb_defused(defuser);
/************* Shared Natives Start ********************************/
/* Custom Weapon Support */
/* function will return index of new weapon */
native custom_weapon_add( const wpnname[],melee = 0,const logname[]="" );
/* Function will pass damage done by this custom weapon to stats module and other plugins */
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
/* Function will pass info about custom weapon shot to stats module */
native custom_weapon_shot( weapon,index ); // weapon id , player id
/* function will return 1 if true */
native xmod_is_melee_wpn(wpnindex);
/* Returns weapon name. */
native xmod_get_wpnname(wpnindex,name[],len);
/* Returns weapon logname. */
native xmod_get_wpnlogname(wpnindex,name[],len);
/* Returns weapons array size */
native xmod_get_maxweapons();
/* Returns stats array size */
native xmod_get_stats_size();
/************* Shared Natives End ********************************/

View File

@@ -0,0 +1,145 @@
/* SQL Database API
* By the AMX Mod X Development Team
* Notes - Read the comments! Make sure your plugins use
* nice ANSI SQL and don't use database column names like "key"
* otherwise this API will be a nightmare
* Never do error checking with the not operator! This is bad:
* if (!dbi_query())
* You should do:
* ret = dbi_query()
* if (ret < 0)
* This is because DBI functions can and will return negative numbers
* Negative numbers evaluate to "true" in AMX.
*/
#if defined _dbi_included
#endinput
#endif
#define _dbi_included
// You can't include SQLX first!
// there's really no reason to anyway.
#assert !defined _sqlx_included
#if AMXX_VERSION_NUM >= 175
#pragma reqclass dbi
#else
#pragma library dbi
#endif
enum Sql
{
SQL_FAILED=0,
SQL_OK
};
enum Result
{
RESULT_FAILED=-1,
RESULT_NONE,
RESULT_OK
};
/* This will return a number equal to or below 0 on failure.
* If it does fail, the error will be mirrored in dbi_error()
* The return value will otherwise be a resource handle, not an
* OK code or cell pointer.
*/
native Sql:dbi_connect(_host[], _user[], _pass[], _dbname[], _error[]="", _maxlength=0);
/* This will do a simple query execution on the SQL server.
* If it fails, it will return a number BELOW ZERO (0)
* If zero, it succeeded with NO RETURN RESULT.
* If greater than zero, make sure to call dbi_free_result() on it!
* The return is a handle to the result set
*/
native Result:dbi_query(Sql:_sql, _query[], any:...);
/* Has the same usage as dbi_query, but this native returns by
* reference the number of rows affected in the query. If the
* query fails rows will be equal to -1.
*/
native Result:dbi_query2(Sql:_sql, &rows, _query[], any:...);
/* Returns 0 on failure or End of Results.
* Advances result pointer by one row.
*/
native dbi_nextrow(Result:_result);
/* Gets a field by number. Returns 0 on failure.
* Although internally fields always start from 0,
* This function takes fieldnum starting from 1.
* No extra params: returns int
* One extra param: returns Float: byref
* Two extra param: Stores string with length
*/
native dbi_field(Result:_result, _fieldnum, {Float,_}:... );
/* Gets a field by name. Returns 0 on failure.
* One extra param: returns Float: byref
* Two extra param: Stores string with length
*/
native dbi_result(Result:_result, _field[], {Float,_}:... );
/* Returns the number of rows returned from a query
*/
native dbi_num_rows(Result:_result);
/* Frees memory used by a result handle. Do this or get memory leaks.
*/
native dbi_free_result(&Result:result);
/* Closes a database handle. Internally, it will also
* mark the handle as free, so this particular handle may
* be re-used in the future to save time.
*/
native dbi_close(&Sql:_sql);
/* Returns an error message set. For PGSQL and MySQL,
* this is a direct error return from the database handle/API.
* For MSSQL, it returns the last error message found from a
* thrown exception.
*/
native dbi_error(Sql:_sql, _error[], _len);
/* Returns the type of database being used. So far:
* "mysql", "pgsql", "mssql", "sqlite"
*/
native dbi_type(_type[], _len);
/* Returns the number of fields/colums in a result set.
* Unlike dbi_nextrow, you must pass a valid result handle.
*/
native dbi_num_fields(Result:result);
/* Retrieves the name of a field/column in a result set.
* Requires a valid result handle, and columns are numbered 1 to n.
*/
native dbi_field_name(Result:result, field, name[], maxLength);
/* This function can be used to find out if a table in a Sqlite database exists.
*/
stock bool:sqlite_table_exists(Sql:sql, table[])
{
new bool:exists;
new query[128];
format(query, 127, "SELECT name FROM sqlite_master WHERE type='table' AND name='%s' LIMIT 1;", table);
new Result:result = dbi_query(sql, query);
if (dbi_nextrow(result))
{
exists = true;
}
else
{
exists = false;
}
if (result > RESULT_NONE)
{
dbi_free_result(result);
}
return exists;
}

View File

@@ -0,0 +1,135 @@
/* DoDX functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _dodconst_included
#endinput
#endif
#define _dodconst_included
/* DoD teams */
#define ALLIES 1
#define AXIS 2
#define FT_NEW 1<<0
#define FT_OLD 1<<1
#define STAMINA_SET 0
#define STAMINA_RESET 1
#define FUSE_SET 0
#define FUSE_RESET 1
#define DODMAX_WEAPONS 46 // 5 slots for custom weapons
// DoD Weapon Types
enum
{
DODWT_PRIMARY = 0,
DODWT_SECONDARY,
DODWT_MELEE,
DODWT_GRENADE,
DODWT_OTHER
};
// Ammo Channels
#define AMMO_SMG 1 // thompson, greasegun, sten, mp40
#define AMMO_ALTRIFLE 2 // carbine, k43, mg34
#define AMMO_RIFLE 3 // garand, enfield, scoped enfield, k98, scoped k98
#define AMMO_PISTOL 4 // colt, webley, luger
#define AMMO_SPRING 5 // springfield
#define AMMO_HEAVY 6 // bar, bren, stg44, fg42, scoped fg42
#define AMMO_MG42 7 // mg42
#define AMMO_30CAL 8 // 30cal
#define AMMO_GREN 9 // grenades (should be all 3 types)
#define AMMO_ROCKET 13 // bazooka, piat, panzerschreck
enum {
PS_NOPRONE =0,
PS_PRONE,
PS_PRONEDEPLOY,
PS_DEPLOY,
};
/* info types for dod_get_map_info native */
enum {
MI_ALLIES_TEAM = 0,
MI_ALLIES_PARAS,
MI_AXIS_PARAS,
};
/* DoD weapons */
enum {
DODW_AMERKNIFE = 1,
DODW_GERKNIFE,
DODW_COLT,
DODW_LUGER,
DODW_GARAND,
DODW_SCOPED_KAR,
DODW_THOMPSON,
DODW_STG44,
DODW_SPRINGFIELD,
DODW_KAR,
DODW_BAR,
DODW_MP40,
DODW_HANDGRENADE,
DODW_STICKGRENADE,
DODW_STICKGRENADE_EX,
DODW_HANDGRENADE_EX,
DODW_MG42,
DODW_30_CAL,
DODW_SPADE,
DODW_M1_CARBINE,
DODW_MG34,
DODW_GREASEGUN,
DODW_FG42,
DODW_K43,
DODW_ENFIELD,
DODW_STEN,
DODW_BREN,
DODW_WEBLEY,
DODW_BAZOOKA,
DODW_PANZERSCHRECK,
DODW_PIAT,
DODW_SCOPED_FG42,
DODW_FOLDING_CARBINE,
DODW_KAR_BAYONET,
DODW_SCOPED_ENFIELD,
DODW_MILLS_BOMB,
DODW_BRITKNIFE,
DODW_GARAND_BUTT,
DODW_ENFIELD_BAYONET,
DODW_MORTAR,
DODW_K43_BUTT,
};
/* DoD Classes */
enum {
DODC_GARAND = 1,
DODC_CARBINE,
DODC_THOMPSON,
DODC_GREASE,
DODC_SNIPER,
DODC_BAR,
DODC_30CAL,
DODC_BAZOOKA,
//DODC_ALLIES_MORTAR,
DODC_KAR = 10,
DODC_K43,
DODC_MP40,
DODC_MP44,
DODC_SCHARFSCHUTZE,
DODC_FG42,
DODC_SCOPED_FG42,
DODC_MG34,
DODC_MG42,
DODC_PANZERJAGER,
//DODC_AXIS_MORTAR,
DODC_ENFIELD = 21,
DODC_STEN,
DODC_MARKSMAN,
DODC_BREN,
DODC_PIAT,
//DODC_BRIT_MORTAR,
};

View File

@@ -0,0 +1,149 @@
/* DoDFun functions
*
* (c) 2004-2005, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _dodfun_included
#endinput
#endif
#define _dodfun_included
#include <dodconst>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib dodfun
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib dodfun
#endif
#else
#pragma library dodfun
#endif
/* Function is called after grenade throw */
forward grenade_throw(index,greindex,wId);
/* Function is called after a rocket is shot */
forward rocket_shoot(index,rocketindex,wId);
/* Example: for full stamina use dod_player_stamina(1,STAMINA_SET,100,100) */
/* value is from 0 - 100 */
native dod_set_stamina(index,set=STAMINA_SET,minvalue=0,maxvalue=100);
/* Sets fuse for grenades. Valid number is from 0.1-20.0 */
/* types : new or preprimed */
native dod_set_fuse(index,set=FUSE_SET,Float:newFuse=5.0, Type=FT_NEW);
/* Sets player class */
native dod_set_user_class(index,classId);
/* Sets player team and random class. Don't work for spectators. */
native dod_set_user_team(index,teamId,refresh=1);
/* Returns next player class. Usefull is player is using random class */
native dod_get_next_class(index);
/* Returns 1 if player choose random class */
native dod_is_randomclass(index);
/* Returns player deaths */
native dod_get_pl_deaths(index);
/* Sets player deaths.
* Note if you opt to refresh the scoreboard, it
* will make the player appear as "DEAD" in the scoreboard.
*/
native dod_set_pl_deaths(index,value,refresh=1);
/* Returns player deaths. */
native dod_get_user_kills(index);
/* Sets player kills. */
native dod_set_user_kills(index,value,refresh=1);
/* Sets player score. */
native dod_set_user_score(index,value,refresh=1);
/* Sets new team name for this player */
native dod_set_pl_teamname(index,const szName[]);
/* Gets player team name */
native dod_get_pl_teamname(index,szName[],len);
/* Returns 1 is player weapon is deployed (bar,mg..) */
native dod_is_deployed(index);
/*Sets the ammo of the specified weapon entity id */
native dod_set_user_ammo(index,wid,value);
/*Gets the ammo of the specified weapon entity id */
native dod_get_user_ammo(index,wid);
/* called after first InitObj */
forward controlpoints_init();
enum CP_VALUE {
CP_edict = 1, // read only
CP_area, // read only
CP_index, // read only
CP_owner,
CP_default_owner,
CP_visible, // reinit after change
CP_icon_neutral, // reinit after change
CP_icon_allies, // reinit after change
CP_icon_axis, // reinit after change
CP_origin_x, // reinit after change
CP_origin_y, // reinit after change
CP_can_touch,
CP_pointvalue,
CP_points_for_cap,
CP_team_points,
CP_model_body_neutral,
CP_model_body_allies,
CP_model_body_axis,
// strings
CP_name,
CP_reset_capsound,
CP_allies_capsound,
CP_axis_capsound,
CP_targetname,
CP_model_neutral,
CP_model_allies,
CP_model_axis,
};
/* returns number of objectives */
native objectives_get_num();
/* use this function to update client(s) hud. You need to do this sometimes. Check CP_VALUE comments.
if player is 0 , all clients will get this message */
native objectives_reinit( player=0 );
/* use this function to get info about specified control point */
native objective_get_data( index, CP_VALUE:key, szValue[]="", len=0 );
/* use this function to change control point's data */
native objective_set_data( index, CP_VALUE:key , iValue=-1, const szValue[]="" );
enum CA_VALUE {
CA_edict = 1,
CA_allies_numcap,
CA_axis_numcap,
CA_timetocap,
CA_can_cap,
// strings
CA_target,
CA_sprite,
};
/* use this function to get info about specified control point's area */
native area_get_data( index, CA_VALUE:key, szValue[]="", len=0 );
/* use this function to change control point's area data */
native area_set_data( index, CA_VALUE:key , iValue=-1, const szValue[]="" );

View File

@@ -0,0 +1,62 @@
/* DoDX Stats functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _dodstats_included
#endinput
#endif
#define _dodstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* 7 - score
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[9],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[9],bodyhits[8]);
/* Gets life (from spawn to spawn) stats from given weapon index.*/
native get_user_wlstats(index,wpnindex,stats[9],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[9],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[9],bodyhits[8]);
/* Gets life (from spawn to spawn) stats of player. */
native get_user_lstats(index,stats[9],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[9],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[9],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[9],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();

View File

@@ -0,0 +1,158 @@
/* DoDX functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _dodx_included
#endinput
#endif
#define _dodx_included
#include <dodconst>
#include <dodstats>
#if AMXX_VERSION_NUM >= 175
#pragma reqclass xstats
#if !defined AMXMODX_NOAUTOLOAD
#pragma defclasslib xstats dodx
#endif
#else
#pragma library dodx
#endif
/************* Shared Natives Start ********************************/
/* Forward types */
enum {
XMF_DAMAGE = 0,
XMF_DEATH,
XMF_SCORE,
};
/* Use this function to register forwards */
native register_statsfwd(ftype);
/* Function is called after player to player attacks ,
* if players were damaged by teammate TA is set to 1 */
forward client_damage(attacker, victim, damage, wpnindex, hitplace, TA);
/* Function is called after player death ,
* if player was killed by teammate TK is set to 1 */
forward client_death(killer, victim, wpnindex, hitplace, TK);
/* Function is called if player scored */
forward client_score(id, score, total);
/* This Forward is called when a player changes team */
forward dod_client_changeteam(id, team, oldteam);
/* This Forward is called if a player changes class, but just after spawn */
forward dod_client_changeclass(id, class, oldclass);
/* This Forward is called when a player spawns */
forward dod_client_spawn(id);
/* This will be called whenever a player scopes or unscopes
value = 1 scope up
value = 0 scope down */
forward dod_client_scope(id, value);
/* This will be called whenever a player drops a weapon
weapon is weapon dropped or picked up
value = 1 picked up
value = 0 dropped */
forward dod_client_weaponpickup(id, weapon, value);
/* Called whenever the the player goes to or comes from prone position
value = 1 going down
value = 0 getting up */
forward dod_client_prone(id, value);
/* This will be called whenever a player switches a weapon */
forward dod_client_weaponswitch(id, wpnew, wpnold);
/* Forward for when a grenade explodes and its location */
forward dod_grenade_explosion(id, pos[3], wpnid);
/* Forward for when a rocket explodes and its location */
forward dod_rocket_explosion(id, pos[3], wpnid);
/* Forward for when a player picks up a object */
forward dod_client_objectpickup(id, objid, pos[3], value);
/* Forward for when a users stamina decreases */
forward dod_client_stamina(id, stamina);
/* We want to get just the weapon of whichever type that the player is on him
Use DODWT_* in dodconst.inc for type */
native dod_weapon_type(id, type);
/* This native will change the position of a weapon within the users slots and its ammo ammount */
native dod_set_weaponlist(id, wpnID, slot, dropslot, totalrds);
/* Sets the model for a player */
native dod_set_model(id, const model[]);
/* Sets the model for a player */
native dod_set_body_number(id, bodynumber);
/* Un-Sets the model for a player */
native dod_clear_model(id);
/* Custom Weapon Support */
/* function will return index of new weapon */
native custom_weapon_add( const wpnname[], melee = 0, const logname[]="" );
/* Function will pass damage done by this custom weapon to stats module and other plugins */
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
/* Function will pass info about custom weapon shot to stats module */
native custom_weapon_shot( weapon, index ); // weapon id , player id
/* function will return 1 if true */
native xmod_is_melee_wpn(wpnindex);
/* Returns weapon name. */
native xmod_get_wpnname(wpnindex, name[], len);
/* Returns weapon logname. */
native xmod_get_wpnlogname(wpnindex, name[], len);
/* Returns weapons array size */
native xmod_get_maxweapons();
/* Returns stats array size ex. 8 in TS , 9 in DoD */
native xmod_get_stats_size();
/* Returns 1 if true */
native xmod_is_custom_wpn(wpnindex);
/************* Shared Natives End ********************************/
/* weapon logname to weapon name convertion */
native dod_wpnlog_to_name(const logname[],name[],len);
/* weapon logname to weapon index convertion */
native dod_wpnlog_to_id(const logname[]);
native dod_get_map_info( info );
/* Returns id of currently carried weapon. Gets also
* ammount of ammo in clip and backpack. */
native dod_get_user_weapon(index,&clip=0,&ammo=0);
/* Returns team score */
native dod_get_team_score(teamId);
/* Returns player class id */
native dod_get_user_class(index);
/* Returns player score */
native dod_get_user_score(index);
/* values are: 0-no prone, 1-prone, 2-prone + w_deploy */
native dod_get_pronestate(index);
/* It is not as safe as original but player deaths will not be increased */
native dod_user_kill(index);

View File

@@ -0,0 +1,241 @@
/* Engine functions
*
* by the AMX Mod X Development Team
* thanks to Vexd and mahnsawce
*
* This file is provided as is (no warranties).
*/
#if defined _engine_included
#endinput
#endif
#define _engine_included
#include <engine_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib engine
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib engine
#endif
#else
#pragma library engine
#endif
native traceresult(type,any:...);
/* Registers a client impulse to a function. Function is passed the ID of the user. */
native register_impulse(impulse, const function[]);
/* Registers a touch action to a function by classnames. Use * to specify any classname. */
native register_touch(const Touched[], const Toucher[], const function[]);
/* Registers a think action to a function by classname. */
native register_think(const Classname[], const function[]);
/* NOTE: In old engine versions, this was not the case. Values are now WINDOWS values.
* You must pass with the windows offset (e.g. if 230 on windows, pass 230 no matter what)
* The module will automatically add +5 for Linux.
*/
/* Precaches an event. */
native precache_event(type, const Name[], any:...);
/* set/get a user's speak flags */
native set_speak(iIndex, iSpeakFlags);
native get_speak(iIndex);
/* Drops an entity to the floor (work?) */
native drop_to_floor(entity);
/* Get whole buffer containing keys and their data. */
native get_info_keybuffer(id, buffer[], length);
/* Use an entity with another entity. "entUsed" could be a hostage, "entUser" a player. */
native force_use(entUsed, entUser);
/* Get globals from server. */
native Float:get_global_float(variable);
native get_global_int(variable);
native get_global_string(variable, string[], maxlen);
native get_global_vector(variable, Float:vector[3]);
native get_global_edict(variable);
/* Set entity bounds. */
native entity_set_size(index, const Float:mins[3], const Float:maxs[3]);
/* Get decal index */
native get_decal_index(const szDecalName[]);
/* Returns the distance between two entities. */
native Float:entity_range(ida,idb);
/* Sets/gets things in an entities Entvars Struct. */
native entity_get_int(iIndex, iKey);
native entity_set_int(iIndex, iKey, iVal);
native Float:entity_get_float(iIndex, iKey);
native entity_set_float(iIndex, iKey, Float:iVal);
native entity_get_vector(iIndex, iKey, Float:vRetVector[3]);
native entity_set_vector(iIndex, iKey, const Float:vNewVector[3]);
native entity_get_edict(iIndex, iKey);
native entity_set_edict(iIndex, iKey, iNewIndex);
native entity_get_string(iIndex, iKey, szReturn[], iRetLen);
native entity_set_string(iIndex, iKey, const szNewVal[]);
native entity_get_byte(iIndex, iKey);
native entity_set_byte(iIndex, iKey, iVal);
/* Creates an entity, will return the index of the created entity. ClassName must be valid. */
native create_entity(const szClassname[]);
/* Finds an entity in the world, will return 0 if nothing is found */
native find_ent_by_class(iIndex, const szClass[]);
//optionally you can set a jghg2 type
// 1: target, 2:targetname, 0:classname (default)
native find_ent_by_owner(iIndex, const szClass[], iOwner, iJghgType=0);
native find_ent_by_target(iIndex, const szClass[]);
native find_ent_by_tname(iIndex, const szClass[]);
native find_ent_by_model(iIndex, const szClass[], const szModel[]);
native find_ent_in_sphere(start_from_ent, const Float:origin[3], Float:radius);
//this will CBaseEntity::Think() or something from the entity
native call_think(entity);
/* Is entity valid? */
native is_valid_ent(iIndex);
/* Proper origin setting, keeps updated with Half-Life engine. */
native entity_set_origin(iIndex, const Float:fNewOrigin[3]);
/* Sets the model of an Entity. */
native entity_set_model(iIndex, const szModel[]);
/* Remove an entity from the world. */
native remove_entity(iIndex);
/* Return current number of entities in the map */
native entity_count();
/* Simulate two entities colliding/touching. */
native fake_touch(entTouched, entToucher);
/* 2 formats.
Format: DispatchKeyValue("KeyName","Value") - sets keyvalues for the entity specified in the keyvalue() forward.
Format: DispatchKeyValue(index,"KeyName","Value") - Sets keyvalue for entity not specified in keyvalue() forward. */
#if !defined AMXMOD_BCOMPAT
native DispatchKeyValue(...);
#endif
native get_keyvalue(entity, const szKey[], value[], maxLength);
native copy_keyvalue(szClassName[],sizea,szKeyName[],sizeb,szValue[],sizec);
/* Runs the GameDLL's DispatchSpawn for an entity, I think it's used with DispatchKeyValue. */
native DispatchSpawn(iIndex);
/* Hurts/Kills players in a sphere, like an explosion, Multiplier determines damage. */
#if !defined AMXMOD_BCOMPAT
native radius_damage(const Float:fExplodeAt[3], iDamageMultiplier, iRadiusMultiplier);
#endif
/* Will return the contents of a point (inside map? in sky? outside map? etc.). */
native point_contents(const Float:fCheckAt[3]);
/* Trace a line from Start(X, Y, Z) to End(X, Y, Z), will return the point hit in vReturn[3]
* and an entity index if an entity is hit. */
#if !defined AMXMOD_BCOMPAT
native trace_line(iIgnoreEnt, const Float:fStart[3], const Float:fEnd[3], Float:vReturn[3]);
#endif
/* Traces a hull. */
native trace_hull(const Float:origin[3],hull,ignoredent=0,ignoremonsters=0);
/* Traces a line, and returns the normal to the plane hit in vReturn.
* Returns 0 if theres no normal. */
native trace_normal(iIgnoreEnt, const Float:fStart[3], const Float:fEnd[3], Float:vReturn[3]);
/* Gets the ID of a grenade. */
native get_grenade_id(id, model[], len, grenadeid = 0);
/* Gets gpGlobals->time from Half-Life */
native Float:halflife_time();
/* Sets map lighting, #OFF to disable. */
native set_lights(const Lighting[]);
/* Sets Player's View to entity iTargetIndex. */
native attach_view(iIndex, iTargetIndex);
/* Sets Player's View Mode.
* rpgrocket.mdl must be precached in order for this function to work */
native set_view(iIndex, ViewType);
/* Direct copy of PLAYBACK_EVENT_FULL from Metamod/HLSDK. If you don't know how that works, you probably shouldn't be using it. */
native playback_event(flags,invoker,eventindex,Float:delay,const Float:origin[3],const Float:angles[3],Float:fparam1,Float:fparam2,iparam1,iparam2,bparam1,bparam2);
/* Gets parameters sent from CmdStart.
Note that you will receive modified values if any other plugin have
changed them. */
native get_usercmd(type,any:...);
/* Sets the parameters sent from CmdStart.
Note that your changes will be seen by any other plugin doing get_usercmd() */
native set_usercmd(type,any:...);
/* Converts a string offset into a real string. Some of the forwards in fakemeta
uses string offsets. (FM_CreateNamedEntity) */
native eng_get_string(_string, _returnString[], _len);
/* FORWARDS
**********/
/* Called when 2 entities touch.
* ptr - touched entity
* ptd - toucher entity
*/
forward pfn_touch(ptr, ptd);
/* Called once every server frame. May cause lag. */
forward server_frame();
/* Called when a client types kill in console. */
forward client_kill(id);
/* Forward for PreThink()/PostThink() on a player. */
forward client_PreThink(id);
forward client_PostThink(id);
/* Forward for impulses. */
forward client_impulse(id, impulse);
/* Called when an entity "thinks" (DispatchThink) */
forward pfn_think(entid);
/* Called when an event is played */
forward pfn_playbackevent(flags, entid, eventid, Float:delay, Float:Origin[3], Float:Angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2);
/* Called when an entity gets a keyvalue set on it from the engine (ie: map load) Use copy_keyvalue to get the keyvalue information */
forward pfn_keyvalue(entid);
/* Called when an entity is spawned */
forward pfn_spawn(entid);
//from jghg2
/* As above, but returns number of ents stored in entlist. Use to find a specific type of entity classname (specify in _lookforclassname) around a
* certain entity specified in aroundent. All matching ents are stored in entlist. Specify max amount of entities to find in maxents.
* If aroundent is 0 its origin is not used, but origin in 6th parameter. Ie, do not specify 6th parameter (origin) if you specified an entity
* in aroundent.
*/
native find_sphere_class(aroundent, const _lookforclassname[], Float:radius, entlist[], maxents, const Float:origin[3] = {0.0, 0.0, 0.0});
/* SDK function - checks if an origin is in an entity's view cone
* Set use3d to 1 to do the calculation in 3D. Otherwise it will be in 2D.
*/
native is_in_viewcone(entity, const Float:origin[3], use3d = 0);
//SDK function - checks if an entity is visible to an entity
native is_visible(entity, target);
//Added at twistedeuphoria's request, see funcwiki for details
native trace_forward(const Float:start[3], const Float:angle[3], Float:give, ignoreEnt, &Float:hitX, &Float:hitY, &Float:shortestDistance, &Float:shortestDistLow, &Float:shortestDistHigh);
#include <engine_stocks>

View File

@@ -0,0 +1,261 @@
/* Engine constants
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _engine_const_included
#endinput
#endif
#define _engine_const_included
#include <hlsdk_const>
#define SPEAK_NORMAL 0
#define SPEAK_MUTED 1
#define SPEAK_ALL 2
#define SPEAK_LISTENALL 4
#define CAMERA_NONE 0
#define CAMERA_3RDPERSON 1
#define CAMERA_UPLEFT 2
#define CAMERA_TOPDOWN 3
/* Int */
enum {
EV_INT_gamestate = 0,
EV_INT_oldbuttons,
EV_INT_groupinfo,
EV_INT_iuser1,
EV_INT_iuser2,
EV_INT_iuser3,
EV_INT_iuser4,
EV_INT_weaponanim,
EV_INT_pushmsec,
EV_INT_bInDuck,
EV_INT_flTimeStepSound,
EV_INT_flSwimTime,
EV_INT_flDuckTime,
EV_INT_iStepLeft,
EV_INT_movetype,
EV_INT_solid,
EV_INT_skin,
EV_INT_body,
EV_INT_effects,
EV_INT_light_level,
EV_INT_sequence,
EV_INT_gaitsequence,
EV_INT_modelindex,
EV_INT_playerclass,
EV_INT_waterlevel,
EV_INT_watertype,
EV_INT_spawnflags,
EV_INT_flags,
EV_INT_colormap,
EV_INT_team,
EV_INT_fixangle,
EV_INT_weapons,
EV_INT_rendermode,
EV_INT_renderfx,
EV_INT_button,
EV_INT_impulse,
EV_INT_deadflag,
};
/* Float */
enum {
EV_FL_impacttime = 0,
EV_FL_starttime,
EV_FL_idealpitch,
EV_FL_pitch_speed,
EV_FL_ideal_yaw,
EV_FL_yaw_speed,
EV_FL_ltime,
EV_FL_nextthink,
EV_FL_gravity,
EV_FL_friction,
EV_FL_frame,
EV_FL_animtime,
EV_FL_framerate,
EV_FL_health,
EV_FL_frags,
EV_FL_takedamage,
EV_FL_max_health,
EV_FL_teleport_time,
EV_FL_armortype,
EV_FL_armorvalue,
EV_FL_dmg_take,
EV_FL_dmg_save,
EV_FL_dmg,
EV_FL_dmgtime,
EV_FL_speed,
EV_FL_air_finished,
EV_FL_pain_finished,
EV_FL_radsuit_finished,
EV_FL_scale,
EV_FL_renderamt,
EV_FL_maxspeed,
EV_FL_fov,
EV_FL_flFallVelocity,
EV_FL_fuser1,
EV_FL_fuser2,
EV_FL_fuser3,
EV_FL_fuser4,
};
/* Vector */
enum {
EV_VEC_origin = 0,
EV_VEC_oldorigin,
EV_VEC_velocity,
EV_VEC_basevelocity,
EV_VEC_clbasevelocity,
EV_VEC_movedir,
EV_VEC_angles,
EV_VEC_avelocity,
EV_VEC_punchangle,
EV_VEC_v_angle,
EV_VEC_endpos,
EV_VEC_startpos,
EV_VEC_absmin,
EV_VEC_absmax,
EV_VEC_mins,
EV_VEC_maxs,
EV_VEC_size,
EV_VEC_rendercolor,
EV_VEC_view_ofs,
EV_VEC_vuser1,
EV_VEC_vuser2,
EV_VEC_vuser3,
EV_VEC_vuser4,
};
/* Edict */
enum {
EV_ENT_chain = 0,
EV_ENT_dmg_inflictor,
EV_ENT_enemy,
EV_ENT_aiment,
EV_ENT_owner,
EV_ENT_groundentity,
EV_ENT_pContainingEntity,
EV_ENT_euser1,
EV_ENT_euser2,
EV_ENT_euser3,
EV_ENT_euser4,
};
/* String */
enum {
EV_SZ_classname = 0,
EV_SZ_globalname,
EV_SZ_model,
EV_SZ_target,
EV_SZ_targetname,
EV_SZ_netname,
EV_SZ_message,
EV_SZ_noise,
EV_SZ_noise1,
EV_SZ_noise2,
EV_SZ_noise3,
EV_SZ_viewmodel,
EV_SZ_weaponmodel,
};
/* Byte */
enum {
EV_BYTE_controller1 = 0,
EV_BYTE_controller2,
EV_BYTE_controller3,
EV_BYTE_controller4,
EV_BYTE_blending1,
EV_BYTE_blending2,
};
#if defined _jghg_enums
#endinput
#endif
#define _jghg_enums
enum {
// Edict
GL_trace_ent = 0,
// Float
GL_coop,
GL_deathmatch,
GL_force_retouch,
GL_found_secrets,
GL_frametime,
GL_serverflags,
GL_teamplay,
GL_time,
GL_trace_allsolid,
GL_trace_fraction,
GL_trace_inopen,
GL_trace_inwater,
GL_trace_plane_dist,
GL_trace_startsolid,
// Int
GL_cdAudioTrack,
GL_maxClients,
GL_maxEntities,
GL_msg_entity,
GL_trace_flags,
GL_trace_hitgroup,
// String
GL_pStringBase,
GL_mapname,
GL_startspot,
// Vector
GL_trace_endpos,
GL_trace_plane_normal,
GL_v_forward,
GL_v_right,
GL_v_up,
GL_vecLandmarkOffset,
// Void (not supported)
GL_pSaveData
};
enum
{
usercmd_float_start,
usercmd_forwardmove, // Float
usercmd_sidemove, // Float
usercmd_upmove, // Float
usercmd_float_end,
usercmd_int_start,
usercmd_lerp_msec, // short
usercmd_msec, // byte
usercmd_lightlevel, // byte
usercmd_buttons, // unsigned short
usercmd_impulse, // byte
usercmd_weaponselect, // byte
usercmd_impact_index, // int
usercmd_int_end,
usercmd_vec_start,
usercmd_viewangles, // Vector
usercmd_impact_position, // vec
usercmd_vec_end
};
// Used by the traceresult() native.
enum
{
TR_AllSolid, // (int) if true, plane is not valid
TR_StartSolid, // (int) if true, the initial point was in a solid area
TR_InOpen, // (int)
TR_InWater, // (int)
TR_Fraction, // (float) time completed, 1.0 = didn't hit anything
TR_EndPos, // (vector) final position
TR_PlaneDist, // (float)
TR_PlaneNormal, // (vector) surface normal at impact
TR_Hit, // (entity) entity the surface is on
TR_Hitgroup // (int) 0 == generic, non zero is specific body part
};

View File

@@ -0,0 +1,255 @@
/* Engine stocks
*
* by the AMX Mod X Development Team
* thanks to AssKicR, Freecode and T(+)rget
*
* This file is provided as is (no warranties).
*/
#if defined _engine_stocks_included
#endinput
#endif
#define _engine_stocks_included
#if !defined _amxmodx_included
#include <amxmodx>
#endif
#if !defined _engine_included
#include <engine>
#endif
stock fakedamage(idvictim,const szClassname[],Float:takedmgdamage,damagetype)
{
new entity = create_entity("trigger_hurt");
if (entity)
{
DispatchKeyValue(entity,"classname","trigger_hurt");
new szDamage[16];
// Takedamages only do half damage per attack (damage is damage per second, and it's triggered in 0.5 second intervals).
// Compensate for that.
format(szDamage,15,"%f",takedmgdamage * 2);
DispatchKeyValue(entity,"dmg",szDamage);
format(szDamage,15,"%i",damagetype);
DispatchKeyValue(entity,"damagetype",szDamage);
DispatchKeyValue(entity,"origin","8192 8192 8192");
DispatchSpawn(entity);
entity_set_string(entity, EV_SZ_classname, szClassname);
fake_touch(entity,idvictim);
remove_entity(entity);
return 1;
}
return 0;
}
//wrapper for find_ent_by_class
stock find_ent(iStart, const szClassname[])
{
return find_ent_by_class(iStart, szClassname);
}
/* Get the Button(s) user is pressing */
stock get_user_button(id)
{
return entity_get_int(id, EV_INT_button);
}
stock get_user_oldbutton(id)
{
return entity_get_int(id, EV_INT_oldbuttons);
}
/* Get flags an entity is flagged with */
stock get_entity_flags(ent)
{
return entity_get_int(ent, EV_INT_flags);
}
/* Get the distance between two entities */
stock get_entity_distance(ent1, ent2)
{
return floatround(entity_range(ent1, ent2));
}
/* Get grenade thrown by this user */
stock get_grenade(id)
{
new iGrenade = find_ent_by_class(-1, "grenade");
while(iGrenade > 0)
{
if(entity_get_edict(iGrenade, EV_ENT_owner) == id)
return iGrenade;
iGrenade = find_ent_by_class(iGrenade, "grenade");
}
return 0;
}
/* Get origin of a brush entity */
stock get_brush_entity_origin(ent, Float:orig[3])
{
new Float:Min[3], Float:Max[3];
entity_get_vector(ent, EV_VEC_origin, orig);
entity_get_vector(ent, EV_VEC_mins, Min);
entity_get_vector(ent, EV_VEC_maxs, Max);
orig[0] += (Min[0] + Max[0]) * 0.5;
orig[1] += (Min[1] + Max[1]) * 0.5;
orig[2] += (Min[2] + Max[2]) * 0.5;
return 1;
}
/* Remove entity by name */
stock remove_entity_name(const eName[])
{
new iEntity = find_ent_by_class(-1, eName);
while (iEntity > 0)
{
remove_entity(iEntity);
iEntity = find_ent_by_class(-1, eName);
}
return 1;
}
/* Get the contents of the point a user is aiming at */
stock ViewContents(id)
{
new origin[3], Float:Orig[3];
get_user_origin(id, origin, 3);
Orig[0] = float(origin[0]);
Orig[1] = float(origin[1]);
Orig[2] = float(origin[2]);
return point_contents(Orig);
}
stock get_speed(ent)
{
new Float:Vel[3];
entity_get_vector(ent, EV_VEC_velocity, Vel);
return floatround(vector_length(Vel));
}
/* Set rendering of an entity */
stock set_rendering(index, fx=kRenderFxNone, r=255, g=255, b=255, render=kRenderNormal, amount=16)
{
entity_set_int(index,EV_INT_renderfx,fx);
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);
entity_set_vector(index,EV_VEC_rendercolor,RenderColor);
entity_set_int(index,EV_INT_rendermode,render);
entity_set_float(index,EV_FL_renderamt,float(amount));
return 1;
}
/* Set flags on an entity */
stock set_entity_flags(ent,flag,onoff)
{
if ((entity_get_int(ent,EV_INT_flags)&flag) > 0)
{
if (onoff == 1)
{
return 2;
}
else
{
entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)-flag);
return 1;
}
}
else
{
if (onoff == 0)
{
return 2;
}
else
{
entity_set_int(ent,EV_INT_flags,entity_get_int(ent,EV_INT_flags)+flag);
return 1;
}
}
return 0;
}
/* If visible = 1, entity will be set to be visible, else invisible. */
stock set_entity_visibility(entity, visible = 1)
{
entity_set_int(entity, EV_INT_effects, visible == 1 ? entity_get_int(entity, EV_INT_effects) & ~EF_NODRAW : entity_get_int(entity, EV_INT_effects) | EF_NODRAW);
return 1;
}
/* Returns 1 if entity is visible. */
stock get_entity_visibility(entity)
{
return !(entity_get_int(entity, EV_INT_effects) & EF_NODRAW);
}
stock set_user_velocity(entity, const Float:vec[3])
{
return entity_set_vector(entity, EV_VEC_velocity, vec);
}
stock get_user_velocity(entity, Float:vec[3])
{
return entity_get_vector(entity, EV_VEC_velocity, vec);
}
/* Backwards compatible */
/* Hurts/Kills players in a sphere, like an explosion, Multiplier determines damage. */
stock RadiusDamage(const Float:fExplodeAt[3], iDamageMultiplier, iRadiusMultiplier)
{
return radius_damage(fExplodeAt, iDamageMultiplier, iRadiusMultiplier);
}
/* Gives you a velocity in the direction a player is looking, iVelocity is the multiplier. */
stock VelocityByAim(iIndex,iVelocity, Float:vRetValue[3])
{
return velocity_by_aim(iIndex,iVelocity,vRetValue);
}
/* Will return the contents of a point (inside map? in sky? outside map? etc.). */
stock PointContents(const Float:fCheckAt[3])
{
return point_contents(fCheckAt);
}
stock set_size(index, const Float:mins[3], const Float:maxs[3])
{
return entity_set_size(index,mins,maxs);
}
//by Twilight Suzuka, request addition at29428
//"Lifted from HLSDK"
stock IsInWorld( ent )
{
new Float:origin[3];
entity_get_vector(ent,EV_VEC_origin,origin);
if (origin[0] >= 4096.0) return 0;
if (origin[1] >= 4096.0) return 0;
if (origin[2] >= 4096.0) return 0;
if (origin[0] <= -4096.0) return 0;
if (origin[1] <= -4096.0) return 0;
if (origin[2] <= -4096.0) return 0;
new Float:velocity[3];
entity_get_vector(ent,EV_VEC_velocity,velocity);
if (velocity[0] >= 2000) return 0;
if (velocity[1] >= 2000) return 0;
if (velocity[2] >= 2000) return 0;
if (velocity[0] <= -2000) return 0;
if (velocity[1] <= -2000) return 0;
if (velocity[2] <= -2000) return 0;
return 1;
}

View File

@@ -0,0 +1,70 @@
/***********************************************
[ Corona-Bytes.NET ] EvolutionX Core Plugin
(c) Corona - Bytes .NET coders :: coders@corona-bytes.net
> 2005 Corona Bytes :: http://www.corona-bytes.net
***********************************************/
#if defined __EVOLUTION_CORE__
#endinput
#endif
#define __EVOLUTION_CORE__
#pragma library EvolutionXCore
native setClientPL ( Client, PowerLevel );
native getClientPL ( Client );
native setClientACPL ( Client, ActualPowerLevel );
native getClientACPL ( Client );
native setClientADPL ( Client, AfterDeathPowerLevel );
native getClientADPL ( Client );
native setClientSPL ( Client, PowerLevel );
native setClientPLtoADPL ( Client );
native setClientKI ( Client, Ki );
native getClientKI ( Client );
native setClientHP ( Client, Health );
native getClientHP ( Client );
native setClientMHP ( Client, MaximumHealth );
native getClientMHP ( Client );
native setClientSPEED ( Client, Speed );
native getClientSPEED ( Client );
native setClientSWOOPSPEED ( Client, SwoopSpeed );
native getClientSWOOPSPEED ( Client );
native setClientPROTECT ( Client, bool:Enable = true );
native getClientPROTECT ( Client );
native setClientFROZEN ( Client, bool:Enable = true );
native getClientFROZEN ( Client );
native setClientGOD ( Client, bool:Enable = true );
native getClientGOD ( Client );
native getClientFLY ( Client );
native setClientHiddenTURBO ( Client, bool:Enable = true );
native getClientTURBO ( Client );
native getClientBLOCK ( Client );
native setClientHiddenPOWERUP ( Client, bool:Enable = true );
native getClientPOWERUP ( Client );
native getClientSWOOPING ( Client );
native getClientATKSHOOT ( Client );
native getClientATKCHARGE ( Client );
native getClientMELEE ( Client );
native getClientTHROWAWAY ( Client );
native getClientTHROW ( Client );
native getClientWALLGND ( Client );
native getClientINFREEFALL ( Client );
native getClientBEAMJUMP ( Client );
// kills a player without score/death msg
native silentClientKILL ( Client );

View File

@@ -0,0 +1,71 @@
/**
* (C)2004-2005 AMX Mod X Development Team
* based on the stocks and information provided by LynX
* organized and released by BAILOPAN
* This file is provided as is (no warranties).
*/
#if defined _esfconst_included
#endinput
#endif
#define _esfconst_included
enum
{
Character_Buu = 1,
Character_Goku = 2,
Character_Gohan = 3, //my favorite :)
Character_Krillin = 4,
Character_Frieza = 5,
Character_Piccolo = 6,
Character_Trunks = 7,
Character_Vegeta = 8,
Character_Cell = 9,
};
enum
{
Explosion_Blue = 0,
Explosion_Green,
Explosion_Orange,
Explosion_Purple,
Explosion_Yellow,
Explosion_Red,
Explosion_White,
Explosions_Total,
};
enum
{
Attack_Kamehameha=1,
Attack_SpiritBomb,
Attack_GalletGun,
Attack_FinalFlash,
Attack_Renzoku,
Attack_Kametorpedo,
Attack_GenericBeam,
Attack_Throw,
};
enum
{
Direction_Left=1,
Direction_Right,
Direction_Up,
Direction_Down,
Direction_Forward,
Direction_Backward,
};
enum
{
Recovery_Kicked=1,
Recovery_Tumbled,
Recovery_Lying,
Recovery_Thrown,
};
#define ESF_CHARGING 1
#define ESF_CONTROLLING 2
#define ESF_SHOOTING 3
#define ESF_SHOT 4

View File

@@ -0,0 +1,260 @@
/* FakeMeta functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _fakemeta_included
#endinput
#endif
#define _fakemeta_included
#include <fakemeta_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib fakemeta
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib fakemeta
#endif
#else
#pragma library fakemeta
#endif
/**
* Returns entvar data from an entity. Use the pev_* enum (in fakemeta_const.inc) to specify which data you want retrieved.
*
* @note This function uses "read_data" style data syntax. It returns integer values,
* by-references float data, and sets a buffer for string data.
*
* @note If retrieving strings, you may optionally get a pointer into the global string table. Depending on
* your situation, there are two ways to do this.
* 1: This simply gets the pointer.
* new ptr = pev(entid, pev_classname)
* 2: The pointer will be stored in ptr AND the actual string is retrieved.
* new ptr, classname[32]
* pev(entid, pev_classname, ptr, classname, 31)
*
* @param _index The entity index to lookup.
* @param _value The pev field to lookup (look in fakemeta_const.inc)
*/
native pev(_index,_value,any:...);
/**
* Sets entvar data for an entity. Use the pev_* enum from fakemeta_const.inc for reference.
*
* @note Setting string data will automatically allocate a new string (via AllocString)
* If you have a string already allocated with your own call to AllocString, use
* set_pev_string_ptr instead.
*
* @param _index The entity index to set the value on.
* @param _value The pev field to set, (look in fakemeta_const.inc)
*/
native set_pev(_index,_value,any:...);
/**
* Use this native to set a pev field to a string that is already allocated (via a function such
* as EngFunc_AllocString).
*
* @note If you specify _value as anything other than string fields, an error will be thrown.
* @note Pass 0 as the _string field to set it to an empty string.
*
* @param _index The entity index to set the value on.
* @param _value The pev field to set - MUST be a string field.
* @param _string The string handle, retrieved from places like AllocString.
*/
native set_pev_string(_index, _value, _string);
/**
* Checks the validity of an entity.
*
* @param entindex The entity id to check.
*
* @return 0 on invalid entity
* 1 on entity is valid
* 2 on entity is valid and it has private data (safe to use pdata natives on).
*/
native pev_valid(entindex);
/**
* Returns the serial number for each entity. The serial number is a unique identity
* generated when an entity is created.
*
* @param entindex The entity id.
*
* @return The serial number for the entity.
*/
native pev_serial(entindex);
/* Returns any global variable inside globalvars_t structure. Use the glb_* enum.
*
* When returning data from glb_pStringBase (the global string table), you may give a pointer into that table
* in order to get different strings.
* Example:
* new model[128]
* new ptr = pev(id, pev_viewmodel)
* global_get(glb_pStringBase, ptr, model, 127)
*/
native global_get(_value, any:...);
/* Returns an integer from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
native get_pdata_int(_index,_Offset,_linuxdiff=5,_macdiff=5);
/* Sets an integer from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
native set_pdata_int(_index,_Offset,_Value,_linuxdiff=5,_macdiff=5);
/* Returns a float from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
native Float:get_pdata_float(_index,_Offset,_linuxdiff=5,_macdiff=5);
/* Sets a float from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */
native set_pdata_float(_index,_Offset,Float:_Value,_linuxdiff=5,_macdiff=5);
/**
* Tries to retrieve an edict (entity encapsulation) pointer from an entity's private data.
*
* This function is byte-addressable. Unlike get_pdata_int() which searches in byte increments of 4,
* get_pdata_end searches in increments of 1.
*
* @param _index Entity index.
* @param _offset Offset to search.
* @param _linuxdiff Linux difference.
* @param _macdiff Mac OS X difference.
* @return -2 if an invalid entity was found.
* -1 if an empty entity was found.
* Otherwise, an entity index is returned.
*/
native get_pdata_ent(_index, _offset, _linuxdiff=20, _macdiff=20);
/* Registers a forward.
* Returns an id you can pass to unregister_forward
*/
native register_forward(_forwardType,const _function[],_post=0);
/* Unregisters a forward.
* The registerId must be from register_forward, and
* post/forwardtype must match what you registered the forward as.
*/
native unregister_forward(_forwardType, registerId, post=0);
/* Returns data for metamod */
native forward_return(type,any:...);
/* Returns the original return value of an engine function.
* This is only valid in forwards that were registered as post.
*
* get_orig_retval() - no params, retrieves integer return value
* get_orig_retval(&Float:value) - retrieves float return value by reference
* get_orig_retval(value[], len) - retrives string return value
*/
native get_orig_retval({Float,_}:...);
native engfunc(type,any:...);
native dllfunc(type,any:...);
//only use this with functions that pass a Trace
// get: zero extra params - return int, one extra param = byref float or vector
// set: use anything
native get_tr(TraceResult:tr_member, {Float,_}:...);
native set_tr(TraceResult:tr_member, {Float,_}:...);
//Upgraded version takes in a TraceResult handle, optionally passed in as the last parameter to the
//TraceResult forward. Use 0 to specify the global traceresult handle set from calling
// some of the Engfucs.
native get_tr2(tr_handle, {TraceResult,_}:tr_member, {Float,_}:...);
native set_tr2(tr_handle, {TraceResult,_}:tr_member, {Float,_}:...);
/**
* Creates a traceresult handle. This value should never be altered.
* The handle can be used in get/set_tr2 and various traceresult engine functions.
*
* NOTE: You must call free_tr2() on every handle made with create_tr2().
*
* @return A new TraceResult handle.
*/
native create_tr2();
/**
* Frees a traceresult handle created with free_tr2(). Do not call
* this more than once per handle, or on handles not created through
* create_tr2().
*
* @param tr_handle TraceResult handle created via create_tr2().
* @noreturn
*/
native free_tr2(tr_handle);
//Same as above, use either a kvd_handle or 0 for global reserved kvd data
//kvd_handle is passed by the kvd hook, last param
native get_kvd(kvd_handle, KeyValueData:member, {Float,_}:...);
//Using set_kvd with the handle from the hook for anything under KV_fHandled
// is considered an undefined operation (it could crash). You should fire a new
// keyvalues structure rather than changing the internal engine strings.
native set_kvd(kvd_handle, KeyValueData:member, {Float,_}:...);
// These functions are used with the clientdata data structure (FM_UpdateClientData)
// Get: 0 extra params - Return integer; 1 extra param - by ref float or vector; 2 extra params - string and length
// Set: Use anything
// Use 0 for cd_handle to specify the global clientdata handle
native get_cd(cd_handle, ClientData:member, {Float,_}:...);
native set_cd(cd_handle, ClientData:member, {Float,_}:...);
// These functions are used with the entity_state data structure (FM_AddToFullPack)
// Get: 0 extra params - Return integer; 1 extra param - by ref float or vector or array
// Set: Use anything
// Use 0 for es_handle to specify the global entity_state handle
native get_es(es_handle, EntityState:member, {Float,_}:...);
native set_es(es_handle, EntityState:member, {Float,_}:...);
// These functions are used with the usercmd data structure (FM_CmdStart)
// Get: 0 extra params - Return integer; 1 extra param - by ref float or vector
// Set: Use anything
// Use 0 for uc_handle to specify the global usercmd handle
native get_uc(uc_handle, UserCmd:member, {Float,_}:...);
native set_uc(uc_handle, UserCmd:member, {Float,_}:...);
//NOTE that for the string offsets below, on AMD64, a byref (char **) offset is NOT the same as an int offset
//In fact it's QWORD aligned rather than DWORD aligned, so the offset will be exactly half.
//Gets a string from a private offset. If byref is false, the string is treated as static rather than dynamic.
//linux value is what to add to the offset for linux servers.
//mac value is what to add to the offset for os x servers. Default (cellmin) means that linux value will be used.
//this cannot use a default value due to older version using an awkward default value.
native get_pdata_string(entity, offset, dest[], maxlength, byref=1, linux, mac=cellmin);
//Sets a string in a private offset.
//realloc = -1 - nonbyref copy (static
//realloc = 0 - copy byref, no realloc *(char **)
//realloc = 1 - reallocate new string with free+malloc
//realloc = 2 - reallocate new string with delete[]+new[]
//linux value is what to add to the offset for linux servers.
//mac value iswhat to add to the offset for os x servers.
//this cannot use a default value due to older version using an awkward default value.
native set_pdata_string(entity, offset, const source[], realloc=2, linux, mac=cellmin);
// Copies the given infoBuffer pointer into out[]
// An infoBuffer pointer is returned by EngFunc_GetInfoKeyBuffer
native copy_infokey_buffer(infoBuffer, out[], maxlen);
/**
* Looks up the sequence for the entity.
*
* @param entity The entity id to lookup.
* @param name The sequence name to lookup, case insensitive. ("JUMP" would match "jump")
* @param framerate The framerate of the sequence, if found.
* @param loops Whether or not the sequence loops.
* @param groundspeed The groundspeed setting of the sequence.
* @return -1 on failed lookup, the sequence number on successful lookup.
*/
native lookup_sequence(entity, const name[], &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0);
/**
* Sets a bone controller with the specified value.
*
* @param entity The entity id to set the value on.
* @param controller Which controller to set (0 through 3).
* @param value The value to set it to.
* @return The percentage that the controller is extended (0.0 through 1.0)
*/
native Float:set_controller(entity, controller, Float:value);

View File

@@ -0,0 +1,749 @@
/* FakeMeta constants
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _fakemeta_const_included
#endinput
#endif
#define _fakemeta_const_included
// For forward_return
#define FMV_STRING 1
#define FMV_FLOAT 2
#define FMV_CELL 3
#include <hlsdk_const>
/* The actual return value of the function, use these instead of PLUGIN_HANDLED etc when
* returning from registered forwards.
*/
#define FMRES_IGNORED 1 // Calls target function, returns normal value
#define FMRES_HANDLED 2 // Tells metamod you did something, still calls target function and returns normal value
#define FMRES_OVERRIDE 3 // Supposed to still call the target function but return your value instead
// however this does not work properly with metamod; use supercede instead.
#define FMRES_SUPERCEDE 4 // Block the target call, and use your return value (if applicable)
// Use this with GetInfoKeyBuffer if you want the server's localinfo buffer
#define FM_NULLENT -1
/* Used with engfunc()
*/
enum {
EngFunc_PrecacheModel, // int ) (char *s);
EngFunc_PrecacheSound, // int ) (char *s);
EngFunc_SetModel, // void ) (edict_t *e, const char *m);
EngFunc_ModelIndex, // int ) (const char *m);
EngFunc_ModelFrames, // int ) (int modelIndex);
EngFunc_SetSize, // void ) (edict_t *e, const float *rgflMin, const float *rgflMax);
EngFunc_ChangeLevel, // void ) (char* s1, char* s2);
EngFunc_VecToYaw, // float) (const float *rgflVector);
EngFunc_VecToAngles, // void ) (const float *rgflVectorIn, float *rgflVectorOut);
EngFunc_MoveToOrigin, // void ) (edict_t *ent, const float *pflGoal, float dist, int iMoveType);
EngFunc_ChangeYaw, // void ) (edict_t* ent);
EngFunc_ChangePitch, // void ) (edict_t* ent);
EngFunc_FindEntityByString, // edict) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue);
EngFunc_GetEntityIllum, // int ) (edict_t* pEnt);
EngFunc_FindEntityInSphere, // edict) (edict_t *pEdictStartSearchAfter, const float *org, float rad);
EngFunc_FindClientInPVS, // edict) (edict_t *pEdict);
EngFunc_EntitiesInPVS, // edict) (edict_t *pplayer);
EngFunc_MakeVectors, // void ) (const float *rgflVector);
EngFunc_AngleVectors, // void ) (const float *rgflVector, float *forward, float *right, float *up);
EngFunc_CreateEntity, // edict) (void);
EngFunc_RemoveEntity, // void ) (edict_t *e);
EngFunc_CreateNamedEntity, // edict) (int className);
EngFunc_MakeStatic, // void ) (edict_t *ent);
EngFunc_EntIsOnFloor, // int ) (edict_t *e);
EngFunc_DropToFloor, // int ) (edict_t *e);
EngFunc_WalkMove, // int ) (edict_t *ent, float yaw, float dist, int iMode);
EngFunc_SetOrigin, // void ) (edict_t *e, const float *rgflOrigin);
EngFunc_EmitSound, // void ) (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch);
EngFunc_EmitAmbientSound, // void ) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch);
//With 1.71 you can pass an optional TraceLine ptr for trace natives
// it can be 0, for meaning "global tr handle" (for get/set_tr2), or
// it can be any other TR handle (such as one from a TR hook)
EngFunc_TraceLine, // void ) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_TraceToss, // void ) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr);
EngFunc_TraceMonsterHull, // int ) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_TraceHull, // void ) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_TraceModel, // void ) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr);
EngFunc_TraceTexture, // const char *) (edict_t *pTextureEntity, const float *v1, const float *v2 );
EngFunc_TraceSphere, // void ) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_GetAimVector, // void ) (edict_t *ent, float speed, float *rgflReturn);
EngFunc_ParticleEffect, // void ) (const float *org, const float *dir, float color, float count);
EngFunc_LightStyle, // void ) (int style, char *val);
EngFunc_DecalIndex, // int ) (const char *name);
EngFunc_PointContents, // int ) (const float *rgflVector);
EngFunc_FreeEntPrivateData, // void ) (edict_t *pEdict);
EngFunc_SzFromIndex, // const char *) (int iString);
EngFunc_AllocString, // int ) (const char *szValue);
EngFunc_RegUserMsg, // int ) (const char *pszName, int iSize);
EngFunc_AnimationAutomove, // void ) (const edict_t *pEdict, float flTime);
EngFunc_GetBonePosition, // void ) (const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles);
EngFunc_GetAttachment, // void ) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles);
EngFunc_SetView, // void ) (const edict_t *pClient, const edict_t *pViewent);
EngFunc_Time, // float) ( void );
EngFunc_CrosshairAngle, // void ) (const edict_t *pClient, float pitch, float yaw);
EngFunc_FadeClientVolume, // void ) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
EngFunc_SetClientMaxspeed, // void ) (const edict_t *pEdict, float fNewMaxspeed);
EngFunc_CreateFakeClient, // edict) (const char *netname); // returns NULL if fake client can't be created
EngFunc_RunPlayerMove, // void ) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec);
EngFunc_NumberOfEntities, // int ) ( void );
EngFunc_StaticDecal, // void ) (const float *origin, int decalIndex, int entityIndex, int modelIndex);
EngFunc_PrecacheGeneric, // int ) (char* s);
EngFunc_BuildSoundMsg, // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
EngFunc_GetPhysicsKeyValue, // const char *) (const edict_t *pClient, const char *key);
EngFunc_SetPhysicsKeyValue, // void ) (const edict_t *pClient, const char *key, const char *value);
EngFunc_GetPhysicsInfoString, // const char *) (const edict_t *pClient);
EngFunc_PrecacheEvent, // unsigned short) (int type, const char*psz);
EngFunc_PlaybackEvent, // void ) (int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
EngFunc_CheckVisibility, // int ) (const edict_t *entity, unsigned char *pset);
EngFunc_GetCurrentPlayer, // int ) ( void );
EngFunc_CanSkipPlayer, // int ) (const edict_t *player);
EngFunc_SetGroupMask, // void ) (int mask, int op);
EngFunc_GetClientListening, // bool ) (int iReceiver, int iSender)
EngFunc_SetClientListening, // bool ) (int iReceiver, int iSender, bool Listen)
EngFunc_MessageBegin, // void ) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
EngFunc_WriteCoord, // void ) (float flValue)
EngFunc_WriteAngle, // void ) (float flValue)
EngFunc_InfoKeyValue, // char*) (char *infobuffer, char *key);
EngFunc_SetKeyValue, // void ) (char *infobuffer, char *key, char *value);
EngFunc_SetClientKeyValue, // void ) (int clientIndex, char *infobuffer, char *key, char *value);
EngFunc_CreateInstBaseline, // int ) (int classname, struct entity_state_s *baseline);
// Returns pointer to info buffer that can be used with the infobuffer param of InfoKeyValue, SetKeyValue, and SetClientKeyValue
EngFunc_GetInfoKeyBuffer, // char*) (edict_t *e);
EngFunc_AlertMessage, // void ) (ALERT_TYPE atype, char *szFmt, ...);
EngFunc_ClientPrintf, // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg);
EngFunc_ServerPrint // void ) (const char *szMsg);
};
/* Used with dllfunc()
*/
enum
{
DLLFunc_GameInit, // void ) ( void );
DLLFunc_Spawn, // int ) (edict_t *pent);
DLLFunc_Think, // void ) (edict_t *pent);
DLLFunc_Use, // void ) (edict_t *pentUsed, edict_t *pentOther);
DLLFunc_Touch, // void ) (edict_t *pentTouched, edict_t *pentOther);
DLLFunc_Blocked, // void ) (edict_t *pentBlocked, edict_t *pentOther);
//You can pass in 0 for glb kvd handle or a kvd handle here
DLLFunc_KeyValue, // void ) (edict_t *pentKeyvalue, KeyValueData *pkvd);
DLLFunc_SetAbsBox, // void ) (edict_t *pent);
DLLFunc_ClientConnect, // bool ) (edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]);
DLLFunc_ClientDisconnect, // void ) (edict_t *pEntity);
DLLFunc_ClientKill, // void ) (edict_t *pEntity);
DLLFunc_ClientPutInServer, // void ) (edict_t *pEntity);
DLLFunc_ClientCommand, // void ) (edict_t *pEntity);
DLLFunc_ServerDeactivate, // void ) ( void );
DLLFunc_PlayerPreThink, // void ) (edict_t *pEntity);
DLLFunc_PlayerPostThink, // void ) (edict_t *pEntity);
DLLFunc_StartFrame, // void ) ( void );
DLLFunc_ParmsNewLevel, // void ) ( void );
DLLFunc_ParmsChangeLevel, // void ) ( void );
// Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
// This also gets called when the server is queried for information (for example, by a server browser tool)
DLLFunc_GetGameDescription, // const char *) ( void );
// Spectator funcs
DLLFunc_SpectatorConnect, // void ) (edict_t *pEntity);
DLLFunc_SpectatorDisconnect, // void ) (edict_t *pEntity);
DLLFunc_SpectatorThink, // void ) (edict_t *pEntity);
// Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint.
DLLFunc_Sys_Error, // void ) (const char *error_string);
DLLFunc_PM_FindTextureType, // char ) (char *name);
DLLFunc_RegisterEncoders, // void ) ( void );
// Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise
DLLFunc_GetHullBounds, // int ) (int hullnumber, float *mins, float *maxs);
// Create baselines for certain "unplaced" items.
DLLFunc_CreateInstBaselines, // void ) ( void );
DLLFunc_pfnAllowLagCompensation, // int ) ( void );
// I know this does not fit with DLLFUNC(), but I don't want another native just for it.
MetaFunc_CallGameEntity, // bool ) (plid_t plid, const char *entStr,entvars_t *pev);
DLLFunc_ClientUserInfoChanged, // void ) (edict *pEntity, char *infobuffer);
// You can pass in 0 for global cd handle or another cd handle here
DLLFunc_UpdateClientData, // void ) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
// You can pass in 0 for global entity state handle or another entity state handle here
DLLFunc_AddToFullPack, // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
// You can pass in 0 for global usercmd handle or another usercmd handle here
DLLFunc_CmdStart, // void ) (const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed);
DLLFunc_CmdEnd, // void ) (const edict_t *player);
DLLFunc_CreateBaseline // void ) (int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs);
};
enum {
pev_string_start = 0,
pev_classname,
pev_globalname,
pev_model,
pev_target,
pev_targetname,
pev_netname,
pev_message,
pev_noise,
pev_noise1,
pev_noise2,
pev_noise3,
pev_string_end,
pev_edict_start,
pev_chain,
pev_dmg_inflictor,
pev_enemy,
pev_aiment,
pev_owner,
pev_groundentity,
pev_euser1,
pev_euser2,
pev_euser3,
pev_euser4,
pev_edict_end,
pev_float_start,
pev_impacttime,
pev_starttime,
pev_idealpitch,
pev_ideal_yaw,
pev_pitch_speed,
pev_yaw_speed,
pev_ltime,
pev_nextthink,
pev_gravity,
pev_friction,
pev_frame,
pev_animtime,
pev_framerate,
pev_scale,
pev_renderamt,
pev_health,
pev_frags,
pev_takedamage,
pev_max_health,
pev_teleport_time,
pev_armortype,
pev_armorvalue,
pev_dmg_take,
pev_dmg_save,
pev_dmg,
pev_dmgtime,
pev_speed,
pev_air_finished,
pev_pain_finished,
pev_radsuit_finished,
pev_maxspeed,
pev_fov,
pev_flFallVelocity,
pev_fuser1,
pev_fuser2,
pev_fuser3,
pev_fuser4,
pev_float_end,
pev_int_start,
pev_fixangle,
pev_modelindex,
pev_viewmodel,
pev_weaponmodel,
pev_movetype,
pev_solid,
pev_skin,
pev_body,
pev_effects,
pev_light_level,
pev_sequence,
pev_gaitsequence,
pev_rendermode,
pev_renderfx,
pev_weapons,
pev_deadflag,
pev_button,
pev_impulse,
pev_spawnflags,
pev_flags,
pev_colormap,
pev_team,
pev_waterlevel,
pev_watertype,
pev_playerclass,
pev_weaponanim,
pev_pushmsec,
pev_bInDuck,
pev_flTimeStepSound,
pev_flSwimTime,
pev_flDuckTime,
pev_iStepLeft,
pev_gamestate,
pev_oldbuttons,
pev_groupinfo,
pev_iuser1,
pev_iuser2,
pev_iuser3,
pev_iuser4,
pev_int_end,
pev_byte_start,
pev_controller_0,
pev_controller_1,
pev_controller_2,
pev_controller_3,
pev_blending_0,
pev_blending_1,
pev_byte_end,
pev_bytearray_start,
pev_controller,
pev_blending,
pev_bytearray_end,
pev_vecarray_start,
pev_origin,
pev_oldorigin,
pev_velocity,
pev_basevelocity,
pev_clbasevelocity,
pev_movedir,
pev_angles,
pev_avelocity,
pev_v_angle,
pev_endpos,
pev_startpos,
pev_absmin,
pev_absmax,
pev_mins,
pev_maxs,
pev_size,
pev_rendercolor,
pev_view_ofs,
pev_vuser1,
pev_vuser2,
pev_vuser3,
pev_vuser4,
pev_punchangle,
pev_vecarray_end,
pev_string2_begin, /* anything after here are string corrections */
pev_weaponmodel2,
pev_viewmodel2,
pev_string2_end,
pev_edict2_start, /* edict corrections */
pev_pContainingEntity,
pev_absolute_end
};
/* Used with global_get()
*/
enum
{
glb_start_int = 0,
glb_trace_hitgroup,
glb_trace_flags,
glb_msg_entity,
glb_cdAudioTrack,
glb_maxClients,
glb_maxEntities,
glb_end_int,
glb_start_float,
glb_time,
glb_frametime,
glb_force_retouch,
glb_deathmatch,
glb_coop,
glb_teamplay,
glb_serverflags,
glb_found_secrets,
glb_trace_allsolid,
glb_trace_startsolid,
glb_trace_fraction,
glb_trace_plane_dist,
glb_trace_inopen,
glb_trace_inwater,
glb_end_float,
glb_start_edict,
glb_trace_ent,
glb_end_edict,
glb_start_vector,
glb_v_forward,
glb_v_up,
glb_v_right,
glb_trace_endpos,
glb_trace_plane_normal,
glb_vecLandmarkOffset,
glb_end_vector,
glb_start_string,
glb_mapname,
glb_startspot,
glb_end_string,
glb_start_pchar,
glb_pStringBase,
glb_end_pchar
};
/* Used with register_forward()
*/
enum {
FM_PrecacheModel = 1,
FM_PrecacheSound,
FM_SetModel,
FM_ModelIndex,
FM_ModelFrames,
FM_SetSize,
FM_ChangeLevel,
FM_VecToYaw,
FM_VecToAngles,
FM_MoveToOrigin,
FM_ChangeYaw,
FM_ChangePitch,
FM_FindEntityByString,
FM_GetEntityIllum,
FM_FindEntityInSphere,
FM_FindClientInPVS,
FM_EntitiesInPVS,
FM_MakeVectors,
FM_AngleVectors,
FM_CreateEntity,
FM_RemoveEntity,
FM_CreateNamedEntity,
FM_MakeStatic,
FM_EntIsOnFloor,
FM_DropToFloor,
FM_WalkMove,
FM_SetOrigin,
FM_EmitSound,
FM_EmitAmbientSound,
FM_TraceLine,
FM_TraceToss,
FM_TraceMonsterHull,
FM_TraceHull,
FM_TraceModel,
FM_TraceTexture,
FM_TraceSphere,
FM_GetAimVector,
FM_ParticleEffect,
FM_LightStyle,
FM_DecalIndex,
FM_PointContents,
FM_MessageBegin,
FM_MessageEnd,
FM_WriteByte,
FM_WriteChar,
FM_WriteShort,
FM_WriteLong,
FM_WriteAngle,
FM_WriteCoord,
FM_WriteString,
FM_WriteEntity,
FM_CVarGetFloat,
FM_CVarGetString,
FM_CVarSetFloat,
FM_CVarSetString,
FM_FreeEntPrivateData,
FM_SzFromIndex,
FM_AllocString,
FM_RegUserMsg,
FM_AnimationAutomove,
FM_GetBonePosition,
FM_GetAttachment,
FM_SetView,
FM_Time,
FM_CrosshairAngle,
FM_FadeClientVolume,
FM_SetClientMaxspeed,
FM_CreateFakeClient,
FM_RunPlayerMove,
FM_NumberOfEntities,
FM_StaticDecal,
FM_PrecacheGeneric,
FM_BuildSoundMsg,
FM_GetPhysicsKeyValue,
FM_SetPhysicsKeyValue,
FM_GetPhysicsInfoString,
FM_PrecacheEvent,
FM_PlaybackEvent,
FM_CheckVisibility,
FM_GetCurrentPlayer,
FM_CanSkipPlayer,
FM_SetGroupMask,
FM_Voice_GetClientListening,
FM_Voice_SetClientListening,
FM_InfoKeyValue,
FM_SetKeyValue,
FM_SetClientKeyValue,
FM_GetPlayerAuthId,
FM_GetPlayerWONId,
FM_IsMapValid,
FM_Spawn,
FM_Think,
FM_Use,
FM_Touch,
FM_Blocked,
FM_KeyValue,
FM_SetAbsBox,
FM_ClientConnect,
FM_ClientDisconnect,
FM_ClientKill,
FM_ClientPutInServer,
FM_ClientCommand,
FM_ServerDeactivate,
FM_PlayerPreThink,
FM_PlayerPostThink,
FM_StartFrame,
FM_ParmsNewLevel,
FM_ParmsChangeLevel,
// Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
// This also gets called when the server is queried for information (for example, by a server browser tool)
FM_GetGameDescription,
// Spectator funcs
FM_SpectatorConnect,
FM_SpectatorDisconnect,
FM_SpectatorThink,
// Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint.
FM_Sys_Error,
FM_PM_FindTextureType,
FM_RegisterEncoders,
// Create baselines for certain "unplaced" items.
FM_CreateInstBaselines,
FM_AllowLagCompensation,
FM_AlertMessage,
// NEW_DLL_FUNCTIONS:
FM_OnFreeEntPrivateData,
FM_GameShutdown,
FM_ShouldCollide,
// LATE ADDITIONS (v1.71)
FM_ClientUserInfoChanged,
// LATE ADDITIONS (v1.75)
FM_UpdateClientData,
FM_AddToFullPack,
FM_CmdStart,
FM_CmdEnd,
FM_CreateInstBaseline,
FM_CreateBaseline,
FM_GetInfoKeyBuffer,
FM_ClientPrintf,
// LATE ADDITIONS (v1.80)
FM_ServerPrint
};
enum TraceResult
{
TR_AllSolid, // int
TR_StartSolid, // int
TR_InOpen, // int
TR_InWater, // int
TR_flFraction, // float
TR_vecEndPos, // float array[3]
TR_flPlaneDist, // float
TR_vecPlaneNormal, // float array[3]
TR_pHit, // int (edict_t*)
TR_iHitgroup, // int
};
enum KeyValueData
{
KV_ClassName, // string
KV_KeyName, // string
KV_Value, // string
KV_fHandled // int
};
enum ClientData
{
CD_Origin, // float array[3]
CD_Velocity, // float array[3]
CD_ViewModel, // int
CD_PunchAngle, // float array[3]
CD_Flags, // int
CD_WaterLevel, // int
CD_WaterType, // int
CD_ViewOfs, // float array[3]
CD_Health, // float
CD_bInDuck, // int
CD_Weapons, // int
CD_flTimeStepSound, // int
CD_flDuckTime, // int
CD_flSwimTime, // int
CD_WaterJumpTime, // int
CD_MaxSpeed, // float
CD_FOV, // float
CD_WeaponAnim, // int
CD_ID, // int
CD_AmmoShells, // int
CD_AmmoNails, // int
CD_AmmoCells, // int
CD_AmmoRockets, // int
CD_flNextAttack, // float
CD_tfState, // int
CD_PushMsec, // int
CD_DeadFlag, // int
CD_PhysInfo, // string[256]
CD_iUser1, // int
CD_iUser2, // int
CD_iUser3, // int
CD_iUser4, // int
CD_fUser1, // float
CD_fUser2, // float
CD_fUser3, // float
CD_fUser4, // float
CD_vUser1, // float array[3]
CD_vUser2, // float array[3]
CD_vUser3, // float array[3]
CD_vUser4 // float array[3]
};
enum EntityState
{
// Fields which are filled in by routines outside of delta compression
ES_EntityType, // int
// Index into cl_entities array for this entity
ES_Number, // int
ES_MsgTime, // float
// Message number last time the player/entity state was updated
ES_MessageNum, // int
// Fields which can be transitted and reconstructed over the network stream
ES_Origin, // float array[3]
ES_Angles, // float array[3]
ES_ModelIndex, // int
ES_Sequence, // int
ES_Frame, // float
ES_ColorMap, // int
ES_Skin, // short
ES_Solid, // short
ES_Effects, // int
ES_Scale, // float
ES_eFlags, // byte
// Render information
ES_RenderMode, // int
ES_RenderAmt, // int
ES_RenderColor, // byte array[3], RGB value
ES_RenderFx, // int
ES_MoveType, // int
ES_AnimTime, // float
ES_FrameRate, // float
ES_Body, // int
ES_Controller, // byte array[4]
ES_Blending, // byte array[4]
ES_Velocity, // float array[3]
// Send bbox down to client for use during prediction
ES_Mins, // float array[3]
ES_Maxs, // float array[3]
ES_AimEnt, // int
// If owned by a player, the index of that player (for projectiles)
ES_Owner, // int
// Friction, for prediction
ES_Friction, // float
// Gravity multiplier
ES_Gravity, // float
// PLAYER SPECIFIC
ES_Team, // int
ES_PlayerClass, // int
ES_Health, // int
ES_Spectator, // bool
ES_WeaponModel, // int
ES_GaitSequence, // int
// If standing on conveyor, e.g.
ES_BaseVelocity, // float array[3]
// Use the crouched hull, or the regular player hull
ES_UseHull, // int
// Latched buttons last time state updated
ES_OldButtons, // int
// -1 = in air, else pmove entity number
ES_OnGround, // int
ES_iStepLeft, // int
// How fast we are falling
ES_flFallVelocity, // float
ES_FOV, // float
ES_WeaponAnim, // int
// Parametric movement overrides
ES_StartPos, // float array[3]
ES_EndPos, // float array[3]
ES_ImpactTime, // float
ES_StartTime, // float
// For mods
ES_iUser1, // int
ES_iUser2, // int
ES_iUser3, // int
ES_iUser4, // int
ES_fUser1, // float
ES_fUser2, // float
ES_fUser3, // float
ES_fUser4, // float
ES_vUser1, // float array[3]
ES_vUser2, // float array[3]
ES_vUser3, // float array[3]
ES_vUser4 // float array[3]
};
enum UserCmd
{
// Interpolation time on client
UC_LerpMsec, // short
// Duration in ms of command
UC_Msec, // byte
// Command view angles
UC_ViewAngles, // float array[3]
// Intended velocities
// Forward velocity
UC_ForwardMove, // float
// Sideways velocity
UC_SideMove, // float
// Upward velocity
UC_UpMove, // float
// Light level at spot where we are standing
UC_LightLevel, // byte
// Attack buttons
UC_Buttons, // unsigned short
// Impulse command issued
UC_Impulse, // byte
// Current weapon id
UC_WeaponSelect, // byte
// Experimental player impact stuff
UC_ImpactIndex, // int
UC_ImpactPosition // float array[3]
};
enum AlertType
{
at_notice = 0,
at_console, // same as at_notice, but forces a ConPrintf, not a message box
at_aiconsole, // same as at_console, but only shown if developer level is 2!
at_warning,
at_error,
at_logged // Server print to console (only in multiplayer games)
};

View File

@@ -0,0 +1,275 @@
/* FakeMeta stocks
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if !defined _fakemeta_included
#include <fakemeta>
#endif
#if defined _fakemeta_stocks_included
#endinput
#endif
#define _fakemeta_stocks_included
// EngFuncs
stock EF_PrecacheModel(const string[])
return engfunc(EngFunc_PrecacheModel, string);
stock EF_PrecacheSound(const string[])
return engfunc(EngFunc_PrecacheSound, string);
stock EF_SetModel(const ID, const STRING[])
return engfunc(EngFunc_SetModel, ID, STRING);
stock EF_ModelIndex(const STRING[])
return engfunc(EngFunc_ModelIndex, STRING);
stock EF_ModelFrames(modelIndex)
return engfunc(EngFunc_ModelFrames, modelIndex);
stock EF_SetSize(const ENTITY, const Float:MIN[3], const Float:MAX[3])
return engfunc(EngFunc_SetSize, ENTITY, MIN, MAX);
stock EF_ChangeLevel(const S1[], const S2[])
return engfunc(EngFunc_ChangeLevel, S1, S2);
stock EF_VecToYaw(const Float:VECTOR[3], &Float:returnValue)
return engfunc(EngFunc_VecToYaw, VECTOR, returnValue);
stock EF_VecToAngles(const Float:VECTORIN[3], const Float:VECTOROUT[3])
return engfunc(EngFunc_VecToAngles, VECTORIN, VECTOROUT);
stock EF_MoveToOrigin(const ENTITY, const Float:GOAL[3], const Float:DISTANCE, const MOVETYPE)
return engfunc(EngFunc_MoveToOrigin, ENTITY, GOAL, DISTANCE, MOVETYPE);
stock EF_ChangeYaw(const ENTITY)
return engfunc(EngFunc_ChangeYaw, ENTITY);
stock EF_ChangePitch(const ENTITY)
return engfunc(EngFunc_ChangePitch, ENTITY);
stock EF_FindEntityByString(const STARTSEARCHAFTER, const FIELD[], const VALUE[])
return engfunc(EngFunc_FindEntityByString, STARTSEARCHAFTER, FIELD, VALUE);
stock EF_GetEntityIllum(const ENTITY)
return engfunc(EngFunc_GetEntityIllum, ENTITY);
stock EF_FindEntityInSphere(const STARTSEARCHAFTER, const Float:ORIGIN[3], Float:radius)
return engfunc(EngFunc_FindEntityInSphere, STARTSEARCHAFTER, ORIGIN, radius);
stock EF_FindClientInPVS(const CLIENT)
return engfunc(EngFunc_FindClientInPVS, CLIENT);
stock EF_EntitiesInPVS(const CLIENT)
return engfunc(EngFunc_EntitiesInPVS, CLIENT);
stock EF_MakeVectors(const Float:VECTOR[3])
return engfunc(EngFunc_MakeVectors, VECTOR);
stock EF_AngleVectors(const Float:VECTOR[3], Float:forward_[3], Float:right[3], Float:up[3])
return engfunc(EngFunc_AngleVectors, VECTOR, forward_, right, up);
stock EF_CreateEntity()
return engfunc(EngFunc_CreateEntity);
stock EF_RemoveEntity(const ENTITY)
return engfunc(EngFunc_RemoveEntity, ENTITY);
stock EF_CreateNamedEntity(const CLASSNAME)
return engfunc(EngFunc_CreateNamedEntity, CLASSNAME);
stock EF_MakeStatic(const ENTITY)
return engfunc(EngFunc_MakeStatic, ENTITY);
stock EF_EntIsOnFloor(const ENTITY)
return engfunc(EngFunc_EntIsOnFloor, ENTITY);
stock EF_DropToFloor(const ENTITY)
return engfunc(EngFunc_DropToFloor, ENTITY);
stock EF_WalkMove(const ENTITY, Float:yaw, Float:distance, iMode)
return engfunc(EngFunc_WalkMove, ENTITY, yaw, distance, iMode);
stock EF_SetOrigin(const ENTITY, const Float:ORIGIN[3])
return engfunc(EngFunc_SetOrigin, ENTITY, ORIGIN);
stock EF_EmitSound(const ENTITY, channel, const SAMPLE[], Float:volume, Float:attenuation, fFlags, pitch)
return engfunc(EngFunc_EmitSound, ENTITY, channel, SAMPLE, volume, attenuation, fFlags, pitch);
stock EF_EmitAmbientSound(const ENTITY, Float:pos[3], const SAMPLE[], Float:volume, Float:attenuation, fFlags, pitch)
return engfunc(EngFunc_EmitAmbientSound, ENTITY, pos, SAMPLE, volume, attenuation, fFlags, pitch);
stock EF_TraceLine(const Float:V1[3], const Float:V2[3], fNoMonsters, const ENT_TO_SKIP)
return engfunc(EngFunc_TraceLine, V1, V2, fNoMonsters, ENT_TO_SKIP);
stock EF_TraceToss(const ENTITY, const ENTITY_TO_IGNORE)
return engfunc(EngFunc_TraceToss, ENTITY, ENTITY_TO_IGNORE);
stock EF_TraceMonsterHull(const ENTITY, const Float:V1[3], const Float:V2[3], fNoMonsters, const ENTITY_TO_SKIP)
return engfunc(EngFunc_TraceMonsterHull, ENTITY, V1, V2, fNoMonsters, ENTITY_TO_SKIP);
stock EF_TraceHull(const Float:V1[3], const Float:V2[3], fNoMonsters, hullNumber, const ENTITY_TO_SKIP)
return engfunc(EngFunc_TraceHull, V1, V2, fNoMonsters, hullNumber, ENTITY_TO_SKIP);
stock EF_TraceModel(const Float:V1[3], const Float:V2[3], hullNumber, const ENTITY)
return engfunc(EngFunc_TraceModel, V1, V2, hullNumber, ENTITY);
stock EF_TraceTexture(const TEXTURE_ENTITY, const Float:V1[3], const Float:V2[3])
return engfunc(EngFunc_TraceTexture, TEXTURE_ENTITY, V1, V2);
stock EF_TraceSphere(const Float:V1[3], const Float:V2[3], fNoMonsters, Float:radius, const ENTITY_TO_SKIP)
return engfunc(EngFunc_TraceSphere, V1, V2, fNoMonsters, radius, ENTITY_TO_SKIP);
stock EF_GetAimVector(const ENTITY, Float:speed, Float:returnVector[3])
return engfunc(EngFunc_GetAimVector, ENTITY, speed, returnVector);
stock EF_ParticleEffect(const Float:ORIGIN[3], const Float:DIRECTION[3], Float:color, Float:count)
return engfunc(EngFunc_ParticleEffect, ORIGIN, DIRECTION, color, count);
stock EF_LightStyle(style, val[])
return engfunc(EngFunc_LightStyle, style, val);
stock EF_DecalIndex(const NAME[])
return engfunc(EngFunc_DecalIndex, NAME);
stock EF_PointContents(const Float:VECTOR[3])
return engfunc(EngFunc_PointContents, VECTOR);
stock EF_FreeEntPrivateData(const ENTITY)
return engfunc(EngFunc_FreeEntPrivateData, ENTITY);
stock EF_SzFromIndex(iString)
return engfunc(EngFunc_SzFromIndex, iString);
stock EF_AllocString(const STRING[])
return engfunc(EngFunc_AllocString, STRING);
stock EF_RegUserMsg(const NAME[], iSize)
return engfunc(EngFunc_RegUserMsg, NAME, iSize);
stock EF_AnimationAutomove(const ENTITY, Float:flTime)
return engfunc(EngFunc_AnimationAutomove, ENTITY, flTime);
stock EF_GetBonePosition(const ENTITY, iBone, Float:origin[3], Float:angles[3])
return engfunc(EngFunc_GetBonePosition, ENTITY, iBone, origin, angles);
stock EF_GetAttachment(const ENTITY, iAttachment, Float:origin[3], Float:angles[3])
return engfunc(EngFunc_GetAttachment, ENTITY, iAttachment, origin, angles);
stock EF_SetView(const CLIENT, const VIEW_ENTITY)
return engfunc(EngFunc_SetView, CLIENT, VIEW_ENTITY);
stock EF_Time(&Float:returnValue)
return engfunc(EngFunc_Time, returnValue);
stock EF_CrosshairAngle(const CLIENT, Float:pitch, Float:yaw)
return engfunc(EngFunc_CrosshairAngle, CLIENT, pitch, yaw);
stock EF_FadeClientVolume(const ENTITY, fadePercent, fadeOutSeconds, holdTime, fadeInSeconds)
return engfunc(EngFunc_FadeClientVolume, ENTITY, fadePercent, fadeOutSeconds, holdTime, fadeInSeconds);
stock EF_SetClientMaxspeed(const ENTITY, Float:newMaxspeed)
return engfunc(EngFunc_SetClientMaxspeed, ENTITY, newMaxspeed);
stock EF_CreateFakeClient(const NETNAME[])
return engfunc(EngFunc_CreateFakeClient, NETNAME);
stock EF_RunPlayerMove(const FAKECLIENT, const Float:VIEWANGLES[3], Float:forwardmove, Float:sidemove, Float:upmove, buttons, impulse, msec)
return engfunc(EngFunc_RunPlayerMove, FAKECLIENT, VIEWANGLES, forwardmove, sidemove, upmove, buttons, impulse, msec);
stock EF_NumberOfEntities()
return engfunc(EngFunc_NumberOfEntities);
stock EF_StaticDecal(const Float:ORIGIN[3], decalIndex, entityIndex, modelIndex)
return engfunc(EngFunc_StaticDecal, ORIGIN, decalIndex, entityIndex, modelIndex);
stock EF_PrecacheGeneric(const STRING[])
return engfunc(EngFunc_PrecacheGeneric, STRING);
stock EF_BuildSoundMSG(const ENTITY, channel, const SAMPLE[], Float:volume, Float:attenuation, fFlags, pitch, msg_dest, msg_type, const Float:ORIGIN[3], const ED)
return engfunc(EngFunc_BuildSoundMsg, ENTITY, channel, SAMPLE, volume, attenuation, fFlags, pitch, msg_dest, msg_type, ORIGIN, ED);
stock EF_GetPhysicsKeyValue(const CLIENT, const KEY[])
return engfunc(EngFunc_GetPhysicsKeyValue, CLIENT, KEY);
stock EF_SetPhysicsKeyValue(const CLIENT, const KEY[], const VALUE[])
return engfunc(EngFunc_SetPhysicsKeyValue, CLIENT, KEY, VALUE);
stock EF_GetPhysicsInfoString(const CLIENT, returnString[], maxLength)
return engfunc(EngFunc_GetPhysicsInfoString, CLIENT, returnString, maxLength);
stock EF_PrecacheEvent(type, const STRING[])
return engfunc(EngFunc_PrecacheEvent, type, STRING);
stock EF_PlaybackEvent(flags, const INVOKER, eventindex, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2)
return engfunc(EngFunc_PlaybackEvent, flags, INVOKER, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2);
stock EF_CheckVisibility(const ENTITY, set)
return engfunc(EngFunc_CheckVisibility, ENTITY, set);
stock EF_GetCurrentPlayer()
return engfunc(EngFunc_GetCurrentPlayer);
stock EF_CanSkipPlayer(const PLAYER)
return engfunc(EngFunc_CanSkipPlayer, PLAYER);
stock EF_SetGroupMask(mask, op)
return engfunc(EngFunc_SetGroupMask, mask, op);
stock EF_GetClientListening(receiver, sender)
return engfunc(EngFunc_GetClientListening, receiver, sender);
stock EF_SetClientListening(receiver, sender, bool:listen)
return engfunc(EngFunc_SetClientListening, receiver, sender, listen);
stock EF_MessageBegin(msg_dest, msg_type, const Float:ORIGIN[3], const ED)
return engfunc(EngFunc_MessageBegin, msg_dest, msg_type, ORIGIN, ED);
stock EF_WriteCoord(Float:value)
return engfunc(EngFunc_WriteCoord, value);
stock EF_WriteAngle(Float:value)
return engfunc(EngFunc_WriteAngle, value);
stock EF_InfoKeyValue(const INFOBUFFER, const KEY[], returnValue[], maxLength)
return engfunc(EngFunc_InfoKeyValue, INFOBUFFER, KEY, returnValue, maxLength);
stock EF_SetKeyValue(const INFOBUFFER, const KEY[], const VALUE[])
return engfunc(EngFunc_SetKeyValue, INFOBUFFER, KEY, VALUE);
stock EF_SetClientKeyValue(const ID, const INFOBUFFER, const KEY[], const VALUE[])
return engfunc(EngFunc_SetClientKeyValue, ID, INFOBUFFER, KEY, VALUE);
stock EF_CreateInstBaseline(CLASSNAME, baseline)
return engfunc(EngFunc_CreateInstBaseline, CLASSNAME, baseline);
// Returns pointer to info buffer that can be used with the INFOBUFFER param
// of EF_InfoKeyValue, EF_SetKeyValue, and EF_SetClientKeyValue
stock EF_GetInfoKeyBuffer(const ENTITY)
return engfunc(EngFunc_GetInfoKeyBuffer, ENTITY);
stock EF_ClientPrintf(const ENTITY, const printType, const MESSAGE[])
return engfunc(EngFunc_ClientPrintf, ENTITY, printType, MESSAGE);
stock EF_ServerPrint(const MESSAGE[])
return engfunc(EngFunc_ServerPrint, MESSAGE);
// DLLFuncs
stock DF_GameInit()
return dllfunc(DLLFunc_GameInit);
stock DF_Spawn(const ENTITY)
return dllfunc(DLLFunc_Spawn, ENTITY);
stock DF_Think(const ENTITY)
return dllfunc(DLLFunc_Think, ENTITY);
stock DF_Use(const ENT_Used, const ENT_User)
return dllfunc(DLLFunc_Use, ENT_Used, ENT_User);
stock DF_Touch(const ENT_Touched, const ENT_Toucher)
return dllfunc(DLLFunc_Touch, ENT_Touched, ENT_Toucher);
stock DF_Blocked(const ENT_Blocked, const ENT_Other)
return dllfunc(DLLFunc_Blocked, ENT_Blocked, ENT_Other);
stock DF_SetAbsBox(const ENTITY)
return dllfunc(DLLFunc_SetAbsBox, ENTITY);
stock DF_ClientConnect(const ENTITY, const NAME[], const ADDRESS[], RejectReason[128])
return dllfunc(DLLFunc_ClientConnect, ENTITY, NAME, ADDRESS, RejectReason);
stock DF_ClientDisconnect(const ENTITY)
return dllfunc(DLLFunc_ClientDisconnect, ENTITY);
stock DF_ClientKill(const ENTITY)
return dllfunc(DLLFunc_ClientKill, ENTITY);
stock DF_ClientPutInServer(const ENTITY)
return dllfunc(DLLFunc_ClientPutInServer, ENTITY);
stock DF_ClientCommand(const ENTITY)
return dllfunc(DLLFunc_ClientCommand, ENTITY);
stock DF_ServerDeactivate()
return dllfunc(DLLFunc_ServerDeactivate);
stock DF_PlayerPreThink(const ENTITY)
return dllfunc(DLLFunc_PlayerPreThink, ENTITY);
stock DF_PlayerPostThink(const ENTITY)
return dllfunc(DLLFunc_PlayerPostThink, ENTITY);
stock DF_StartFrame()
return dllfunc(DLLFunc_StartFrame);
stock DF_ParmsNewLevel()
return dllfunc(DLLFunc_ParmsNewLevel);
stock DF_ParmsChangeLevel()
return dllfunc(DLLFunc_ParmsChangeLevel);
stock DF_GetGameDescription()
return dllfunc(DLLFunc_GetGameDescription);
stock DF_SpectatorConnect(const ENTITY)
return dllfunc(DLLFunc_SpectatorConnect, ENTITY);
stock DF_SpectatorDisconnect(const ENTITY)
return dllfunc(DLLFunc_SpectatorDisconnect, ENTITY);
stock DF_SpectatorThink(const ENTITY)
return dllfunc(DLLFunc_SpectatorThink, ENTITY);
stock DF_Sys_Error(const ERROR_STRING[])
return dllfunc(DLLFunc_Sys_Error, ERROR_STRING);
stock DF_PM_FindTextureType(name[])
return dllfunc(DLLFunc_PM_FindTextureType, name);
stock DF_RegisterEncoders()
return dllfunc(DLLFunc_RegisterEncoders);
stock DF_GetHullBounds(hullnumber, Float:mins[3], Float:maxs[3])
return dllfunc(DLLFunc_GetHullBounds, hullnumber, mins, maxs);
stock DF_CreateInstBaselines()
return dllfunc(DLLFunc_CreateInstBaselines);
stock DF_pfnAllowLagCompensation()
return dllfunc(DLLFunc_pfnAllowLagCompensation);
stock DF_MetaFunc_CallGameEntity(const STRING[], const ENTITY)
return dllfunc(MetaFunc_CallGameEntity, STRING, ENTITY);
stock DF_ClientUserInfoChanged(const IDPLAYER)
return dllfunc(DLLFunc_ClientUserInfoChanged, IDPLAYER);
stock DF_UpdateClientData(const ENTITY, sendweapons, const cd/* = 0*/)
return dllfunc(DLLFunc_UpdateClientData, ENTITY, sendweapons, cd);
stock DF_AddToFullPack(const STATE/* = 0*/, e, ENT, HOST, hostflags, player, set)
return dllfunc(DLLFunc_AddToFullPack, STATE, e, ENT, HOST, hostflags, player, set);
stock DF_CmdStart(const PLAYER, const CMD/* = 0*/, randomSeed)
return dllfunc(DLLFunc_CmdStart, PLAYER, CMD, randomSeed);
stock DF_CmdEnd(const PLAYER)
return dllfunc(DLLFunc_CmdEnd, PLAYER);
stock DF_CreateBaseline(PLAYER, eIndex, baseline, playerModelIndex, Float:playerMins[3], Float:playerMaxs[3])
return dllfunc(DLLFunc_CreateBaseline, PLAYER, eIndex, baseline, playerModelIndex, playerMins, playerMaxs);

View File

@@ -0,0 +1,882 @@
/**
* This file provides various utility functions that use the Fakemeta module.
* This file is created and maintained by VEN.
* For support and issues, see:
* http://forums.alliedmods.net/showthread.php?t=28284
*/
/* Fakemeta Utilities
*
* by VEN
*
* This file is provided as is (no warranties).
*/
#if !defined _fakemeta_included
#include <fakemeta>
#endif
#if defined _fakemeta_util_included
#endinput
#endif
#define _fakemeta_util_included
#include <xs>
/* Engine functions */
#define fm_precache_generic(%1) engfunc(EngFunc_PrecacheGeneric, %1)
/* stock fm_precache_generic(const file[])
return engfunc(EngFunc_PrecacheGeneric, file) */
#define fm_precache_event(%1,%2) engfunc(EngFunc_PrecacheEvent, %1, %2)
/* stock fm_precache_event(type, const name[])
return engfunc(EngFunc_PrecacheEvent, type, name) */
// ported by v3x
#define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor, %1)
/* stock fm_drop_to_floor(entity)
return engfunc(EngFunc_DropToFloor, entity) */
#define fm_force_use(%1,%2) dllfunc(DLLFunc_Use, %2, %1)
/* stock fm_force_use(user, used)
return dllfunc(DLLFunc_Use, used, user) */
#define fm_entity_set_size(%1,%2,%3) engfunc(EngFunc_SetSize, %1, %2, %3)
/* stock fm_entity_set_size(index, const Float:mins[3], const Float:maxs[3])
return engfunc(EngFunc_SetSize, index, mins, maxs) */
#define fm_get_decal_index(%1) engfunc(EngFunc_DecalIndex, %1)
/* stock fm_get_decal_index(const decalname[])
return engfunc(EngFunc_DecalIndex, decalname) */
stock Float:fm_entity_range(ent1, ent2) {
new Float:origin1[3], Float:origin2[3];
pev(ent1, pev_origin, origin1);
pev(ent2, pev_origin, origin2);
return get_distance_f(origin1, origin2);
}
// based on KoST's port, upgraded version fits into the macros
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
/* stock fm_create_entity(const classname[])
return engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname)) */
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
/* stock fm_find_ent_by_class(index, const classname[])
return engfunc(EngFunc_FindEntityByString, index, "classname", classname) */
stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
new strtype[11] = "classname", ent = index;
switch (jghgtype) {
case 1: strtype = "target";
case 2: strtype = "targetname";
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent;
}
#define fm_find_ent_by_target(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "target", %2)
/* stock fm_find_ent_by_target(index, const target[])
return engfunc(EngFunc_FindEntityByString, index, "target", target) */
#define fm_find_ent_by_tname(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "targetname", %2)
/* stock fm_find_ent_by_tname(index, const targetname[])
return engfunc(EngFunc_FindEntityByString, index, "targetname", targetname) */
stock fm_find_ent_by_model(index, const classname[], const model[]) {
new ent = index, mdl[72];
while ((ent = fm_find_ent_by_class(ent, classname))) {
pev(ent, pev_model, mdl, sizeof mdl - 1);
if (equal(mdl, model))
return ent;
}
return 0;
}
#define fm_find_ent_in_sphere(%1,%2,%3) engfunc(EngFunc_FindEntityInSphere, %1, %2, %3)
/* stock fm_find_ent_in_sphere(index, const Float:origin[3], Float:radius)
return engfunc(EngFunc_FindEntityInSphere, index, origin, radius) */
#define fm_call_think(%1) dllfunc(DLLFunc_Think, %1)
/* stock fm_call_think(entity)
return dllfunc(DLLFunc_Think, entity) */
#define fm_is_valid_ent(%1) pev_valid(%1)
/* stock fm_is_valid_ent(index)
return pev_valid(index) */
stock fm_entity_set_origin(index, const Float:origin[3]) {
new Float:mins[3], Float:maxs[3];
pev(index, pev_mins, mins);
pev(index, pev_maxs, maxs);
engfunc(EngFunc_SetSize, index, mins, maxs);
return engfunc(EngFunc_SetOrigin, index, origin);
}
#define fm_entity_set_model(%1,%2) engfunc(EngFunc_SetModel, %1, %2)
/* stock fm_entity_set_model(index, const model[])
return engfunc(EngFunc_SetModel, index, model) */
// ported by v3x
#define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
/* stock fm_remove_entity(index)
return engfunc(EngFunc_RemoveEntity, index) */
#define fm_entity_count() engfunc(EngFunc_NumberOfEntities)
/* stock fm_entity_count()
return engfunc(EngFunc_NumberOfEntities) */
#define fm_fake_touch(%1,%2) dllfunc(DLLFunc_Touch, %1, %2)
/* stock fm_fake_touch(toucher, touched)
return dllfunc(DLLFunc_Touch, toucher, touched) */
#define fm_DispatchSpawn(%1) dllfunc(DLLFunc_Spawn, %1)
/* stock fm_DispatchSpawn(entity)
return dllfunc(DLLFunc_Spawn, entity) */
// ported by v3x
#define fm_point_contents(%1) engfunc(EngFunc_PointContents, %1)
/* stock fm_point_contents(const Float:point[3])
return engfunc(EngFunc_PointContents, point) */
stock fm_trace_line(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0);
new ent = get_tr2(0, TR_pHit);
get_tr2(0, TR_vecEndPos, ret);
return pev_valid(ent) ? ent : 0;
}
stock fm_trace_hull(const Float:origin[3], hull, ignoredent = 0, ignoremonsters = 0) {
new result = 0;
engfunc(EngFunc_TraceHull, origin, origin, ignoremonsters, hull, ignoredent > 0 ? ignoredent : 0, 0);
if (get_tr2(0, TR_StartSolid))
result += 1;
if (get_tr2(0, TR_AllSolid))
result += 2;
if (!get_tr2(0, TR_InOpen))
result += 4;
return result;
}
stock fm_trace_normal(ignoreent, const Float:start[3], const Float:end[3], Float:ret[3]) {
engfunc(EngFunc_TraceLine, start, end, 0, ignoreent, 0);
get_tr2(0, TR_vecPlaneNormal, ret);
new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if (fraction >= 1.0)
return 0;
return 1;
}
// note that for CS planted C4 has a "grenade" classname as well
stock fm_get_grenade_id(id, model[], len, grenadeid = 0) {
new ent = fm_find_ent_by_owner(grenadeid, "grenade", id);
if (ent && len > 0)
pev(ent, pev_model, model, len);
return ent;
}
#define fm_halflife_time() get_gametime()
/* stock Float:fm_halflife_time()
return get_gametime() */
#define fm_attach_view(%1,%2) engfunc(EngFunc_SetView, %1, %2)
/* stock fm_attach_view(index, entity)
return engfunc(EngFunc_SetView, index, entity) */
stock fm_playback_event(flags, invoker, eventindex, Float:delay, const Float:origin[3], const Float:angles[3], Float:fparam1, Float:fparam2, iparam1, iparam2, bparam1, bparam2) {
return engfunc(EngFunc_PlaybackEvent, flags, invoker, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2);
}
#define fm_eng_get_string(%1,%2,%3) engfunc(EngFunc_SzFromIndex, %1, %2, %3)
/* stock fm_eng_get_string(istring, string[], len)
return engfunc(EngFunc_SzFromIndex, istring, string, len) */
/* HLSDK functions */
// the dot product is performed in 2d, making the view cone infinitely tall
stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
new Float:angles[3];
pev(index, pev_angles, angles);
engfunc(EngFunc_MakeVectors, angles);
global_get(glb_v_forward, angles);
angles[2] = 0.0;
new Float:origin[3], Float:diff[3], Float:norm[3];
pev(index, pev_origin, origin);
xs_vec_sub(point, origin, diff);
diff[2] = 0.0;
xs_vec_normalize(diff, norm);
new Float:dot, Float:fov;
dot = xs_vec_dot(norm, angles);
pev(index, pev_fov, fov);
if (dot >= floatcos(fov * M_PI / 360))
return true;
return false;
}
stock bool:fm_is_visible(index, const Float:point[3], ignoremonsters = 0) {
new Float:start[3], Float:view_ofs[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);
engfunc(EngFunc_TraceLine, start, point, ignoremonsters, index, 0);
new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if (fraction == 1.0)
return true;
return false;
}
/* Engine_stocks functions */
stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype) {
new class[] = "trigger_hurt";
new entity = fm_create_entity(class);
if (!entity)
return 0;
new value[16];
float_to_str(takedmgdamage * 2, value, sizeof value - 1);
fm_set_kvd(entity, "dmg", value, class);
num_to_str(damagetype, value, sizeof value - 1);
fm_set_kvd(entity, "damagetype", value, class);
fm_set_kvd(entity, "origin", "8192 8192 8192", class);
fm_DispatchSpawn(entity);
set_pev(entity, pev_classname, classname);
fm_fake_touch(entity, victim);
fm_remove_entity(entity);
return 1;
}
#define fm_find_ent(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
/* stock fm_find_ent(index, const classname[])
return engfunc(EngFunc_FindEntityByString, index, "classname", classname) */
#define fm_get_user_button(%1) pev(%1, pev_button)
/* stock fm_get_user_button(index)
return pev(index, pev_button) */
#define fm_get_user_oldbutton(%1) pev(%1, pev_oldbuttons)
/* stock fm_get_user_oldbutton(index)
return pev(index, pev_oldbuttons) */
#define fm_get_entity_flags(%1) pev(%1, pev_flags)
/* stock fm_get_entity_flags(index)
return pev(index, pev_flags) */
#define fm_get_entity_distance(%1,%2) floatround(fm_entity_range(%1, %2))
/* stock fm_get_entity_distance(ent1, ent2)
return floatround(fm_entity_range(ent1, ent2)) */
#define fm_get_grenade(%1) fm_get_grenade_id(%1, "", 0)
/* stock fm_get_grenade(id)
return fm_get_grenade_id(id, "", 0) */
// optimization idea by Orangutanz
stock fm_get_brush_entity_origin(index, Float:origin[3]) {
new Float:mins[3], Float:maxs[3];
pev(index, pev_origin, origin);
pev(index, pev_mins, mins);
pev(index, pev_maxs, maxs);
origin[0] += (mins[0] + maxs[0]) * 0.5;
origin[1] += (mins[1] + maxs[1]) * 0.5;
origin[2] += (mins[2] + maxs[2]) * 0.5;
return 1;
}
// based on v3x's port, upgraded version returns number of removed entities
stock fm_remove_entity_name(const classname[]) {
new ent = -1, num = 0;
while ((ent = fm_find_ent_by_class(ent, classname)))
num += fm_remove_entity(ent);
return num;
}
stock fm_ViewContents(id) {
new origin[3], Float:Orig[3];
get_user_origin(id, origin, 3);
IVecFVec(origin, Orig);
return fm_point_contents(Orig);
}
stock fm_get_speed(entity) {
new Float:Vel[3];
pev(entity, pev_velocity, Vel);
return floatround(vector_length(Vel));
}
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
new Float:RenderColor[3];
RenderColor[0] = float(r);
RenderColor[1] = float(g);
RenderColor[2] = float(b);
set_pev(entity, pev_renderfx, fx);
set_pev(entity, pev_rendercolor, RenderColor);
set_pev(entity, pev_rendermode, render);
set_pev(entity, pev_renderamt, float(amount));
return 1;
}
stock fm_set_entity_flags(index, flag, onoff) {
new flags = pev(index, pev_flags);
if ((flags & flag) > 0)
return onoff == 1 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags - flag);
else
return onoff == 0 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags + flag);
return 0;
}
stock fm_set_entity_visibility(index, visible = 1) {
set_pev(index, pev_effects, visible == 1 ? pev(index, pev_effects) & ~EF_NODRAW : pev(index, pev_effects) | EF_NODRAW);
return 1;
}
#define fm_get_entity_visibility(%1) (!(pev(%1, pev_effects) & EF_NODRAW))
/* stock fm_get_entity_visibility(index)
return !(pev(index, pev_effects) & EF_NODRAW) */
stock fm_set_user_velocity(entity, const Float:vector[3]) {
set_pev(entity, pev_velocity, vector);
return 1;
}
#define fm_get_user_velocity(%1,%2) pev(%1, pev_velocity, %2)
/* stock fm_get_user_velocity(entity, Float:vector[3])
return pev(entity, pev_velocity, vector) */
/* Fun functions */
#define fm_get_client_listen(%1,%2) engfunc(EngFunc_GetClientListening, %1, %2)
/* stock fm_get_client_listen(receiver, sender)
return engfunc(EngFunc_GetClientListening, receiver, sender) */
#define fm_set_client_listen(%1,%2,%3) engfunc(EngFunc_SetClientListening, %1, %2, %3)
/* stock fm_set_client_listen(receiver, sender, listen)
return engfunc(EngFunc_SetClientListening, receiver, sender, listen) */
stock fm_get_user_godmode(index) {
new Float:val;
pev(index, pev_takedamage, val);
return (val == DAMAGE_NO);
}
stock fm_set_user_godmode(index, godmode = 0) {
set_pev(index, pev_takedamage, godmode == 1 ? DAMAGE_NO : DAMAGE_AIM);
return 1;
}
stock fm_set_user_armor(index, armor) {
set_pev(index, pev_armorvalue, float(armor));
return 1;
}
stock fm_set_user_health(index, health) {
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);
return 1;
}
stock fm_set_user_origin(index, /* const */ origin[3]) {
new Float:orig[3];
IVecFVec(origin, orig);
return fm_entity_set_origin(index, orig);
}
stock fm_set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) {
return fm_set_rendering(index, fx, r, g, b, render, amount);
}
stock fm_give_item(index, const item[]) {
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0;
new ent = fm_create_entity(item);
if (!pev_valid(ent))
return 0;
new Float:origin[3];
pev(index, pev_origin, origin);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Spawn, ent);
new save = pev(ent, pev_solid);
dllfunc(DLLFunc_Touch, ent, index);
if (pev(ent, pev_solid) != save)
return ent;
engfunc(EngFunc_RemoveEntity, ent);
return -1;
}
stock fm_set_user_maxspeed(index, Float:speed = -1.0) {
engfunc(EngFunc_SetClientMaxspeed, index, speed);
set_pev(index, pev_maxspeed, speed);
return 1;
}
stock Float:fm_get_user_maxspeed(index) {
new Float:speed;
pev(index, pev_maxspeed, speed);
return speed;
}
stock fm_set_user_gravity(index, Float:gravity = 1.0) {
set_pev(index, pev_gravity, gravity);
return 1;
}
stock Float:fm_get_user_gravity(index) {
new Float:gravity;
pev(index, pev_gravity, gravity);
return gravity;
}
/* interferes with FM_Spawn enum, just use fm_DispatchSpawn
stock fm_spawn(entity) {
return dllfunc(DLLFunc_Spawn, entity)
}
*/
stock fm_set_user_noclip(index, noclip = 0) {
set_pev(index, pev_movetype, noclip == 1 ? MOVETYPE_NOCLIP : MOVETYPE_WALK);
return 1;
}
#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)
/* stock fm_get_user_noclip(index)
return (pev(index, pev_movetype) == MOVETYPE_NOCLIP) */
// note: get_user_weapon will still return former weapon index
stock fm_strip_user_weapons(index) {
new ent = fm_create_entity("player_weaponstrip");
if (!pev_valid(ent))
return 0;
dllfunc(DLLFunc_Spawn, ent);
dllfunc(DLLFunc_Use, ent, index);
engfunc(EngFunc_RemoveEntity, ent);
return 1;
}
stock fm_set_user_frags(index, frags) {
set_pev(index, pev_frags, float(frags));
return 1;
}
/* Cstrike functions */
stock fm_cs_user_spawn(index) {
set_pev(index, pev_deadflag, DEAD_RESPAWNABLE);
dllfunc(DLLFunc_Spawn, index);
set_pev(index, pev_iuser1, 0);
return 1;
}
/* Custom functions */
// based on Basic-Master's set_keyvalue, upgraded version accepts an optional classname (a bit more efficient if it is passed)
stock fm_set_kvd(entity, const key[], const value[], const classname[] = "") {
if (classname[0])
set_kvd(0, KV_ClassName, classname);
else {
new class[32];
pev(entity, pev_classname, class, sizeof class - 1);
set_kvd(0, KV_ClassName, class);
}
set_kvd(0, KV_KeyName, key);
set_kvd(0, KV_Value, value);
set_kvd(0, KV_fHandled, 0);
return dllfunc(DLLFunc_KeyValue, entity, 0);
}
stock fm_find_ent_by_integer(index, pev_field, value) {
static maxents;
if (!maxents)
maxents = global_get(glb_maxEntities);
for (new i = index + 1; i < maxents; ++i) {
if (pev_valid(i) && pev(i, pev_field) == value)
return i;
}
return 0;
}
stock fm_find_ent_by_flags(index, pev_field, flags) {
static maxents;
if (!maxents)
maxents = global_get(glb_maxEntities);
for (new i = index + 1; i < maxents; ++i) {
if (pev_valid(i) && (pev(i, pev_field) & flags) == flags)
return i;
}
return 0;
}
stock Float:fm_distance_to_box(const Float:point[3], const Float:mins[3], const Float:maxs[3]) {
new Float:dist[3];
for (new i = 0; i < 3; ++i) {
if (point[i] > maxs[i])
dist[i] = point[i] - maxs[i];
else if (mins[i] > point[i])
dist[i] = mins[i] - point[i];
}
return vector_length(dist);
}
stock Float:fm_boxes_distance(const Float:mins1[3], const Float:maxs1[3], const Float:mins2[3], const Float:maxs2[3]) {
new Float:dist[3];
for (new i = 0; i < 3; ++i) {
if (mins1[i] > maxs2[i])
dist[i] = mins1[i] - maxs2[i];
else if (mins2[i] > maxs1[i])
dist[i] = mins2[i] - maxs1[i];
}
return vector_length(dist);
}
stock Float:fm_distance_to_boxent(entity, boxent) {
new Float:point[3];
pev(entity, pev_origin, point);
new Float:mins[3], Float:maxs[3];
pev(boxent, pev_absmin, mins);
pev(boxent, pev_absmax, maxs);
return fm_distance_to_box(point, mins, maxs);
}
stock Float:fm_boxents_distance(boxent1, boxent2) {
new Float:mins1[3], Float:maxs1[3];
pev(boxent1, pev_absmin, mins1);
pev(boxent1, pev_absmax, maxs1);
new Float:mins2[3], Float:maxs2[3];
pev(boxent2, pev_absmin, mins2);
pev(boxent2, pev_absmax, maxs2);
return fm_boxes_distance(mins1, maxs1, mins2, maxs2);
}
// projects a center of a player's feet base (originally by P34nut, improved)
stock Float:fm_distance_to_floor(index, ignoremonsters = 1) {
new Float:start[3], Float:dest[3], Float:end[3];
pev(index, pev_origin, start);
dest[0] = start[0];
dest[1] = start[1];
dest[2] = -8191.0;
engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0);
get_tr2(0, TR_vecEndPos, end);
pev(index, pev_absmin, start);
new Float:ret = start[2] - end[2];
return ret > 0 ? ret : 0.0;
}
// potential to crash (?) if used on weaponbox+weapon_* entity pair (use fm_remove_weaponbox instead)
stock fm_kill_entity(index) {
set_pev(index, pev_flags, pev(index, pev_flags) | FL_KILLME);
return 1;
}
// if weapon index isn't passed then assuming that it's the current weapon
stock fm_get_user_weapon_entity(id, wid = 0) {
new weap = wid, clip, ammo;
if (!weap && !(weap = get_user_weapon(id, clip, ammo)))
return 0;
new class[32];
get_weaponname(weap, class, sizeof class - 1);
return fm_find_ent_by_owner(-1, class, id);
}
// only weapon index or its name can be passed, if neither is passed then the current gun will be stripped
stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") {
new ent_class[32];
if (!wid && wname[0])
copy(ent_class, sizeof ent_class - 1, wname);
else {
new weapon = wid, clip, ammo;
if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
return false;
get_weaponname(weapon, ent_class, sizeof ent_class - 1);
}
new ent_weap = fm_find_ent_by_owner(-1, ent_class, index);
if (!ent_weap)
return false;
engclient_cmd(index, "drop", ent_class);
new ent_box = pev(ent_weap, pev_owner);
if (!ent_box || ent_box == index)
return false;
dllfunc(DLLFunc_Think, ent_box);
return true;
}
// only weapon index or its name can be passed, if neither is passed then the current gun will be transferred
stock bool:fm_transfer_user_gun(index1, index2, wid = 0, const wname[] = "") {
new ent_class[32];
if (!wid && wname[0])
copy(ent_class, sizeof ent_class - 1, wname);
else {
new weapon = wid, clip, ammo;
if (!weapon && !(weapon = get_user_weapon(index1, clip, ammo)))
return false;
get_weaponname(weapon, ent_class, sizeof ent_class - 1);
}
new ent_weap = fm_find_ent_by_owner(-1, ent_class, index1);
if (!ent_weap)
return false;
engclient_cmd(index1, "drop", ent_class);
new ent_box = pev(ent_weap, pev_owner);
if (!ent_box || ent_box == index1)
return false;
set_pev(ent_box, pev_flags, pev(ent_box, pev_flags) | FL_ONGROUND);
dllfunc(DLLFunc_Touch, ent_box, index2);
if (pev(ent_weap, pev_owner) != index2)
return false;
return true;
}
stock bool:fm_is_ent_visible(index, entity, ignoremonsters = 0) {
new Float:start[3], Float:dest[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, dest);
xs_vec_add(start, dest, start);
pev(entity, pev_origin, dest);
engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0);
new Float:fraction;
get_tr2(0, TR_flFraction, fraction);
if (fraction == 1.0 || get_tr2(0, TR_pHit) == entity)
return true;
return false;
}
// ported from AMXX's core get_user_origin(..., 3) (suggested by Greenberet)
stock fm_get_aim_origin(index, Float:origin[3]) {
new Float:start[3], Float:view_ofs[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);
new Float:dest[3];
pev(index, pev_v_angle, dest);
engfunc(EngFunc_MakeVectors, dest);
global_get(glb_v_forward, dest);
xs_vec_mul_scalar(dest, 9999.0, dest);
xs_vec_add(start, dest, dest);
engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
get_tr2(0, TR_vecEndPos, origin);
return 1;
}
stock bool:fm_get_user_longjump(index) {
new value[2];
engfunc(EngFunc_GetPhysicsKeyValue, index, "slj", value, 1);
switch (value[0]) {
case '1': return true;
}
return false;
}
stock fm_set_user_longjump(index, bool:longjump = true, bool:tempicon = true) {
if (longjump == fm_get_user_longjump(index))
return;
if (longjump) {
engfunc(EngFunc_SetPhysicsKeyValue, index, "slj", "1");
if (tempicon) {
static msgid_itempickup;
if (!msgid_itempickup)
msgid_itempickup = get_user_msgid("ItemPickup");
message_begin(MSG_ONE, msgid_itempickup, _, index);
write_string("item_longjump");
message_end();
}
}
else
engfunc(EngFunc_SetPhysicsKeyValue, index, "slj", "0");
}
#define WEAPON_SUIT 31
stock bool:fm_get_user_suit(index) {
return bool:(!(!(pev(index, pev_weapons) & (1<<WEAPON_SUIT)))); // i'm not insane, this is a trick!
}
stock fm_set_user_suit(index, bool:suit = true, bool:sound = true) {
new weapons = pev(index, pev_weapons);
if (!suit)
set_pev(index, pev_weapons, weapons & ~(1<<WEAPON_SUIT));
else if (!(weapons & (1<<WEAPON_SUIT))) {
set_pev(index, pev_weapons, weapons | (1<<WEAPON_SUIT));
if (sound)
emit_sound(index, CHAN_VOICE, "items/tr_kevlar.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
}
}
#define FEV_RELIABLE (1<<1)
#define FEV_GLOBAL (1<<2)
// removes all created decals and players' corpses from the world
// set a specific index to remove decals only for the given client
stock fm_cs_remove_decals(index = 0) {
static eventindex_decal_reset;
if (!eventindex_decal_reset)
eventindex_decal_reset = engfunc(EngFunc_PrecacheEvent, 1, "events/decal_reset.sc");
new flags = FEV_RELIABLE;
if (!index)
flags |= FEV_GLOBAL;
engfunc(EngFunc_PlaybackEvent, flags, index, eventindex_decal_reset, 0.0, Float:{0.0, 0.0, 0.0}, Float:{0.0, 0.0, 0.0}, 0.0, 0.0, 0, 0, 0, 0);
}
// checks whether the entity's classname is equal to the passed classname
stock bool:fm_is_ent_classname(index, const classname[]) {
if (!pev_valid(index))
return false;
new class[32];
pev(index, pev_classname, class, sizeof class - 1);
if (equal(class, classname))
return true;
return false;
}
// the same as AMXX's core user_kill but fixes the issue when the scoreboard doesn't update immediately if flag is set to 1
stock fm_user_kill(index, flag = 0) {
if (flag) {
new Float:frags;
pev(index, pev_frags, frags);
set_pev(index, pev_frags, ++frags);
}
dllfunc(DLLFunc_ClientKill, index);
return 1;
}
// returns a degree angle between player-to-point and player's view vectors
stock Float:fm_get_view_angle_diff(index, const Float:point[3]) {
new Float:vec[3], Float:ofs[3], Float:aim[3];
pev(index, pev_origin, vec);
pev(index, pev_view_ofs, ofs);
xs_vec_add(vec, ofs, vec);
xs_vec_sub(point, vec, vec);
xs_vec_normalize(vec, vec);
pev(index, pev_v_angle, aim);
engfunc(EngFunc_MakeVectors, aim);
global_get(glb_v_forward, aim);
return xs_vec_angle(vec, aim);
}
// gets a weapon type of the linked to weaponbox weapon_* entity
stock fm_get_weaponbox_type(entity) {
static max_clients, max_entities;
if (!max_clients)
max_clients = global_get(glb_maxClients);
if (!max_entities)
max_entities = global_get(glb_maxEntities);
for (new i = max_clients + 1; i < max_entities; ++i) {
if (pev_valid(i) && entity == pev(i, pev_owner)) {
new wname[32];
pev(i, pev_classname, wname, sizeof wname - 1);
return get_weaponid(wname);
}
}
return 0;
}
// safe removal of weaponbox+weapon_* entity pair (delay =~= 0.03 second)
#define fm_remove_weaponbox(%1) dllfunc(DLLFunc_Think, %1)
/* stock fm_remove_weaponbox(entity)
return dllfunc(DLLFunc_Think, entity) */

View File

@@ -0,0 +1,143 @@
/* Files functions
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _file_included
#endinput
#endif
#define _file_included
/* Reads content from directory.
* Returns index of next element or 0 when end of dir. is reached. */
native read_dir(const dirname[],pos,output[],len,&outlen);
/* Reads line from file. Returns index of next line or 0 when end of file is reached. */
native read_file(const file[],line,text[],len,&txtlen);
/* Writes text to file. Function returns 0 on failure.
* When line is set to -1, the text is added at the end of file. */
native write_file(const file[],const text[],line = -1);
/* Deletes file. Function returns 1 on success, 0 on failure. */
native delete_file(const file[]);
/* Checks for file. If file exists function returns 1, in other case 0. */
native file_exists(const file[]);
/* renames a file. returns 0 on failure, 1 on success.
* if relative true, rename_file will act like other natives which
* use the moddir as a base directory. otherwise, the current directory is
* undefined (but assumed to be hlds).
*/
native rename_file(const oldname[], const newname[], relative=0);
/* Checks if a directory exists */
native dir_exists(const dir[]);
/* Returns a file size in bytes if flag is set to 0.
* When flag is set to 1 returns number of lines in the file,
* and when flags is 2, function returns 1 if the file ends
* with line feed. If file doesn't exist returns -1. */
native file_size(const file[], flag=0);
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
//Open a file, returns a handle or 0 on failure
native fopen(const filename[],const mode[]);
//Closes a file handle
native fclose(file);
#define BLOCK_INT 4
#define BLOCK_SHORT 2
#define BLOCK_CHAR 1
#define BLOCK_BYTE 1
//The following functions work as such:
// RAW - means the array you pass is a raw bytestream, for experts only
// BLOCK - means you are passing in an array where each element will be written
// NORMAL - means you are writing only one element
// RAW and BLOCK return the number of blocks acted upon successfully
// NORMAL returns 1 on success
native fread(file, &data, mode);
native fread_blocks(file, data[], blocks, mode);
native fread_raw(file, stream[], blocksize, blocks);
native fwrite(file, data, mode);
native fwrite_blocks(file, const data[], blocks, mode);
native fwrite_raw(file, const stream[], blocksize, mode);
//Returns 1 if the file is ended, 0 otherwise
native feof(file);
//Reads a line from a text file -- includes newline!
native fgets(file, buffer[], maxlength);
//Writes a line to a text file. Returns # of characters written.
native fputs(file, const text[]);
//Writes a line to the file
native fprintf(file, const fmt[], any:...);
//Sets the current position in a file (see SEEK_ values above)
native fseek(file, position, start);
//Returns the current position in a file
native ftell(file);
//These are straight from the C standard.
native fgetc(file);
native fputc(file, data);
native fungetc(file, data);
//Return the size of a file
native filesize(const filename[], any:...);
//Attempts to remove a directory.
//Note that you cannot remove a directory that has files on most
// operating systems.
native rmdir(const path[]);
/* Returns 0 on success, like the POSIX specification */
native mkdir(const dirname[]);
//Delete a file (delete_file macro)
native unlink(const filename[]);
//Returns a handle to a directory
native open_dir(dir[], firstfile[], length);
native next_file(dirh, buffer[], length);
native close_dir(dirh);
/**
* Loads a file using the LoadFileForMe engine function.
*
* The data is truncated if there is not enough space. No null-terminator
* is applied; the data is the raw contents of the file.
*
* @param file File to load (may be a file from the GCF).
* @param buffer Buffer to store file contents.
* @param maxlength Maximum size of the file buffer.
* @param length Variable to store the file length. This may return
* a number larger than the buffer size.
* @return -1 if the file could not be loaded. Otherwise,
* the number of cells actually written to the buffer
* are returned.
*/
native LoadFileForMe(const file[], buffer[], maxlength, &length=0);
/**
* Flushes a buffered output stream.
*
* @param file File handle, or 0 for all open streams.
* @return 0 on success, -1 on failure.
*/
native fflush(file);

View File

@@ -0,0 +1,213 @@
/* Float arithmetic
*
* (c) Copyright 1999, Artran, Inc.
* Written by Greg Garner (gmg@artran.com)
* Modified in March 2001 to include user defined
* operators for the floating point functions.
*
* This file is provided as is (no warranties).
*/
#if defined _float_included
#endinput
#endif
#define _float_included
/* Different methods of rounding */
enum floatround_method {
floatround_round = 0,
floatround_floor,
floatround_ceil,
floatround_tozero
};
enum anglemode {
radian = 0,
degrees,
grades
};
/* Convert an integer into a floating point value */
native Float:float(value);
/* Convert a string into a floating point value */
native Float:floatstr(const string[]);
/* Multiple two floats together */
native Float:floatmul(Float:oper1, Float:oper2);
/* Divide the dividend float by the divisor float */
native Float:floatdiv(Float:dividend, Float:divisor);
/* Add two floats together */
native Float:floatadd(Float:dividend, Float:divisor);
/* Subtract oper2 float from oper1 float */
native Float:floatsub(Float:oper1, Float:oper2);
/* Return the fractional part of a float */
native Float:floatfract(Float:value);
/* Round a float into a integer value */
native floatround(Float:value, floatround_method:method=floatround_round);
/* Compare two integers. If the two elements are equal, return 0.
* If the first argument is greater than the second argument, return 1,
* If the first argument is less than the second argument, return -1. */
native floatcmp(Float:fOne, Float:fTwo);
/* Return the square root of the input value, same as floatpower(value, 0.5) */
native Float:floatsqroot(Float:value);
/* Return the value raised to the power of the exponent */
native Float:floatpower(Float:value, Float:exponent);
/* Return the logarithm */
native Float:floatlog(Float:value, Float:base=10.0);
/* Return the sine, cosine or tangent.
* The input angle may be in radians, degrees or grades. */
native Float:floatsin(Float:value, anglemode:mode=radian);
native Float:floatcos(Float:value, anglemode:mode=radian);
native Float:floattan(Float:value, anglemode:mode=radian);
/* Return the hyperbolic sine, cosine or tangent.
* The input angle may be in radians, degrees or grades. */
native Float:floatsinh(Float:angle, anglemode:mode=radian);
native Float:floatcosh(Float:angle, anglemode:mode=radian);
native Float:floattanh(Float:angle, anglemode:mode=radian);
/* Return the absolute value */
native Float:floatabs(Float:value);
/* Return the angle of a sine, cosine or tangent.
* The output angle may be in radians, degrees, or grades. */
native Float:floatatan(Float:angle, {anglemode,_}:radix);
native Float:floatacos(Float:angle, {anglemode,_}:radix);
native Float:floatasin(Float:angle, {anglemode,_}:radix);
native Float:floatatan2(Float:x, Float:y, {anglemode,_}:radix);
#pragma rational Float
/* user defined operators */
native Float:operator*(Float:oper1, Float:oper2) = floatmul;
native Float:operator/(Float:oper1, Float:oper2) = floatdiv;
native Float:operator+(Float:oper1, Float:oper2) = floatadd;
native Float:operator-(Float:oper1, Float:oper2) = floatsub;
stock Float:operator++(Float:oper)
return oper+1.0;
stock Float:operator--(Float:oper)
return oper-1.0;
stock Float:operator-(Float:oper)
return oper^Float:cellmin; /* IEEE values are sign/magnitude */
stock Float:operator*(Float:oper1, oper2)
return floatmul(oper1, float(oper2)); /* "*" is commutative */
stock Float:operator/(Float:oper1, oper2)
return floatdiv(oper1, float(oper2));
stock Float:operator/(oper1, Float:oper2)
return floatdiv(float(oper1), oper2);
stock Float:operator+(Float:oper1, oper2)
return floatadd(oper1, float(oper2)); /* "+" is commutative */
stock Float:operator-(Float:oper1, oper2)
return floatsub(oper1, float(oper2));
stock Float:operator-(oper1, Float:oper2)
return floatsub(float(oper1), oper2);
stock bool:operator==(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) == 0;
stock bool:operator==(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) == 0; /* "==" is commutative */
stock bool:operator!=(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) != 0;
stock bool:operator!=(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) != 0; /* "==" is commutative */
stock bool:operator>(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) > 0;
stock bool:operator>(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) > 0;
stock bool:operator>(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) > 0;
stock bool:operator>=(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) >= 0;
stock bool:operator>=(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) >= 0;
stock bool:operator>=(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) >= 0;
stock bool:operator<(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) < 0;
stock bool:operator<(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) < 0;
stock bool:operator<(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) < 0;
stock bool:operator<=(Float:oper1, Float:oper2)
return floatcmp(oper1, oper2) <= 0;
stock bool:operator<=(Float:oper1, oper2)
return floatcmp(oper1, float(oper2)) <= 0;
stock bool:operator<=(oper1, Float:oper2)
return floatcmp(float(oper1), oper2) <= 0;
stock bool:operator!(Float:oper)
return (_:oper & ((-1)/2)) == 0; /* -1 = all bits to 1; /2 = remove most significant bit (sign)
works on both 32bit and 64bit systems; no constant required */
/* forbidden operations */
forward operator%(Float:oper1, Float:oper2);
forward operator%(Float:oper1, oper2);
forward operator%(oper1, Float:oper2);
stock Float:floatmin(Float:ValueA, Float:ValueB)
{
if (ValueA<=ValueB)
{
return ValueA;
}
return ValueB;
}
stock Float:floatmax(Float:ValueA, Float:ValueB)
{
if (ValueA>=ValueB)
{
return ValueA;
}
return ValueB;
}
stock Float:floatclamp(Float:Value, Float:MinValue, Float:MaxValue)
{
if (Value<=MinValue)
{
return MinValue;
}
if (Value>=MaxValue)
{
return MaxValue;
}
return Value;
}

View File

@@ -0,0 +1,99 @@
/* Fun functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _fun_included
#endinput
#endif
#define _fun_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib fun
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib fun
#endif
#else
#pragma library fun
#endif
/* Returns 1 if receiver hears sender via voice communication. */
native get_client_listen(receiver, sender);
/* Sets who can listen who. Function returns 0
* if for some reasons this setting can't be done. */
native set_client_listen(receiver, sender, listen);
/* Sets player godmode. If you want to disable godmode set only first parameter. */
native set_user_godmode(index, godmode = 0);
/* Returns 1 if godmode is set. */
native get_user_godmode(index);
/* Sets player armor. */
native set_user_armor(index, armor);
/* Sets player health. */
native set_user_health(index, health);
/* Move player to origin. */
native set_user_origin(index, const origin[3]);
/* Sets player rendering mode. */
native set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16);
/* Gives item to player, name of item can start
* with weapon_, ammo_ and item_. This event
* is announced with proper message to all players. */
native give_item(index, const item[]);
/* Sets hit zones for player.
* Parts of body are as bits:
* 1 - generic
* 2 - head
* 4 - chest
* 8 - stomach
* 16 - left arm
* 32 - right arm
* 64 - left leg
* 128 - right leg */
native set_user_hitzones(index = 0, target = 0, body = 255);
/* Get user hitzones. */
native get_user_hitzones(index, target);
/* Sets users max. speed. */
native set_user_maxspeed(index, Float:speed = -1.0);
/* Returns users max. speed. */
native Float:get_user_maxspeed(index);
/* Sets users gravity. */
native set_user_gravity(index, Float:gravity = 1.0);
/* Returns users gravity. */
native Float:get_user_gravity(index);
/* Spawns entity. */
native spawn(index);
/* Sets player noclip. If you want to disable noclip set only first parameter. */
native set_user_noclip(index, noclip = 0);
/* Returns 1 if noclip is set. */
native get_user_noclip(index);
/* Returns 1 if player has silent footsteps, 0 if footsteps are set to normal */
native get_user_footsteps(index);
/* Gives player silent footsteps.
* if set = 0 it will return footsteps to normal */
native set_user_footsteps(id, set = 1);
/* Strips all weapons from user. */
native strip_user_weapons(index);
/* Sets player frags. */
native set_user_frags(index, frags);

View File

@@ -0,0 +1,74 @@
/* GeoIP module functions for AMX Mod X
by David "BAILOPAN" Anderson
(C)Copyrighted under the GNU General Public License, Version 2
*/
#if defined geoip_included
#endinput
#endif
#define _geoip_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib geoip
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib geoip
#endif
#else
#pragma library geoip
#endif
/// IP addresses passed to these natives can contain ports, the ports will be ignored.
/**
* Lookup the two character country code for a given IP address.
* e.g: "US", "CA", etc.
*
* @param ip The IP address to lookup.
* @param result The result buffer. If the lookup does not succeed, the buffer is not modified.
* @return true on a successful lookup, false on a failed lookup.
*/
native bool:geoip_code2_ex(const ip[], result[3]);
/**
* Lookup the three character country code for a given IP address.
* e.g: "USA", "cAN", etc.
*
* @param ip The IP address to lookup.
* @param result The result buffer. If the lookup does not succeed, the buffer is not modified.
* @return true on a successful lookup, false on a failed lookup.
*/
native bool:geoip_code3_ex(const ip[], result[4]);
/**
* @deprecated
* Lookup the two character country code for a given IP address.
*
* @note This native will overflow the buffer by one cell on an unknown ip lookup!
* @note Use geoip_code2_ex instead!
*
* @param ip The IP address to lookup.
* @param result The result buffer.
*/
native geoip_code2(const ip[], ccode[3]);
/**
* @deprecated
* Lookup the three character country code for a given IP address.
*
* @note This native will overflow the buffer by one cell on an unknown ip lookup!
* @note Use geoip_code3_ex instead!
*
* @param ip The IP address to lookup.
* @param result The result buffer.
*/
native geoip_code3(const ip[], result[4]);
/**
* Lookup the full country name for the given IP address. Sets the buffer to "error" on
* an unsuccessful lookup.
*
* @param ip The IP address to lookup.
* @param result The result of the geoip lookup.
* @param len The maximum length of the result buffer.
*/
native geoip_country(const ip[], result[], len=45);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,382 @@
/**
* Ham Sandwich module include file.
* (c) 2007, The AMX Mod X Development Team
*
* -
* 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.
*/
/**
* Ham Sandwich is a module that is used to hook and call virtual functions of
* entities.
* Virtual functions are mod-specific functions. This means that in order
* for this to work on a mod, it needs to be configured with the hamdata.ini
* file.
* Be very careful with parameter passing to these functions.
*/
#if defined _hamsandwich_included
#endinput
#endif
#define _hamsandwich_included
#include <ham_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib hamsandwich
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib hamsandwich
#endif
#else
#pragma library hamsandwich
#endif
/**
* Hooks the virtual table for the specified entity class.
* An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
* Look at the Ham enum for parameter lists.
*
* @param function The function to hook.
* @param EntityClass The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);
/**
* Hooks the virtual table for the specified entity's class.
* An example would be: RegisterHam(Ham_TakeDamage, id, "player_hurt");
* Look at the Ham enum for parameter lists.
* Note: This will cause hooks for the entire internal class that the entity is
* not exclusively for the provided entity.
*
* @param function The function to hook.
* @param EntityId The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
/**
* Stops a ham forward from triggering.
* Use the return value from RegisterHam as the parameter here!
*
* @param fwd The forward to stop.
*/
native DisableHamForward(HamHook:fwd);
/**
* Starts a ham forward back up.
* Use the return value from RegisterHam as the parameter here!
*
* @param fwd The forward to re-enable.
*/
native EnableHamForward(HamHook:fwd);
/**
* Executes the virtual function on the entity.
* Look at the Ham enum for parameter lists.
*
* @param function The function to call.
* @param id The id of the entity to execute it on.
*/
native ExecuteHam(Ham:function, this, any:...);
/**
* Executes the virtual function on the entity, this will trigger all hooks on that function.
* Be very careful about recursion!
* Look at the Ham enum for parameter lists.
*
* @param function The function to call.
* @param id The id of the entity to execute it on.
*/
native ExecuteHamB(Ham:function, this, any:...);
/**
* Gets the return status of the current hook.
* This is useful to determine what return natives to use.
*
* @return The current status of the hook (such as HAM_SUPERCEDE).
*/
native GetHamReturnStatus();
/**
* Gets the return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetHamReturnInteger(&output);
/**
* Gets the return value of a hook for hooks that return float.
*
* @param output The variable to store the value in.
*/
native GetHamReturnFloat(&Float:output);
/**
* Gets the return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetHamReturnVector(Float:output[3]);
/**
* Gets the return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. Will be -1 on null.
*/
native GetHamReturnEntity(&output);
/**
* Gets the return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The string size of the buffer.
*/
native GetHamReturnString(output[], size);
/**
* Gets the original return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnInteger(&output);
/**
* Gets the original return value of a hook for hooks that return floats.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnFloat(&Float:output);
/**
* Gets the original return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnVector(Float:output[3]);
/**
* Gets the original return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. -1 on null.
*/
native GetOrigHamReturnEntity(&output);
/**
* Gets the original return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The size of the buffer.
*/
native GetOrigHamReturnString(output[], size);
/**
* Sets the return value of a hook that returns an integer or boolean.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnInteger(value);
/**
* Sets the return value of a hook that returns a float.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnFloat(Float:value);
/**
* Sets the return value of a hook that returns a Vector.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnVector(const Float:value[3]);
/**
* Sets the return value of a hook that returns an entity. Set to -1 for null.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnEntity(value);
/**
* Sets the return value of a hook that returns a string.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnString(const value[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are integers.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamInteger(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are floats.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamFloat(which, Float:value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are Vectors.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamVector(which, const Float:value[3]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are entities.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamEntity(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are strings.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamString(which, const output[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are trace result handles.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamTraceResult(which, tr_handle);
/**
* Returns whether or not the function for the specified Ham is valid.
* Things that would make it invalid would be bounds (an older module version
* may not have all of the functions), and the function not being found in
* the mod's hamdata.ini file.
*
* @param function The function to look up.
* @return true if the function is valid, false otherwise.
*/
native bool:IsHamValid(Ham:function);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @param macdiff The mac os x difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
*/
native get_pdata_cbase(id, offset, linuxdiff=5, macdiff=5);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* This will set the corresponding cbase field in private data with the index.
* Pass -1 to null the entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param value The index to store, -1 for invalid
* @param linuxdiff The linux difference of the data.
* @param macdiff The mac os x difference of the data.
*/
native set_pdata_cbase(id, offset, value, linuxdiff=5, macdiff=5);
/**
* This is similar to the get_pdata_cbase, however it does not dereference memory.
* This is many times slower than get_pdata_cbase, and this should only be used
* for testing and finding of offsets, not actual release quality plugins.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry. -2 on an invalid entry.
*
* @param id Entry to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @param macdiff The mac os x difference of the data.
* @return The index of the corresponding pdata field, -1 for null, -2 for invalid.
*/
native get_pdata_cbase_safe(id, offset, linuxdiff=5, macdiff=5);
// This is the callback from the module, this handles any fatal errors.
// This will in turn call the "HamFilter(Ham:id, HamError:err, const reason[])" public, if it exists.
// Return PLUGIN_HANDLED from within the HamFilter to stop the plugin from failing.
// Any other return value will fail the plugin.
// You do not need to have a HamFilter, if there is none, all fatal errors will fail the plugin.
// Do not modify this!
public __fatal_ham_error(Ham:id, HamError:err, const reason[])
{
new func=get_func_id("HamFilter", -1);
new bool:fail=true;
if (func != -1 && callfunc_begin_i(func, -1)==1)
{
callfunc_push_int(_:id);
callfunc_push_int(_:err);
callfunc_push_str(reason, false);
if (callfunc_end()==PLUGIN_HANDLED)
{
fail=false;
}
}
if (fail)
{
set_fail_state(reason);
}
}

View File

@@ -0,0 +1,492 @@
/* Half-Life Software Development Kit constants
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*
*/
#if defined _hlsdk_const_included
#endinput
#endif
#define _hlsdk_const_included
// pev(entity, pev_button) or pev(entity, pev_oldbuttons) values
#define IN_ATTACK (1<<0)
#define IN_JUMP (1<<1)
#define IN_DUCK (1<<2)
#define IN_FORWARD (1<<3)
#define IN_BACK (1<<4)
#define IN_USE (1<<5)
#define IN_CANCEL (1<<6)
#define IN_LEFT (1<<7)
#define IN_RIGHT (1<<8)
#define IN_MOVELEFT (1<<9)
#define IN_MOVERIGHT (1<<10)
#define IN_ATTACK2 (1<<11)
#define IN_RUN (1<<12)
#define IN_RELOAD (1<<13)
#define IN_ALT1 (1<<14)
#define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down
// pev(entity, pev_flags) values
#define FL_FLY (1<<0) // Changes the SV_Movestep() behavior to not need to be on ground
#define FL_SWIM (1<<1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water)
#define FL_CONVEYOR (1<<2)
#define FL_CLIENT (1<<3)
#define FL_INWATER (1<<4)
#define FL_MONSTER (1<<5)
#define FL_GODMODE (1<<6)
#define FL_NOTARGET (1<<7)
#define FL_SKIPLOCALHOST (1<<8) // Don't send entity to local host, it's predicting this entity itself
#define FL_ONGROUND (1<<9) // At rest / on the ground
#define FL_PARTIALGROUND (1<<10) // Not all corners are valid
#define FL_WATERJUMP (1<<11) // Player jumping out of water
#define FL_FROZEN (1<<12) // Player is frozen for 3rd person camera
#define FL_FAKECLIENT (1<<13) // JAC: fake client, simulated server side; don't send network messages to them
#define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched
#define FL_FLOAT (1<<15) // Apply floating force to this entity when in water
#define FL_GRAPHED (1<<16) // Worldgraph has this ent listed as something that blocks a connection
#define FL_IMMUNE_WATER (1<<17)
#define FL_IMMUNE_SLIME (1<<18)
#define FL_IMMUNE_LAVA (1<<19)
#define FL_PROXY (1<<20) // This is a spectator proxy
#define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path)
#define FL_BASEVELOCITY (1<<22) // Base velocity has been applied this frame (used to convert base velocity into momentum)
#define FL_MONSTERCLIP (1<<23) // Only collide in with monsters who have FL_MONSTERCLIP set
#define FL_ONTRAIN (1<<24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
#define FL_WORLDBRUSH (1<<25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something)
#define FL_SPECTATOR (1<<26) // This client is a spectator, don't run touch functions, etc.
#define FL_CUSTOMENTITY (1<<29) // This is a custom entity
#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time
#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client
// engfunc(EngFunc_WalkMove, entity, Float:yaw, Float:dist, iMode) iMode values
#define WALKMOVE_NORMAL 0 // Normal walkmove
#define WALKMOVE_WORLDONLY 1 // Doesn't hit ANY entities, no matter what the solid type
#define WALKMOVE_CHECKONLY 2 // Move, but don't touch triggers
// pev(entity, pev_movetype) values
#define MOVETYPE_NONE 0 // Never moves
#define MOVETYPE_WALK 3 // Player only - moving on the ground
#define MOVETYPE_STEP 4 // Gravity, special edge handling -- monsters use this
#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff
#define MOVETYPE_TOSS 6 // Gravity/Collisions
#define MOVETYPE_PUSH 7 // No clip to world, push and crush
#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity
#define MOVETYPE_FLYMISSILE 9 // Extra size to monsters
#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces
#define MOVETYPE_BOUNCEMISSILE 11 // Bounce w/o gravity
#define MOVETYPE_FOLLOW 12 // Track movement of aiment
#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision)
// pev(entity, pev_solid) values
// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves
// SOLID only effects OTHER entities colliding with this one when they move - UGH!
#define SOLID_NOT 0 // No interaction with other objects
#define SOLID_TRIGGER 1 // Touch on edge, but not blocking
#define SOLID_BBOX 2 // Touch on edge, block
#define SOLID_SLIDEBOX 3 // Touch on edge, but not an onground
#define SOLID_BSP 4 // BSP clip, touch on edge, block
// pev(entity, pev_deadflag) values
#define DEAD_NO 0 // Alive
#define DEAD_DYING 1 // Playing death animation or still falling off of a ledge waiting to hit ground
#define DEAD_DEAD 2 // Dead, lying still
#define DEAD_RESPAWNABLE 3
#define DEAD_DISCARDBODY 4
// new Float:takedamage, pev(entity, pev_takedamage, takedamage) values
#define DAMAGE_NO 0.0
#define DAMAGE_YES 1.0
#define DAMAGE_AIM 2.0
// pev(entity, pev_effects) values
#define EF_BRIGHTFIELD 1 // Swirling cloud of particles
#define EF_MUZZLEFLASH 2 // Single frame ELIGHT on entity attachment 0
#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin
#define EF_DIMLIGHT 8 // Player flashlight
#define EF_INVLIGHT 16 // Get lighting from ceiling
#define EF_NOINTERP 32 // Don't interpolate the next frame
#define EF_LIGHT 64 // Rocket flare glow sprite
#define EF_NODRAW 128 // Don't draw entity
// engfunc(EngFunc_PointContents, Float:origin) return values
#define CONTENTS_EMPTY -1
#define CONTENTS_SOLID -2
#define CONTENTS_WATER -3
#define CONTENTS_SLIME -4
#define CONTENTS_LAVA -5
#define CONTENTS_SKY -6
#define CONTENTS_ORIGIN -7 // Removed at csg time
#define CONTENTS_CLIP -8 // Changed to contents_solid
#define CONTENTS_CURRENT_0 -9
#define CONTENTS_CURRENT_90 -10
#define CONTENTS_CURRENT_180 -11
#define CONTENTS_CURRENT_270 -12
#define CONTENTS_CURRENT_UP -13
#define CONTENTS_CURRENT_DOWN -14
#define CONTENTS_TRANSLUCENT -15
#define CONTENTS_LADDER -16
#define CONTENT_FLYFIELD -17
#define CONTENT_GRAVITY_FLYFIELD -18
#define CONTENT_FOG -19
// Instant damage values for use with gmsgDamage 3rd value write_long(BIT)
#define DMG_GENERIC 0 // Generic damage was done
#define DMG_CRUSH (1<<0) // Crushed by falling or moving object
#define DMG_BULLET (1<<1) // Shot
#define DMG_SLASH (1<<2) // Cut, clawed, stabbed
#define DMG_BURN (1<<3) // Heat burned
#define DMG_FREEZE (1<<4) // Frozen
#define DMG_FALL (1<<5) // Fell too far
#define DMG_BLAST (1<<6) // Explosive blast damage
#define DMG_CLUB (1<<7) // Crowbar, punch, headbutt
#define DMG_SHOCK (1<<8) // Electric shock
#define DMG_SONIC (1<<9) // Sound pulse shockwave
#define DMG_ENERGYBEAM (1<<10) // Laser or other high energy beam
#define DMG_NEVERGIB (1<<12) // With this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1<<13) // With this bit OR'd in, any damage type can be made to gib victims upon death.
#define DMG_DROWN (1<<14) // Drowning
#define DMG_PARALYZE (1<<15) // Slows affected creature down
#define DMG_NERVEGAS (1<<16) // Nerve toxins, very bad
#define DMG_POISON (1<<17) // Blood poisioning
#define DMG_RADIATION (1<<18) // Radiation exposure
#define DMG_DROWNRECOVER (1<<19) // Drowning recovery
#define DMG_ACID (1<<20) // Toxic chemicals or acid burns
#define DMG_SLOWBURN (1<<21) // In an oven
#define DMG_SLOWFREEZE (1<<22) // In a subzero freezer
#define DMG_MORTAR (1<<23) // Hit by air raid (done to distinguish grenade from mortar)
#define DMG_TIMEBASED (~(0x3fff)) // Mask for time-based damage
// The fNoMonsters parameter of EngFunc_TraceLine, EngFunc_TraceMonsterHull, EngFunc_TraceHull, and EngFunc_TraceSphere
#define DONT_IGNORE_MONSTERS 0
#define IGNORE_MONSTERS 1
#define IGNORE_MISSILE 2
#define IGNORE_GLASS 0x100
// The hullnumber paramater of EngFunc_TraceHull, EngFunc_TraceModel and DLLFunc_GetHullBounds
#define HULL_POINT 0
#define HULL_HUMAN 1
#define HULL_LARGE 2
#define HULL_HEAD 3
// global_get(glb_trace_flags)
#define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box
// Used with get/set_es(es_handle, ES_eFlags, ...) (entity_state data structure)
#define EFLAG_SLERP 1 // Do studio interpolation of this entity
// pev(entity, pev_spawnflags) values
// Many of these flags apply to specific entities
// func_train
#define SF_TRAIN_WAIT_RETRIGGER 1
#define SF_TRAIN_START_ON 4 // Train is initially moving
#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains
// func_wall_toggle
#define SF_WALL_START_OFF 0x0001
// func_converyor
#define SF_CONVEYOR_VISUAL 0x0001
#define SF_CONVEYOR_NOTSOLID 0x0002
// func_button
#define SF_BUTTON_DONTMOVE 1
#define SF_BUTTON_TOGGLE 32 // Button stays pushed until reactivated
#define SF_BUTTON_SPARK_IF_OFF 64 // Button sparks in OFF state
#define SF_BUTTON_TOUCH_ONLY 256 // Button only fires as a result of USE key.
// func_rot_button
#define SF_ROTBUTTON_NOTSOLID 1
// env_global
#define SF_GLOBAL_SET 1 // Set global state to initial state on spawn
// multisource
#define SF_MULTI_INIT 1
// momentary_rot_button
#define SF_MOMENTARY_DOOR 0x0001
// button_target
#define SF_BTARGET_USE 0x0001
#define SF_BTARGET_ON 0x0002
// func_door, func_water, func_door_rotating, momementary_door
#define SF_DOOR_ROTATE_Y 0
#define SF_DOOR_START_OPEN 1
#define SF_DOOR_ROTATE_BACKWARDS 2
#define SF_DOOR_PASSABLE 8
#define SF_DOOR_ONEWAY 16
#define SF_DOOR_NO_AUTO_RETURN 32
#define SF_DOOR_ROTATE_Z 64
#define SF_DOOR_ROTATE_X 128
#define SF_DOOR_USE_ONLY 256 // Door must be opened by player's use button
#define SF_DOOR_NOMONSTERS 512 // Monster can't open
#define SF_DOOR_SILENT 0x80000000
// gibshooter
#define SF_GIBSHOOTER_REPEATABLE 1 // Allows a gibshooter to be refired
// env_funnel
#define SF_FUNNEL_REVERSE 1 // Funnel effect repels particles instead of attracting them
// env_bubbles
#define SF_BUBBLES_STARTOFF 0x0001
// env_blood
#define SF_BLOOD_RANDOM 0x0001
#define SF_BLOOD_STREAM 0x0002
#define SF_BLOOD_PLAYER 0x0004
#define SF_BLOOD_DECAL 0x0008
// env_shake
#define SF_SHAKE_EVERYONE 0x0001 // Don't check radius
#define SF_SHAKE_DISRUPT 0x0002 // Disrupt controls
#define SF_SHAKE_INAIR 0x0004 // Shake players in air
// env_fade
#define SF_FADE_IN 0x0001 // Fade in, not out
#define SF_FADE_MODULATE 0x0002 // Modulate, don't blend
#define SF_FADE_ONLYONE 0x0004
// env_beam, env_lightning
#define SF_BEAM_STARTON 0x0001
#define SF_BEAM_TOGGLE 0x0002
#define SF_BEAM_RANDOM 0x0004
#define SF_BEAM_RING 0x0008
#define SF_BEAM_SPARKSTART 0x0010
#define SF_BEAM_SPARKEND 0x0020
#define SF_BEAM_DECALS 0x0040
#define SF_BEAM_SHADEIN 0x0080
#define SF_BEAM_SHADEOUT 0x0100
#define SF_BEAM_TEMPORARY 0x8000
// env_sprite
#define SF_SPRITE_STARTON 0x0001
#define SF_SPRITE_ONCE 0x0002
#define SF_SPRITE_TEMPORARY 0x8000
// env_message
#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out
#define SF_MESSAGE_ALL 0x0002 // Send to all clients
// env_explosion
#define SF_ENVEXPLOSION_NODAMAGE (1<<0) // When set, ENV_EXPLOSION will not actually inflict damage
#define SF_ENVEXPLOSION_REPEATABLE (1<<1) // Can this entity be refired?
#define SF_ENVEXPLOSION_NOFIREBALL (1<<2) // Don't draw the fireball
#define SF_ENVEXPLOSION_NOSMOKE (1<<3) // Don't draw the smoke
#define SF_ENVEXPLOSION_NODECAL (1<<4) // Don't make a scorch mark
#define SF_ENVEXPLOSION_NOSPARKS (1<<5) // Don't make a scorch mark
// func_tank
#define SF_TANK_ACTIVE 0x0001
#define SF_TANK_PLAYER 0x0002
#define SF_TANK_HUMANS 0x0004
#define SF_TANK_ALIENS 0x0008
#define SF_TANK_LINEOFSIGHT 0x0010
#define SF_TANK_CANCONTROL 0x0020
#define SF_TANK_SOUNDON 0x8000
// grenade
#define SF_DETONATE 0x0001
// item_suit
#define SF_SUIT_SHORTLOGON 0x0001
// game_score
#define SF_SCORE_NEGATIVE 0x0001
#define SF_SCORE_TEAM 0x0002
// game_text
#define SF_ENVTEXT_ALLPLAYERS 0x0001
// game_team_master
#define SF_TEAMMASTER_FIREONCE 0x0001
#define SF_TEAMMASTER_ANYTEAM 0x0002
// game_team_set
#define SF_TEAMSET_FIREONCE 0x0001
#define SF_TEAMSET_CLEARTEAM 0x0002
// game_player_hurt
#define SF_PKILL_FIREONCE 0x0001
// game_counter
#define SF_GAMECOUNT_FIREONCE 0x0001
#define SF_GAMECOUNT_RESET 0x0002
// game_player_equip
#define SF_PLAYEREQUIP_USEONLY 0x0001
// game_player_team
#define SF_PTEAM_FIREONCE 0x0001
#define SF_PTEAM_KILL 0x0002
#define SF_PTEAM_GIB 0x0004
// func_trackchange
#define SF_PLAT_TOGGLE 0x0001
#define SF_TRACK_ACTIVATETRAIN 0x00000001
#define SF_TRACK_RELINK 0x00000002
#define SF_TRACK_ROTMOVE 0x00000004
#define SF_TRACK_STARTBOTTOM 0x00000008
#define SF_TRACK_DONT_MOVE 0x00000010
// func_tracktrain
#define SF_TRACKTRAIN_NOPITCH 0x0001
#define SF_TRACKTRAIN_NOCONTROL 0x0002
#define SF_TRACKTRAIN_FORWARDONLY 0x0004
#define SF_TRACKTRAIN_PASSABLE 0x0008
#define SF_PATH_DISABLED 0x00000001
#define SF_PATH_FIREONCE 0x00000002
#define SF_PATH_ALTREVERSE 0x00000004
#define SF_PATH_DISABLE_TRAIN 0x00000008
#define SF_PATH_ALTERNATE 0x00008000
#define SF_CORNER_WAITFORTRIG 0x001
#define SF_CORNER_TELEPORT 0x002
#define SF_CORNER_FIREONCE 0x004
// trigger_push
#define SF_TRIGGER_PUSH_START_OFF 2 // Spawnflag that makes trigger_push spawn turned OFF
// trigger_hurt
#define SF_TRIGGER_HURT_TARGETONCE 1 // Only fire hurt target once
#define SF_TRIGGER_HURT_START_OFF 2 // Spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_NO_CLIENTS 8 // Spawnflag that makes trigger_push spawn turned OFF
#define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 // Trigger hurt will only fire its target if it is hurting a client
#define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // Only clients may touch this trigger
// trigger_auto
#define SF_AUTO_FIREONCE 0x0001
// trigger_relay
#define SF_RELAY_FIREONCE 0x0001
// multi_manager
#define SF_MULTIMAN_CLONE 0x80000000
#define SF_MULTIMAN_THREAD 0x00000001
// env_render - Flags to indicate masking off various render parameters that are normally copied to the targets
#define SF_RENDER_MASKFX (1<<0)
#define SF_RENDER_MASKAMT (1<<1)
#define SF_RENDER_MASKMODE (1<<2)
#define SF_RENDER_MASKCOLOR (1<<3)
// trigger_changelevel
#define SF_CHANGELEVEL_USEONLY 0x0002
// trigger_endsection
#define SF_ENDSECTION_USEONLY 0x0001
// trigger_camera
#define SF_CAMERA_PLAYER_POSITION 1
#define SF_CAMERA_PLAYER_TARGET 2
#define SF_CAMERA_PLAYER_TAKECONTROL 4
// func_rotating
#define SF_BRUSH_ROTATE_Y_AXIS 0
#define SF_BRUSH_ROTATE_INSTANT 1
#define SF_BRUSH_ROTATE_BACKWARDS 2
#define SF_BRUSH_ROTATE_Z_AXIS 4
#define SF_BRUSH_ROTATE_X_AXIS 8
#define SF_PENDULUM_AUTO_RETURN 16
#define SF_PENDULUM_PASSABLE 32
#define SF_BRUSH_ROTATE_SMALLRADIUS 128
#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256
#define SF_BRUSH_ROTATE_LARGERADIUS 512
// triggers
#define SF_TRIGGER_ALLOWMONSTERS 1 // Monsters allowed to fire this trigger
#define SF_TRIGGER_NOCLIENTS 2 // Players not allowed to fire this trigger
#define SF_TRIGGER_PUSHABLES 4 // Only pushables can fire this trigger
#define SF_TRIG_PUSH_ONCE 1
// func_breakable
#define SF_BREAK_TRIGGER_ONLY 1 // May only be broken by trigger
#define SF_BREAK_TOUCH 2 // Can be 'crashed through' by running player (plate glass)
#define SF_BREAK_PRESSURE 4 // Can be broken by a player standing on it
#define SF_BREAK_CROWBAR 256 // Instant break if hit with crowbar
// func_pushable (it's also func_breakable, so don't collide with those flags)
#define SF_PUSH_BREAKABLE 128
// light_spawn
#define SF_LIGHT_START_OFF 1
#define SPAWNFLAG_NOMESSAGE 1
#define SPAWNFLAG_NOTOUCH 1
#define SPAWNFLAG_DROIDONLY 4
#define SPAWNFLAG_USEONLY 1 // Can't be touched, must be used (buttons)
// Monster Spawnflags
#define SF_MONSTER_WAIT_TILL_SEEN 1 // Spawnflag that makes monsters wait until player can see them before attacking
#define SF_MONSTER_GAG 2 // No idle noises from this monster
#define SF_MONSTER_HITMONSTERCLIP 4
#define SF_MONSTER_PRISONER 16 // Monster won't attack anyone, no one will attacke him
#define SF_MONSTER_WAIT_FOR_SCRIPT 128 // Spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked
#define SF_MONSTER_PREDISASTER 256 // This is a predisaster scientist or barney; influences how they speak
#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death
#define SF_MONSTER_FALL_TO_GROUND 0x80000000
#define SF_MONSTER_TURRET_AUTOACTIVATE 32
#define SF_MONSTER_TURRET_STARTINACTIVE 64
#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // Don't attack the player unless provoked
// info_decal
#define SF_DECAL_NOTINDEATHMATCH 2048
// worldspawn
#define SF_WORLD_DARK 0x0001 // Fade from black at startup
#define SF_WORLD_TITLE 0x0002 // Display game title at startup
#define SF_WORLD_FORCETEAM 0x0004 // Force teams
// Set this bit on guns and stuff that should never respawn
#define SF_NORESPAWN (1<<30)
// Valve Mod Weapon Constants
#define HLI_HEALTHKIT 1
#define HLI_ANTIDOTE 2
#define HLI_SECURITY 3
#define HLI_BATTERY 4
#define HLW_NONE 0
#define HLW_CROWBAR 1
#define HLW_GLOCK 2
#define HLW_PYTHON 3
#define HLW_MP5 4
#define HLW_CHAINGUN 5
#define HLW_CROSSBOW 6
#define HLW_SHOTGUN 7
#define HLW_RPG 8
#define HLW_GAUSS 9
#define HLW_EGON 10
#define HLW_HORNETGUN 11
#define HLW_HANDGRENADE 12
#define HLW_TRIPMINE 13
#define HLW_SATCHEL 14
#define HLW_SNARK 15
#define HLW_SUIT 31
#define HLW_ALLWEAPONS (~(1<<HLW_SUIT))
#define FEV_NOTHOST (1<<0) // Skip local host for event send.
#define FEV_RELIABLE (1<<1) // Send the event reliably. You must specify the origin and angles
// for this to work correctly on the server for anything
// that depends on the event origin/angles. I.e., the origin/angles are not
// taken from the invoking edict for reliable events.
#define FEV_GLOBAL (1<<2) // Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC
// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
#define FEV_UPDATE (1<<3) // If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
#define FEV_HOSTONLY (1<<4) // Only send to entity specified as the invoker
#define FEV_SERVER (1<<5) // Only send if the event was created on the server.
#define FEV_CLIENT (1<<6) // Only issue event client side ( from shared code )
// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions)
#define FCAP_CUSTOMSAVE 0x00000001
#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions
#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore
#define FCAP_DONT_SAVE 0x80000000 // Don't save this
#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player
#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player
#define FCAP_ONOFF_USE 0x00000020 // can be used by the player
#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains)
#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource)

View File

@@ -0,0 +1,56 @@
/* Language functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _lang_included
#endinput
#endif
#define _lang_included
//return the number of languages loaded
native get_langsnum();
//sets name to the two-letter name of a language returned by get_langsnum
//index starts at 0
native get_lang(id, name[3]);
//registers a dictionary file, making sure the words are in the dictionary
// the file should be in "addons/amxx/data/lang/", but only the name needs to be
// given. (e.g. register_dictionary("file.txt") will be addons/amxx/data/file.txt).
native register_dictionary(const filename[]);
//returns 1 if the language is loaded, 0 otherwise.
native lang_exists(const name[]);
enum TransKey
{
TransKey_Bad = -1,
};
/**
* Adds or finds a translation key.
*/
native TransKey:CreateLangKey(const key[]);
/**
* Finds a translation key id without adding on failure.
* Returns -1 on not found.
*/
native TransKey:GetLangTransKey(const key[]);
/**
* Adds a translation.
*/
native AddTranslation(const lang[3], TransKey:key, const phrase[]);
/**
* Looks up the translation of the key for the given type
* This does NOT format the output text.
* eg: If the key includes %s, the outputted text will also contain %s.
* NOTE: LANG_PLAYER is invalid in this, use a player index
* or LANG_SERVER
*/
native LookupLangKey(Output[], OutputSize, const Key[], const &id);

View File

@@ -0,0 +1,803 @@
/* Message constants
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*
*/
#if defined _message_const_included
#endinput
#endif
#define _message_const_included
/* Destination types for message_begin() */
#define MSG_BROADCAST 0 // Unreliable to all
#define MSG_ONE 1 // Reliable to one (msg_entity)
#define MSG_ALL 2 // Reliable to all
#define MSG_INIT 3 // Write to the init string
#define MSG_PVS 4 // Ents in PVS of org
#define MSG_PAS 5 // Ents in PAS of org
#define MSG_PVS_R 6 // Reliable to PVS
#define MSG_PAS_R 7 // Reliable to PAS
#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram (could be dropped)
#define MSG_SPEC 9 // Sends to all spectator proxies
/* Hardcoded message types for message_begin()
* Look in the actual HLSDK for details!
*/
#define SVC_NOP 1
#define SVC_DISCONNECT 2
#define SVC_EVENT 3
#define SVC_VERSION 4
#define SVC_SETVIEW 5
#define SVC_SOUND 6
#define SVC_TIME 7
#define SVC_PRINT 8
#define SVC_STUFFTEXT 9
#define SVC_SETANGLE 10
#define SVC_SERVERINFO 11
#define SVC_LIGHTSTYLE 12
#define SVC_UPDATEUSERINFO 13
#define SVC_DELTADESCRIPTION 14
#define SVC_CLIENTDATA 15
#define SVC_STOPSOUND 16
#define SVC_PINGS 17
#define SVC_PARTICLE 18
#define SVC_DAMAGE 19
#define SVC_SPAWNSTATIC 20
#define SVC_EVENT_RELIABLE 21
#define SVC_SPAWNBASELINE 22
#define SVC_TEMPENTITY 23
#define SVC_SETPAUSE 24
#define SVC_SIGNONNUM 25
#define SVC_CENTERPRINT 26
#define SVC_KILLEDMONSTER 27
#define SVC_FOUNDSECRET 28
#define SVC_SPAWNSTATICSOUND 29
#define SVC_INTERMISSION 30
#define SVC_FINALE 31
#define SVC_CDTRACK 32
#define SVC_RESTORE 33
#define SVC_CUTSCENE 34
#define SVC_WEAPONANIM 35
#define SVC_DECALNAME 36
#define SVC_ROOMTYPE 37
#define SVC_ADDANGLE 38
#define SVC_NEWUSERMSG 39
#define SVC_PACKETENTITIES 40
#define SVC_DELTAPACKETENTITIES 41
#define SVC_CHOKE 42
#define SVC_RESOURCELIST 43
#define SVC_NEWMOVEVARS 44
#define SVC_RESOURCEREQUEST 45
#define SVC_CUSTOMIZATION 46
#define SVC_CROSSHAIRANGLE 47
#define SVC_SOUNDFADE 48
#define SVC_FILETXFERFAILED 49
#define SVC_HLTV 50
#define SVC_DIRECTOR 51
#define SVC_VOICEINIT 52
#define SVC_VOICEDATA 53
#define SVC_SENDEXTRAINFO 54
#define SVC_TIMESCALE 55
/* Message flags for set_msg_block() */
#define BLOCK_NOT 0
#define BLOCK_ONCE 1
#define BLOCK_SET 2
/* Used with get_msg_argtype() and set_msg_arg_ */
enum
{
ARG_BYTE = 1, /* int */
ARG_CHAR, /* int */
ARG_SHORT, /* int */
ARG_LONG, /* int */
ARG_ANGLE, /* float */
ARG_COORD, /* float */
ARG_STRING, /* string */
ARG_ENTITY, /* int */
};
/* Temp entity message types for message_begin() */
#define TE_BEAMPOINTS 0 // Beam effect between two points
// write_byte(TE_BEAMPOINTS)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_BEAMENTPOINT 1 // Beam effect between point and entity
// write_byte(TE_BEAMENTPOINT)
// write_short(start entity)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_GUNSHOT 2 // Particle effect plus ricochet sound
// write_byte(TE_GUNSHOT)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
#define TE_EXPLOSION 3 // Additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps
// write_byte(TE_EXPLOSION)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index)
// write_byte(scale in 0.1's)
// write_byte(framerate)
// write_byte(flags)
//
// The Explosion effect has some flags to control performance/aesthetic features:
#define TE_EXPLFLAG_NONE 0 // All flags clear makes default Half-Life explosion
#define TE_EXPLFLAG_NOADDITIVE 1 // Sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite)
#define TE_EXPLFLAG_NODLIGHTS 2 // Do not render dynamic lights
#define TE_EXPLFLAG_NOSOUND 4 // Do not play client explosion sound
#define TE_EXPLFLAG_NOPARTICLES 8 // Do not draw particles
#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound
// write_byte(TE_TAREXPLOSION)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
#define TE_SMOKE 5 // Alphablend sprite, move vertically 30 pps
// write_byte(TE_SMOKE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index)
// write_byte(scale in 0.1's)
// write_byte(framerate)
#define TE_TRACER 6 // Tracer effect from point to point
// write_byte(TE_TRACER)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters
// write_byte(TE_LIGHTNING)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
// write_byte(life in 0.1's)
// write_byte(width in 0.1's)
// write_byte(amplitude in 0.01's)
// write_short(sprite model index)
#define TE_BEAMENTS 8
// write_byte(TE_BEAMENTS)
// write_short(start entity)
// write_short(end entity)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite
// write_byte(TE_SPARKS)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
#define TE_LAVASPLASH 10 // Quake1 lava splash
// write_byte(TE_LAVASPLASH)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
#define TE_TELEPORT 11 // Quake1 teleport splash
// write_byte(TE_TELEPORT)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound
// write_byte(TE_EXPLOSION2)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(starting color)
// write_byte(num colors)
#define TE_BSPDECAL 13 // Decal from the .BSP file
// write_byte(TE_BSPDECAL)
// write_coord(position.x) decal position (center of texture in world)
// write_coord(position.y)
// write_coord(position.z)
// write_short(texture index of precached decal texture name)
// write_short(entity index)
// [optional - write_short(index of model of above entity) only included if previous short is non-zero (not the world)]
#define TE_IMPLOSION 14 // Tracers moving toward a point
// write_byte(TE_IMPLOSION)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(radius)
// write_byte(count)
// write_byte(life in 0.1's)
#define TE_SPRITETRAIL 15 // Line of moving glow sprites with gravity, fadeout, and collisions
// write_byte(TE_SPRITETRAIL)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
// write_short(sprite index)
// write_byte(count)
// write_byte(life in 0.1's)
// write_byte(scale in 0.1's)
// write_byte(velocity along vector in 10's)
// write_byte(randomness of velocity in 10's)
#define TE_SPRITE 17 // Additive sprite, plays 1 cycle
// write_byte(TE_SPRITE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index)
// write_byte(scale in 0.1's)
// write_byte(brightness)
#define TE_BEAMSPRITE 18 // A beam with a sprite at the end
// write_byte(TE_BEAMSPRITE)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
// write_short(beam sprite index)
// write_short(end sprite index)
#define TE_BEAMTORUS 19 // Screen aligned beam ring, expands to max radius over lifetime
// write_byte(TE_BEAMTORUS)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(axis.x)
// write_coord(axis.y)
// write_coord(axis.z)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_BEAMDISK 20 // Disk that expands to max radius over lifetime
// write_byte(TE_BEAMDISK)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(axis.x)
// write_coord(axis.y)
// write_coord(axis.z)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_BEAMCYLINDER 21 // Cylinder that expands to max radius over lifetime
// write_byte(TE_BEAMCYLINDER)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(axis.x)
// write_coord(axis.y)
// write_coord(axis.z)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_BEAMFOLLOW 22 // Create a line of decaying beam segments until entity stops moving
// write_byte(TE_BEAMFOLLOW)
// write_short(entity:attachment to follow)
// write_short(sprite index)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
#define TE_GLOWSPRITE 23
// write_byte(TE_GLOWSPRITE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(model index)
// write_byte(scale / 10)
// write_byte(size)
// write_byte(brightness)
#define TE_BEAMRING 24 // Connect a beam ring to two entities
// write_byte(TE_BEAMRING)
// write_short(start entity)
// write_short(end entity)
// write_short(sprite index)
// write_byte(starting frame)
// write_byte(frame rate in 0.1's)
// write_byte(life in 0.1's)
// write_byte(line width in 0.1's)
// write_byte(noise amplitude in 0.01's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(scroll speed in 0.1's)
#define TE_STREAK_SPLASH 25 // Oriented shower of tracers
// write_byte(TE_STREAK_SPLASH)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(vector.x)
// write_coord(vector.y)
// write_coord(vector.z)
// write_byte(color)
// write_short(count)
// write_short(base speed)
// write_short(ramdon velocity)
#define TE_DLIGHT 27 // Dynamic light, effect world, minor entity effect
// write_byte(TE_DLIGHT)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(radius in 10's)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(brightness)
// write_byte(life in 10's)
// write_byte(decay rate in 10's)
#define TE_ELIGHT 28 // Point entity light, no world effect
// write_byte(TE_ELIGHT)
// write_short(entity:attachment to follow)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(radius)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
// write_byte(life in 0.1's)
// write_coord(decay rate)
#define TE_TEXTMESSAGE 29
// write_byte(TE_TEXTMESSAGE)
// write_byte(channel)
// write_short(x) -1 = center)
// write_short(y) -1 = center)
// write_byte(effect) 0 = fade in/fade out, 1 is flickery credits, 2 is write out (training room)
// write_byte(red) - text color
// write_byte(green)
// write_byte(blue)
// write_byte(alpha)
// write_byte(red) - effect color
// write_byte(green)
// write_byte(blue)
// write_byte(alpha)
// write_short(fadein time)
// write_short(fadeout time)
// write_short(hold time)
// [optional] write_short(fxtime) time the highlight lags behing the leading text in effect 2
// write_string(text message) 512 chars max string size
#define TE_LINE 30
// write_byte(TE_LINE)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
// write_short(life in 0.1 s)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
#define TE_BOX 31
// write_byte(TE_BOX)
// write_coord(boxmins.x)
// write_coord(boxmins.y)
// write_coord(boxmins.z)
// write_coord(boxmaxs.x)
// write_coord(boxmaxs.y)
// write_coord(boxmaxs.z)
// write_short(life in 0.1 s)
// write_byte(red)
// write_byte(green)
// write_byte(blue)
#define TE_KILLBEAM 99 // Kill all beams attached to entity
// write_byte(TE_KILLBEAM)
// write_short(entity)
#define TE_LARGEFUNNEL 100
// write_byte(TE_LARGEFUNNEL)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index)
// write_short(flags)
#define TE_BLOODSTREAM 101 // Particle spray
// write_byte(TE_BLOODSTREAM)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(vector.x)
// write_coord(vector.y)
// write_coord(vector.z)
// write_byte(color)
// write_byte(speed)
#define TE_SHOWLINE 102 // Line of particles every 5 units, dies in 30 seconds
// write_byte(TE_SHOWLINE)
// write_coord(startposition.x)
// write_coord(startposition.y)
// write_coord(startposition.z)
// write_coord(endposition.x)
// write_coord(endposition.y)
// write_coord(endposition.z)
#define TE_BLOOD 103 // Particle spray
// write_byte(TE_BLOOD)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(vector.x)
// write_coord(vector.y)
// write_coord(vector.z)
// write_byte(color)
// write_byte(speed)
#define TE_DECAL 104 // Decal applied to a brush entity (not the world)
// write_byte(TE_DECAL)
// write_coord(position.x) decal position (center of texture in world)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(texture index of precached decal texture name)
// write_short(entity index)
#define TE_FIZZ 105 // Create alpha sprites inside of entity, float upwards
// write_byte(TE_FIZZ)
// write_short(entity)
// write_short(sprite index)
// write_byte density)
#define TE_MODEL 106 // Create a moving model that bounces and makes a sound when it hits
// write_byte(TE_MODEL)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(velocity.x)
// write_coord(velocity.y)
// write_coord(velocity.z)
// write_angle(initial yaw)
// write_short(model index)
// write_byte(bounce sound type)
// write_byte(life in 0.1's)
#define TE_EXPLODEMODEL 107 // Spherical shower of models, picks from set
// write_byte(TE_EXPLODEMODEL)
// write_coord(origin.x)
// write_coord(origin.y)
// write_coord(origin.z)
// write_coord(velocity.x)
// write_coord(velocity.y)
// write_coord(velocity.z)
// write_short(model index)
// write_short(count)
// write_byte(life in 0.1's)
#define TE_BREAKMODEL 108 // Box of models or sprites
// write_byte(TE_BREAKMODEL)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(size.x)
// write_coord(size.y)
// write_coord(size.z)
// write_coord(velocity.x)
// write_coord(velocity.y)
// write_coord(velocity.z)
// write_byte(random velocity in 10's)
// write_short(sprite or model index)
// write_byte(count)
// write_byte(life in 0.1 secs)
// write_byte(flags)
#define TE_GUNSHOTDECAL 109 // Decal and ricochet sound
// write_byte(TE_GUNSHOTDECAL)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(entity index???)
// write_byte(decal???)
#define TE_SPRITE_SPRAY 110 // Spray of alpha sprites
// write_byte(TE_SPRITE_SPRAY)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(velocity.x)
// write_coord(velocity.y)
// write_coord(velocity.z)
// write_short(sprite index)
// write_byte(count)
// write_byte(speed)
// write_byte(noise)
#define TE_ARMOR_RICOCHET 111 // Quick spark sprite, client ricochet sound.
// write_byte(TE_ARMOR_RICOCHET)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(scale in 0.1's)
#define TE_PLAYERDECAL 112
// write_byte(TE_PLAYERDECAL)
// write_byte(playerindex)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(entity???)
// write_byte(decal number)
// [optional] write_short(model index)
#define TE_BUBBLES 113 // Create alpha sprites inside of box, float upwards
// write_byte(TE_BUBBLES)
// write_coord(position.x) (min start position)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(position.x) (max start position)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(float height)
// write_short(model index)
// write_byte(count)
// write_coord(speed)
#define TE_BUBBLETRAIL 114 // Create alpha sprites along a line, float upwards
// write_byte(TE_BUBBLETRAIL)
// write_coord(position.x) (min start position)
// write_coord(position.y) (min start position)
// write_coord(position.z) (min start position)
// write_coord(position.x) (max start position)
// write_coord(position.y) (max start position)
// write_coord(position.z) (max start position)
// write_coord(float height)
// write_short(model index)
// write_byte(count)
// write_coord(speed)
#define TE_BLOODSPRITE 115 // Spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent)
// write_byte(TE_BLOODSPRITE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite1 index)
// write_short(sprite2 index)
// write_byte(color)
// write_byte(scale)
#define TE_WORLDDECAL 116 // Decal applied to the world brush
// write_byte(TE_WORLDDECAL)
// write_coord(position.x) decal position (center of texture in world)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(texture index of precached decal texture name)
#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush
// write_byte(TE_WORLDDECALHIGH)
// write_coord(position.x) decal position (center of texture in world)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(texture index of precached decal texture name - 256)
#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256
// write_byte(TE_DECALHIGH)
// write_coord(position.x) decal position (center of texture in world)
// write_coord(position.y)
// write_coord(position.z)
// write_byte(texture index of precached decal texture name - 256)
// write_short(entity index)
#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent)
// write_byte(TE_PROJECTILE)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(velocity.x)
// write_coord(velocity.y)
// write_coord(velocity.z)
// write_short(modelindex)
// write_byte(life)
// write_byte(owner) projectile won't collide with owner (if owner == 0, projectile will hit any client).
#define TE_SPRAY 120 // Throws a shower of sprites or models
// write_byte(TE_SPRAY)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_coord(direction.x)
// write_coord(direction.y)
// write_coord(direction.z)
// write_short(modelindex)
// write_byte(count)
// write_byte(speed)
// write_byte(noise)
// write_byte(rendermode)
#define TE_PLAYERSPRITES 121 // Sprites emit from a player's bounding box (ONLY use for players!)
// write_byte(TE_PLAYERSPRITES)
// write_short(playernum)
// write_short(sprite modelindex)
// write_byte(count)
// write_byte(variance) (0 = no variance in size) (10 = 10% variance in size)
#define TE_PARTICLEBURST 122 // Very similar to lavasplash
// write_byte(TE_PARTICLEBURST)
// write_coord(origin)
// write_short(radius)
// write_byte(particle color)
// write_byte(duration * 10) (will be randomized a bit)
#define TE_FIREFIELD 123 // Makes a field of fire
// write_byte(TE_FIREFIELD)
// write_coord(origin)
// write_short(radius) (fire is made in a square around origin. -radius, -radius to radius, radius)
// write_short(modelindex)
// write_byte(count)
// write_byte(flags)
// write_byte(duration (in seconds) * 10) (will be randomized a bit)
//
// to keep network traffic low, this message has associated flags that fit into a byte:
#define TEFIRE_FLAG_ALLFLOAT 1 // All sprites will drift upwards as they animate
#define TEFIRE_FLAG_SOMEFLOAT 2 // Some of the sprites will drift upwards. (50% chance)
#define TEFIRE_FLAG_LOOP 4 // If set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration.
#define TEFIRE_FLAG_ALPHA 8 // If set, sprite is rendered alpha blended at 50% else, opaque
#define TEFIRE_FLAG_PLANAR 16 // If set, all fire sprites have same initial Z instead of randomly filling a cube.
#define TE_PLAYERATTACHMENT 124 // Attaches a TENT to a player (this is a high-priority tent)
// write_byte(TE_PLAYERATTACHMENT)
// write_byte(entity index of player)
// write_coord(vertical offset) (attachment origin.z = player origin.z + vertical offset)
// write_short(model index)
// write_short(life * 10 )
#define TE_KILLPLAYERATTACHMENTS 125 // Will expire all TENTS attached to a player.
// write_byte(TE_KILLPLAYERATTACHMENTS)
// write_byte(entity index of player)
#define TE_MULTIGUNSHOT 126 // Much more compact shotgun message
// This message is used to make a client approximate a 'spray' of gunfire.
// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is
// a good candidate for MULTIGUNSHOT use. (shotguns)
//
// NOTE: This effect makes the client do traces for each bullet, these client traces ignore
// entities that have studio models.Traces are 4096 long.
//
// write_byte(TE_MULTIGUNSHOT)
// write_coord(origin.x)
// write_coord(origin.y)
// write_coord(origin.z)
// write_coord(direction.x)
// write_coord(direction.y)
// write_coord(direction.z)
// write_coord(x noise * 100)
// write_coord(y noise * 100)
// write_byte(count)
// write_byte(bullethole decal texture index)
#define TE_USERTRACER 127 // Larger message than the standard tracer, but allows some customization.
// write_byte(TE_USERTRACER)
// write_coord(origin.x)
// write_coord(origin.y)
// write_coord(origin.z)
// write_coord(velocity.x)
// write_coord(velocity.y)
// write_coord(velocity.z)
// write_byte(life * 10)
// write_byte(color) this is an index into an array of color vectors in the engine. (0 - )
// write_byte(length * 10)
// From hltv.h from the HLSDK, these are used in conjunction with SVC_DIRECTOR
// sub commands of svc_director:
#define DRC_CMD_NONE 0 // NULL director command
#define DRC_CMD_START 1 // start director mode
#define DRC_CMD_EVENT 2 // informs about director command
#define DRC_CMD_MODE 3 // switches camera modes
#define DRC_CMD_CAMERA 4 // sets camera registers
#define DRC_CMD_TIMESCALE 5 // sets time scale
#define DRC_CMD_MESSAGE 6 // send HUD centerprint
#define DRC_CMD_SOUND 7 // plays a particular sound
#define DRC_CMD_STATUS 8 // status info about broadcast
#define DRC_CMD_BANNER 9 // banner file name for HLTV gui
#define DRC_CMD_FADE 10 // send screen fade command
#define DRC_CMD_SHAKE 11 // send screen shake command
#define DRC_CMD_STUFFTEXT 12 // like the normal svc_stufftext but as director command
#define DRC_CMD_LAST 12
// HLTV_EVENT event flags
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1<<4) //
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo
#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
#define DRC_FLAG_INTRO (1<<8) // is a introduction scene
#define DRC_FLAG_FINAL (1<<9) // is a final scene
#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data
#define MAX_DIRECTOR_CMD_PARAMETERS 4
#define MAX_DIRECTOR_CMD_STRING 128

View File

@@ -0,0 +1,58 @@
/* Message Stocks
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*
*/
#if defined _message_stocks_included
#endinput
#endif
#define _message_stocks_included
/* Creates a death message. */
stock dod_make_deathmsg(killer, victim, weaponNUM)
{
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
write_byte(weaponNUM);
message_end();
return 1;
}
/* Kills a user without a message. */
stock user_silentkill(index)
{
static msgid = 0;
new msgblock;
if (!msgid)
{
msgid = get_user_msgid("DeathMsg");
}
msgblock = get_msg_block(msgid);
set_msg_block(msgid, BLOCK_ONCE);
user_kill(index, 1);
set_msg_block(msgid, msgblock);
return 1;
}
/* Creates a death message. */
stock make_deathmsg(killer, victim, headshot, const weapon[])
{
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0);
write_byte(killer);
write_byte(victim);
new mod_name[32];
get_modname(mod_name, 31);
if (equal(mod_name, "cstrike") || equal(mod_name, "czero") || equal(mod_name, "csv15") || equal(mod_name, "cs13"))
write_byte(headshot);
write_string(weapon);
message_end();
return 1;
}

View File

@@ -0,0 +1,93 @@
/* Messaging functions (now part of Core)
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _coremsg_included
#endinput
#endif
#define _coremsg_included
#include <message_const>
/* These functinos are used to generate client messages.
* You may generate menu, smoke, shockwaves, thunderlights,
* intermission and many many others messages.
* See HL SDK for more examples. */
native message_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0);
native message_end();
native write_byte(x);
native write_char(x);
native write_short(x);
native write_long(x);
native write_entity(x);
native write_angle(x);
native write_coord(x);
native write_string(const x[]);
/* These are the same as above, except that the messages sent
* are also sent to all other plugins and Metamod plugins.
* This means that if you send one of these messages, other plugins will
* be notified, which was previously impossible.
* BE CAREFUL! Using these incorrectly, or not for their intended purpose,
* could cause infinite recursion or something just as bad.
* NOTE! These natives are experimental.
*/
native emessage_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0);
native emessage_end();
native ewrite_byte(x);
native ewrite_char(x);
native ewrite_short(x);
native ewrite_long(x);
native ewrite_entity(x);
native ewrite_angle(x);
native ewrite_coord(x);
native ewrite_string(const x[]);
/* Sets/Gets what engine messages are blocked. */
native set_msg_block(iMessage, iMessageFlags);
native get_msg_block(iMessage);
/* Lets you directly hook a message in the engine!
* You can overwrite the message before anything happens and either let the message continue
* or fully block it. Here is how it works:
* If you hook a message, the message is stored but not sent. You have the opportunity to
* not only execute code, but to get/set the contents of the message, before you choose to
* either block it or let it go on its way. The hooked function will be passed a msg_id, msg_dest, and entity index.
* The return value can be passed to unregister_message() to stop the message from being hooked */
native register_message(iMsgId, const szFunction[]);
/* Unregisters a message hook previously created with register_message
* You must pass the proper message id, and return value from the message to unregister the message successfully. */
native unregister_message(iMsgId, registeredmsg);
/* The get/set _msg commands will fail if used outside a hooked message scope.
* They should never be used unless inside a registered message function.
* There are eight different ways of sending a message, five are ints, two are floats, and one is string.
* These are denoted by iArgType. argn is the number
* of the argument. Exceeding the bounds of 1 to get_msg_args() is a bad idea.
* As of AMX Mod X 1.5, the middle parameter of set_* no longer does anything.
* You cannot change the message argument type (as this would crash the mod anyway)
*/
/* Gets number of arguments that were passed to this message */
native get_msg_args();
/* Gets the argument type of argument argn */
native get_msg_argtype(argn);
/* Gets the value of argn. */
native get_msg_arg_int(argn);
native Float:get_msg_arg_float(argn);
native get_msg_arg_string(argn, szReturn[], iLength);
/* sets the value of argn. */
native set_msg_arg_int(argn, argtype, iValue);
native set_msg_arg_float(argn, argtype, Float:fValue);
native set_msg_arg_string(argn, const szString[]);
/* Gets the origin of a message */
native get_msg_origin(const Float:_Origin[3]);

View File

@@ -0,0 +1,262 @@
/* AMX Mod X constants
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _newmenus_included
#endinput
#endif
#define _newmenus_included
#define MEXIT_ALL 1 /* Menu will have an exit option (default)*/
#define MEXIT_NEVER -1 /* Menu will not have an exit option */
#define MPROP_PERPAGE 1 /* Number of items per page (param1 = number, 0=no paginating, 7=default) */
#define MPROP_BACKNAME 2 /* Name of the back button (param1 = string) */
#define MPROP_NEXTNAME 3 /* Name of the next button (param1 = string) */
#define MPROP_EXITNAME 4 /* Name of the exit button (param1 = string) */
#define MPROP_TITLE 5 /* Menu title text (param1 = string) */
#define MPROP_EXIT 6 /* Exit functionality (param1 = number, see MEXIT constants) */
#define MPROP_NOCOLORS 8 /* Sets whether colors are not auto (param1 = number, 0=default) */
#define MPROP_NUMBER_COLOR 10 /* Color indicator to use for numbers (param1 = string, "\r"=default) */
#define MEXIT_NORMAL 0 /* DEPRECATED, do not use (has no effect) */
#define MENUPAD_NONE 0 /* DEPRECATED, do not use (has no effect) */
#define MENUPAD_PAGE 1 /* DEPRECATED, do not use (has no effect) */
#define MPROP_ORDER 7 /* DEPRECATED, do not use (has no effect) */
#define MPROP_PADMENU 9 /* DEPRECATED, do not use (has no effect) */
/**
* @brief Creates a new menu object.
*
* The handler function should be prototyped as:
*
* public <function>(id, menu, item)
* id - Client the menu is being acted upon.
* menu - Menu resource identifier.
* item - Item the client selected. If less than 0, the menu was
* cancelled and the item is a status code. menu_display
* should never be called immediately if the item is a status
* code, for re-entrancy reasons.
*
* The handler function should always return PLUGIN_HANDLED to block
* any old menu handlers from potentially feeding on the menu, unless
* that is the desired functionality.
*
* @param title Title the menu should use.
* @param handler Name of the handler function. The function will be invoked
* once and only once to every menu_display() call.
* @param ml Unused (should be 0).
* @return Menu resource identifier which must be destroyed via
* menu_destroy(). All menus are destroyed when the plugin
* unloads.
* @error Function name not found.
*/
native menu_create(const title[], const handler[], ml=0);
/**
* Creates a menu item callback handler.
*
* The handler function should be prototyped as:
*
* public <function>(id, menu, item)
* id - Client index being displayed to.
* menu - Menu resource identifier.
* item - Item being drawn.
* <return> - ITEM_IGNORE to use the default functionality. ITEM_ENABLED to
* explicitly enable or ITEM_DISABLED to explicitly disable.
*
* @param function Function name.
* @return Menu callback ID.
*/
native menu_makecallback(const function[]);
/**
* Adds an menu to a menu.
*
* @param menu Menu resource identifier.
* @param name Item text to display.
* @param info Item info string for internal information.
* @param paccess Access required by the player viewing the menu.
* @param callback If set to a valid ID from menu_makecallback(), the
* callback will be invoked before drawing the item.
* @noreturn
* @error Invalid menu resource.
*/
native menu_additem(menu, const name[], const info[]="", paccess=0, callback=-1);
/**
* Returns the number of pages in a menu.
*
* @param menu Menu resource identifier.
* @return Number of pages in the menu.
* @error Invalid menu resource.
*/
native menu_pages(menu);
/**
* Returns the number of items in a menu.
*
* @param menu Menu resource identifier.
* @return Number of items in the menu.
* @error Invalid menu resource.
*/
native menu_items(menu);
/**
* Displays a menu to one client. This should never be called from a handler
* when the item is less than 0 (i.e. calling this from a cancelled menu will
* result in an error).
*
* @param id Client index.
* @param menu Menu resource identifier.
* @param page Page to start from (starting from 0).
* @noreturn
* @error Invalid menu resource or client index.
*/
native menu_display(id, menu, page=0);
/**
* Given a page on a menu and a keypress on that page, returns the item id selected.
* If the item is less than 0, a special option was chosen (such as MENU_EXIT).
*
* @param menu Menu resource identifier.
* @param page Page on the menu.
* @param key Key pressed (from 1 to 10).
* @return Item identifier, or <0 for a special selection code.
* @error Invalid menu resource.
*/
native menu_find_id(menu, page, key);
/**
* Retrieves info about a menu item.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param access Variable to store access value.
* @param info Buffer to store item info.
* @param infolen Item info buffer length.
* @param name Buffer to store item display text.
* @param namelen Item name buffer length.
* @param callback Callback ID.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_getinfo(menu, item, &access, info[], infolen, name[]="", namelen=0, &callback);
/**
* Sets an item's display text.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param name New item display text.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setname(menu, item, const name[]);
/**
* Sets an item's info string.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param info New item info string.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setcmd(menu, item, const info[]);
/**
* Sets an item's callback.
*
* @param menu Menu resource identifier.
* @param item Item identifier.
* @param callback New callback from menu_makecallback(), or -1 to clear.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource.
*/
native menu_item_setcall(menu, item, callback=-1);
/**
* Destroys a menu. Player menus will be cancelled (although may still linger
* on the HUD), and future attempts to access the menu resource will result in
* an error.
*
* This must be called if you create menus dynamically, otherwise you will
* leak memory. For normal dynamic menus, you will destroy the menu in the
* handler function (remembering to handle the case of a menu being cancelled,
* it must still be destroyed).
*
* @param menu Menu resource identifier.
* @noreturn
* @error Invalid menu resource.
*/
native menu_destroy(menu);
/**
* Returns information about a menu (if any) the client is currently viewing.
*
* If newmenu is valid, then the menu will refer to the menuid associated with
* the title. If newmenu is not valid, and the menu is valid, then the player
* is viewing a menu displayed with show_menu().
*
* Both may be invalid if the player is not viewing a menu.
*
* @param id Client index.
* @param menu Variable to store old menu id. If none, then <1 will be
* stored.
* @param newmenu Variable to store new menu id. If none, then -1 will be
* stored.
* @param menupage Variable to store current page of the new menu, if any.
* @return 1 if the player is viewing a menu, 0 otherwise.
* @error Invalid client.
*/
native player_menu_info(id, &menu, &newmenu, &menupage=0);
/**
* Adds a blank line to a menu.
*
* @param menu Menu resource identifier.
* @param slot 1 (default) if the line should shift the numbering down.
* 0 if the line should be a visual shift only.
* @noreturn
* @error Invalid menu resource.
*/
native menu_addblank(menu, slot=1);
/**
* Adds a text line to a menu. Only available in amxmodx 1.8.1 and above.
*
* @param menu Menu resource identifier.
* @param text Text to add.
* @param slot 1 (default) if the line should shift the numbering down.
* 0 if the line should be a visual shift only.
* @noreturn
* @error Invalid menu resource.
*/
native menu_addtext(menu, const text[], slot=1);
/**
* Sets a menu property.
*
* @param menu Menu resource identifier.
* @param prop MPROP_ constant.
* @param ... Property parameters.
* @return 1 on success, 0 on failure.
* @error Invalid menu resource or property.
*/
native menu_setprop(menu, prop, ...);
/**
* Cancels a player's menu, effectively forcing the player to select MENU_EXIT.
* The menu will still exist on their screen but any results are invalidated,
* and the callback is invoked.
*
* @param player Client index.
* @noreturn
* @error Invalid client index.
*/
native menu_cancel(player);

View File

@@ -0,0 +1,753 @@
/* NS module functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined NS_INC
#endinput
#endif
#define NS_INC
#if AMXX_VERSION_NUM >= 175
#pragma reqlib ns
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib ns
#endif
#else
#pragma library ns
#endif
#include <ns_const>
/**
* Called whenever the client's class is changed.
*
* @param id The index of the player who changed.
* @param newclass The class the client changed to. Check the class enum in ns_const.inc.
* @param oldclass The class the client changed from. Check the class enum in ns_const.inc.
* @noreturn
*/
forward client_changeclass(id, newclass, oldclass);
/**
* Called whenever the client builds a structure.
*
* @param idPlayer The player index who triggered the building.
* @param idStructure The structure index that was created.
* @param type The type of structure that was built (1 for marine, 2 for alien).
* @param impulse The impulse command that was issued to build this structure.
* @noreturn
*/
forward client_built(idPlayer, idStructure, type, impulse);
/**
* Tell whether or not the map is combat.
*
* @return 1 if combat, 0 otherwise.
*/
native ns_is_combat();
/**
* Returns the gameplay type for the currently active map.
* Refer to ns_const.inc's NSGameplay enum for details.
*
* @note The earliest this is guaranteed to be accurate is during plugin_init(). It needs
* the info_gameplay entity to be properly set within the map, or it will return "Unknown",
* or "Cantfind".
*
* @return Return the gameplay mode, as accurate as the module can tell.
*/
native NSGameplay:ns_get_gameplay();
/**
* Exact syntax as get_user_team, but should be more accurate.
*
* @param id Player id.
* @param buff Buffer to store team name in.
* @param len Buffer length.
* @return The pev_team setting for the player.
*/
native ns_get_user_team(id, buff[], len);
/**
* Send an NS-style popup message.
*
* @param target The client to receive the message. Set to 0 to send to everybody.
* @param szMsg The message to send, 180 characters max.
* @param ah Whether to only display the message on clients who have the cvar "cl_autohelp" set to 1.
* @noreturn
*/
native ns_popup(target, const szMsg[180], ah=0);
/**
* Sets a player model. Omit the second parameter to return to default
*
* @note The model does not revert on death, teamswitch, gestation, etc.
*
* @param id The player id to change.
* @param szModel The model to change to.
* @noreturn
*/
native ns_set_player_model(id, const szModel[]="");
/**
* Sets a player skin. Omit the second parameter to return to default
*
* @note The skin does not revert on death, teamswitch, gestation, etc.
*
* @param id The player id to change.
* @param skin The skin number to change to.
* @noreturn
*/
native ns_set_player_skin(id, skin=-1);
/**
* Sets a player body. Omit the second parameter to return to default
*
* @note The body does not revert on death, teamswitch, gestation, etc.
*
* @param id The player id to change.
* @param body The body number to change to.
* @noreturn
*/
native ns_set_player_body(id, body=-1);
/**
* Set this to modify the player's speed by a certain amount.
*
* @note The speed does not revert on death, teamswitch, gestation, etc.
*
* @param id The player id to change.
* @param speedchange The speed to modify the player speed by. Set to 0 to revert to default speed.
* @noreturn
*/
native ns_set_speedchange(id, speedchange=0);
/**
* Returns a client's current speed modifier.
*
* @param id The client id to check.
* @return The module's current speed modifier for the client.
*/
native ns_get_speedchange(id);
/**
* Returns a client's maxspeed before the speed change modifier is factored in.
*
* @param id The client id to check.
* @return The maxspeed for the client.
*/
native ns_get_maxspeed(id);
/* Returns whether or not this mask is set from the entity's iuser4 field. Use the "mask" enum for reference. */
native ns_get_mask(id,mask);
/* Sets or removes the mask from the entity's iuser4 field. Set "value" to 1 to turn the mask on, 0 to turn it off. */
native ns_set_mask(id,mask,value);
/* Returns built/unbuilt structures.
If:
builtOnly is 1 (default):
Only fully built structures are counted.
builtOnly is 0:
Any structure meeting the classname is counted.
Number is 0 (default):
The total number of matching structures is returned.
Number is any other value:
The index of the #th matching structure is returned.
*/
native ns_get_build(const classname[],builtOnly=1,Number=0);
/* Returns if the player has the weapon or not in their pev->weapons field.
set "setweapon" to 0 to turn the bit off, set to 1 to turn it on. Or omit it to just return the value. */
native ns_has_weapon(id,weapon,setweapon=-1);
/* Gets spawn point for specified team (type).
If:
Team is equal to 0:
Ready room spawns are returned.
Team is greater than 0:
Spawns for the team are returned.
Number is equal to 0:
Total number of spawns is returned.
Number is greater than 0:
The location of the specified spawn is returned.
*/
native ns_get_spawn(team,number=0,Float:ret[3]);
/* Returns the class of the player. Look in the classes enum in ns_const.inc for the value's meaning. */
native ns_get_class(id);
/**
* Gets the player's jetpack fuel reserve.
*
* @param id The player to get fuel from.
* @return The amount of fuel in the player's reserve. (0.0 through 100.0)
*/
native Float:ns_get_jpfuel(id);
/**
* Sets the player's jetpack fuel reserve.
*
* @param id The player to set fuel.
* @param fuel The amount of fuel to set, as a percentage (0.0 through 100.0)
* @noreturn
*/
native ns_set_jpfuel(id, Float:fuel);
/**
* Adds to the player's jetpack fuel reserve.
*
* @param id The player to add fuel to.
* @param amount The amount of fuel to add, as a percentage (0.0 through 100.0)
* @return The new amount of fuel in the player's reserve. (0.0 through 100.0)
*/
native Float:ns_add_jpfuel(id, Float:amount);
/**
* Gets the player's energy percentage.
*
* @param id The player to get the energy from.
* @return The amount of energy the player has (0.0 through 100.0)
*/
native Float:ns_get_energy(id);
/**
* Sets the player's energy percentage.
*
* @param id The player to set the energy on.
* @param energy The amount of energy to set (0.0 through 100.0)
* @noreturn
*/
native ns_set_energy(id, Float:energy);
/**
* Adds to the player's energy percentage.
*
* @param id The player to add the energy to.
* @param amount The amount of energy to add to the player.
* @return The new amount of energy the player has (0.0 through 100.0)
*/
native Float:ns_add_energy(id, Float:amount);
/**
* Returns a player's resources.
*
* @note This is only for alien players.
* @param id The id of the player to check.
* @return Amount of resources this player has.
*/
native Float:ns_get_res(id);
/**
* Sets a player's resources.
*
* @note This is only for alien players.
* @param id The id of the player to set.
* @param res Amount of resources to set on this player.
* @noreturn
*/
native ns_set_res(id, Float:res);
/**
* Adds an amount of resources to the player.
*
* @note This is only for alien players.
* @param id The id of the player to add resources to.
* @param amount The amount to add to the player.
* @return The new amount of resources the player has.
*/
native Float:ns_add_res(id, Float:amount);
/**
* Returns the team's resources.
*
* @param Team 1 for teama, 2 for teamb. (eg: in MvA maps, 1 is marines,
2 is aliens. In mvm, 1 is marine1, 2 is marine2)
* @return The amount of resources in this team's resource pool.
*/
native Float:ns_get_teamres(Team);
/**
* Sets the team's resources in the resource pool.
*
* @note If this is used on an alien team, the resources will be
* distributed between all of the players who need resources.
* @param Team 1 for teama, 2 for teamb. (eg: in MvA maps, 1 is marines,
* 2 is aliens. In mvm, 1 is marine1, 2 is marine2)
* @param value The amount to set the resources to set to.
* @noreturn
*/
native ns_set_teamres(Team, Float:value);
/**
* Adds to the team's resources in the resource pool.
*
* @note If this is used on an alien team, the resources will be
* distributed between all of the players who need resources.
* @param Team 1 for teama, 2 for teamb. (eg: in MvA maps, 1 is marines,
* 2 is aliens. In mvm, 1 is marine1, 2 is marine2)
* @param value The amount to set the resources to add to the pool
* @return The new amount of resources in the resource pool.
*/
native Float:ns_add_teamres(Team,Float:value);
/**
* Returns the player's experience.
*
* @note Combat only.
* @param id The player to get experience value from.
* @return The amount of experience this player has.
*/
native Float:ns_get_exp(id);
/**
* Sets the player's experience.
*
* @note Combat only.
* @param id The player to set experience value on.
* @param exp The amount of experience this player will have.
* @noreturn
*/
native ns_set_exp(id,Float:exp);
/**
* Adds to the player's experience.
*
* @note Combat only.
* @param id The player to add experience value to.
* @param value The amount of experience this player will receive.
* @return The new amount of experience this player has.
*/
native Float:ns_add_exp(id, Float:value);
/**
* Gets the player's points spent count in combat.
*
* @param id The player to check.
* @return The amount of points this player has spent.
*/
native ns_get_points(id);
/**
* Sets the player's points spent count in combat.
*
* @param id The player to set this on.
* @param points The amount to set this to.
* @noreturn
*/
native ns_set_points(id, points);
/**
* Adds to the player's points spent count in combat.
*
* @param id The player to add this to.
* @param value The value to add to the points spent.
* @return The new value of the points spent variable.
*/
native ns_add_points(id,points);
/**
* Gets the damage for this weapon.
*
* @note Use weapon index, not player index!
* @param idWeapon The entity index of the weapon to check.
* @return The damage this weapon does.
*/
native Float:ns_get_weap_dmg(idWeapon);
/**
* Sets the damage for this weapon.
*
* @note Use weapon index, not player index!
* @param idWeapon The entity index of the weapon to set.
* @param damage The damage to make this weapon cause.
* @noreturn
*/
native ns_set_weap_dmg(idWeapon, Float:damage);
/**
* Gets the maximum range for this weapon.
*
* @note Use weapon index, not player index!
* @param idWeapon The entity index of the weapon to check.
* @return The maximum range this weapon has.
*/
native Float:ns_get_weap_range(idWeapon);
/**
* Sets the maximum range for this weapon.
*
* @note Use weapon index, not player index!
* @param idWeapon The entity index of the weapon to set.
* @param range The maximum range this weapon will have.
* @noreturn
*/
native ns_set_weap_range(idWeapon, Float:range);
/**
* Gets the weapon's clip ammo.
*
* @note Use weapon index, not player index!
* @param idWeapon The weapon to get the clip ammo from.
* @return The amount of ammunition in the weapon's clip.
*/
native ns_get_weap_clip(idWeapon);
/**
* Sets the weapon's ammo in the clip.
*
* @note Use weapon index, not player index!
* @param idWeapon The weapon to set the clip ammo on.
* @param clipsize The amount of ammunition to set in the weapon's clip.
* @noreturn
*/
native ns_set_weap_clip(idWeapon, clipsize);
/**
* Gets the player's weapon reserve (backpack ammo) for the specified
* type of weapon.
*
* @note Use player index, not weapon index!
* @param id The player id to check ammo count on.
* @param weapon The weapon type to check ammo count for.
* @return The ammunition count in the player's reserve.
*/
native ns_get_weap_reserve(id,weapon);
/**
* Sets the player's weapon reserve (backpack ammo) for the specified
* type of weapon.
*
* @note Use player index, not weapon index!
* @param id The player id to set ammo count on.
* @param weapon The weapon type to set ammo count for.
* @param ammo The ammunition count to set.
* @noreturn
*/
native ns_set_weap_reserve(id,weapon,ammo);
/**
* Gets the player's score.
*
* @note The score from level is automatically factored into the scoreboard in combat.
* @param idPlayer The player to get the score for.
* @return The player's score.
*/
native ns_get_score(idPlayer);
/**
* Sets the player's score.
*
* @note The score from level is automatically factored into the scoreboard in combat.
* @param idPlayer The player to get the score for.
* @param score What to set the player's score as.
* @noreturn
*/
native ns_set_score(idPlayer, score);
/* Adds to a player's score
* Returns the new score on success
*/
native ns_add_score(idPlayer,score);
/* Gets a player's death count. */
native ns_get_deaths(idPlayer);
/* Sets a player's death count. */
native ns_set_deaths(idPlayer,numdeaths);
/* Adds to a player's death count
* Returns the new death count on success
*/
native ns_add_deaths(idPlayer,numdeaths);
/* Gets the index of the owner of a structure. -1 for no owner. */
native ns_get_struct_owner(idStructsure);
/* Sets the index of the owner of a structure. -1 for no owner. */
native ns_set_struct_owner(idStructure,indexOwner);
/* Gets the trait type tied to the hive. Look at the hivetrait enum for the values. */
native ns_get_hive_trait(idHive);
/* Sets the trait type tied to the hive. Look at the hivetrait enum for the values. */
native ns_set_hive_trait(idHive,trait);
/* Sets the players field of view, set "_fov" to 0.0 (or omit it) to return to normal. FOV change will persist until disconnect unless reset by a plugin */
native ns_set_fov(idPlayer,Float:_fov=0.0);
/**
* Give the player an item.
*
* @param id The player to give the item to.
* @param class The map-classname of the entity to give to the player.
* @noreturn
*/
native ns_give_item(id, const class[]);
/**
* Returns 1 if a player has the hive ability number.
* If ability is 0, it will return the number of active hives.
*
* @param idPlayer The player index to look up.
* @param ability The ability number to check, set to 0 to get number of active hives.
* @return If ability is != 0, returns 1 or 0 depending on if the client has the ability.
* If ability is 0, returns the number of active hives.
*/
native ns_get_hive_ability(idPlayer, ability=0);
/**
* Triggered whenever a client's pev->team changes.
*
* @param id The id of the client.
* @param newteam The team number of the new team.
* @param oldteam The team number of the old team.
* @noreturn
*/
forward client_changeteam(id, newteam, oldteam);
/**
* Triggered whenever a client's pev->deadflag changes from >0 to 0.
*
* @param id The id of the client.
* @noreturn
*/
forward client_spawn(id);
/**
* Calls NS's private damage routine on the victim entity.
*
* @deprecated
* @note This is provided for backwards compatibility with peachy's module.
* It is suggested to use hamsandwich for this action instead.
*
* @param IDVictim The victim that is taking the damage.
* @param IDInflictor The entity that is causing the damage (weapon, etc).
* @param IDAttacker The attacker who is triggering the damage (person shooting).
* @param Damage The amount of damage being done.
* @param DamageType The damage type being done (bitmask).
*/
native ns_takedamage(IDVictim, IDInflictor, IDAttacker, Float:Damage, DamageType);
/**
* Attempts to unstick a player.
*
* @param id Player to unstick.
* @param StartDistance Distance to start from the player to check for a new location.
* @param MaxAttempts How many attempts to try to find a new spot before giving up.
* @return 1 on success, 0 on cannot find a place to move player to,
* -1 on invalid state (stunned/webbed), -2 on invalid class (comm/egg)
* -3 if the player is dead or a spectator, -4 on invalid player,
* -5 if the player is not connected.
*/
native ns_unstick_player(id, StartDistance=32, MaxAttempts=128);
/**
* Whether or not there is a game in progress.
*
* @return true if a game is in progress, false otherwise.
*/
native bool:ns_round_in_progress();
/**
* Called at the approximate time that a round is started.
*
* @noreturn
*/
forward round_start();
/**
* Called immediately when a round ends
*
* @param roundtime The length of the round in seconds.
* @noreturn
*/
forward round_end(Float:roundtime);
forward map_reset(isload);
native ns_get_weapon(idPlayer,weaponid,&weapontype=0);
/* Returns the location name of the provided x/y position
* (z origin is ignored; can't have location over location)
* -
* Note that as of NS 3.2 beta 2, on the following maps
* the returned string should be passed through ns_lookup_title
* to be human readable:
* ns_bast, ns_hera, ns_nothing, ns_tanith,
* ns_nancy, ns_caged, ns_eclipse, ns_veil
*
* Passing the 5th parameter as non zero will auto look up
* the title if it exists.
*/
native ns_get_locationname(Float:x, Float:y, name[], len, titlelookup=0);
/* Looks up a key from titles.txt
* Returns -1 if the key is not found
* Otherwise it returns the length of the output
*/
native ns_lookup_title(const KeyName[], Output[], length);
/* Forces the structure to fully build
* Removes the ghost state from marine structures.
* Do not use this on hives! It wont work.
*/
native ns_build_structure(idStructure);
/* Forces the structure to begin recycling
* Passing an index other than a marine structure will
* have undefined results!
* -
* Note: This calls a private NS function!
* Be careful when using this!
*/
native ns_recycle(idStructure);
/* Forces the weldable to trigger
* Passing an index other than a weldable
* will have undefined results!
* -
* NS renames func_weldable to avhweldable
* at map load.
* -
* Note: This calls a private NS function!
* Be careful when using this!
*/
native ns_finish_weldable(idWeldable);
/* Gets the total time needed to weld this
* func_weldable shut.
* Note: NS renames "func_weldable"s to "avhweldable"s
* at run time!
*/
native Float:ns_get_weld_time(idWeldable);
/* Sets the total time needed to weld this
* func_weldable shut.
*/
native ns_set_weld_time(idWeldable,Float:value);
/* Adds to the weldable's time required to open.
* Returns the new required time on success.
* Note this native clamps the low value to 0.
*/
native Float:ns_add_weld_time(idWeldable,Float:value);
/* Gets the total time this func_weldable
* has been welded.
*/
native Float:ns_get_weld_done(idWeldable);
/* Sets the total time this func_weldable
* has been welded.
*/
native ns_set_weld_done(idWeldable,Float:value);
/* Adds to the total time this func_weldable
* has been welded. Returns the new value.
* Note this native clamps the low value to 0.0
*/
native Float:ns_add_weld_done(idWeldable,Float:value);
/* Gets/sets/adds to the energy pool of this observatory. */
native Float:ns_get_obs_energy(idObs);
native ns_set_obs_energy(idObs,Float:value);
native Float:ns_add_obs_energy(idObs,Float:value);
/**
* Removes an upgrade from the player's bought and active upgrade lists.
* This will not refund the points spent on the upgrade, nor will it
* immediately strip the upgrade if the player is alive. Rather, it will
* make it so the player no longer receives the upgrade on spawn.
*
* @note This only works in combat.
* @params idPlayer The player index to change upgrades for.
* @params ugprade The impulse number for the upgrade to strip.
* @return 2 for upgrade removed from player's bought and active list.
* 1 for upgrade removed from player's bought list only.
* 3 for upgrade removed from player's active list only (shouldn't happen, just incase.)
* 0 for the player didn't have the upgrade in either list.
*/
native ns_remove_upgrade(idPlayer, upgrade);
/**
* Particle system natives
* -
* The particle system emulates a map-based custom particle system.
* Familiarity with the keyvalues from the map-based particle systems
* is recommended! You will be lost otherwise!
* -
* prsearle's NSPEdit is also recommended for designing the systems:
* http://homepage.ntlworld.com/pr.searle/NSPSEdit/NSPSEdit.html
*/
/* Creates a handle to the a particle system to configure
* -
* Note! this is not a particle system you can pass to
* ns_fire_ps()!
*/
native RawPS:ns_create_ps();
/* Sets the name of the particle system.
* -
* This is used for things like ns_get_ps_id()
* and through calling another particle system
* through the "ps_to_gen" field
*/
native ns_set_ps_name(RawPS:system, const name[]);
/* Sets the sprite to use for the particle system
* -
* You do NOT have to precache the sprite, BUT
* the sprite must obviously be on the client to
* display.
*/
native ns_set_ps_sprite(RawPS:system, const sprite[]);
/* Finalizes the particle system. Do not configure it after this.
* A usable particle system handle is returned.
*/
native Particle:ns_spawn_ps(RawPS:system);
/* Draws a particle system at the given origin (and angles)
* Flags are the FEV_* defines from hlsdk_const.inc
* Only use handles returned by ns_spawn_ps or ns_get_ps_id here!
*/
native ns_fire_ps(Particle:system,const Float:origin[3],const Float:angles[3]={0.0,0.0,0.0}, flags=0);
/* Looks up a particle system by name
* Returns a usable particle system handle.
*/
native Particle:ns_get_ps_id(const Name[]);
/* The following are the parameters for configuring the
* particle system. Look through the fgd and NSPSEdit
* for details!
*/
native ns_set_ps_genrate(RawPS:system, genrate);
native ns_set_ps_genshape(RawPS:system, NSPS_GenShape:genshape);
native ns_set_ps_genshape_params(RawPS:system, const params[]);
native ns_set_ps_spriteframes(RawPS:system, spriteframes);
native ns_set_ps_numparticles(RawPS:system, numparticles);
native ns_set_ps_size(RawPS:system, Float:size);
native ns_set_ps_vel_params(RawPS:system, const params[]);
native ns_set_ps_vel_shape(RawPS:system, NSPS_VelShape:shape);
native ns_set_ps_sys_life(RawPS:system, Float:lifetime);
native ns_set_ps_particle_life(RawPS:system, Float:lifetime);
native ns_set_ps_rendermode(RawPS:system, NSPS_RenderMode:rendermode);
native ns_set_ps_to_gen(RawPS:system, const name[]);
native ns_set_ps_anim_speed(RawPS:system, speed);
native ns_set_ps_spawn_flags(RawPS:system, NSPS_Flags:flags);
native ns_set_ps_base_color(RawPS:system, const colors[]);
native ns_set_ps_scale(RawPS:system, Float:scale);
native ns_set_ps_max_alpha(RawPS:system, Float:maxalpha);

View File

@@ -0,0 +1,263 @@
/* NS2AMX Utility backwards compatibility
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _ns2amx_included
#endinput
#endif
#define _ns2amx_included
#include <engine> // various engine calls
#include <fakemeta> // pev/engfunc/dllfunc/various calls which rely on engfunc/dllfunc
#include <ns> // ns specifics
stock is_entity(id)
return is_valid_ent(id);
/* The end of the native is buffered incase the plugin is including an NS_VERSION (no longer supported), ignore it */
stock get_build(classname[], value, number=0,any:...)
return ns_get_build(classname, value, number);
stock get_private_i(index, offset, linuxdiff=5)
return get_pdata_int(index, offset, linuxdiff);
stock set_private_i(index, offset, value, linuxdiff=5)
{
return set_pdata_int(index, offset, value, linuxdiff);
}
stock Float:get_private_f(index, offset, linuxdiff=5)
{
return get_pdata_float(index, offset, linuxdiff);
}
stock set_private_f(index, offset, Float:value, linuxdiff=5)
{
return set_pdata_float(index, offset, value, linuxdiff);
}
stock make_string(value[])
return engfunc(EngFunc_AllocString,value);
stock string(value, ret[])
{
new szString[128];
engfunc(EngFunc_SzFromIndex,value,szString,127);
copy(ret,127,szString);
}
stock gpgobals_time()
return floatround(halflife_time());
stock Float:get_range(ida, idb)
return entity_range(ida, idb);
stock supercede()
return 0;
stock register_clientkill()
return 0;
stock register_changelvl()
return 0;
stock register_msgblock(msgName[])
return set_msg_block(get_user_msgid(msgName), BLOCK_SET);
stock register_msgedit(msgName[], cmd[])
return register_message(get_user_msgid(msgName), cmd);
stock register_playback(event, cmd[])
return 0;
stock get_spawn(type, number=0, Float:ret[3])
return ns_get_spawn(type, number, ret);
stock has_weapon(index, weapon, setweapon=-1)
return ns_has_weapon(index, weapon, setweapon);
stock gpglobals_v(type, Float:ret[3])
{
new v_type=0;
switch (type)
{
case 1:
v_type = GL_v_forward;
case 2:
v_type = GL_v_right;
case 3:
v_type = GL_v_up;
}
if (!v_type)
return 0;
return get_global_vector(v_type, ret);
}
stock pev_i(_index,_field)
return pev(_index,_field);
stock set_pev_i(_index, _field, _val)
return set_pev(_index,_field,_val);
stock Float:pev_f(_index,_field)
{
new Float:f;
pev(_index,_field,f);
return f;
}
stock set_pev_f(_index,_field,Float:_val)
return set_pev(_index,_field,_val);
stock msg_args()
return get_msg_args();
stock Float:msg_loc(vec)
{
new Float:Ret[3];
get_msg_origin(Ret);
if (vec < 0 || vec > 3)
return float(0);
else
return Ret[vec];
return 0.0; // make compiler happy!
}
stock msg_dest()
return 0;
stock msg_type()
return 0;
stock msg_name()
return 0;
stock msg_set_s(number, value[])
return set_msg_arg_string(number, value);
stock msg_set_f(number, Float:value)
return set_msg_arg_float(number, get_msg_argtype(number), value);
stock msg_set_i(number, value)
return set_msg_arg_int(number, get_msg_argtype(number), value);
stock msg_data_type(value)
return get_msg_argtype(value);
stock msg_strdata(value)
return 0;
stock msg_data(value, ...)
{
return (0*value);
}
stock get_filename(szFile[], len=-1)
{
new name[16], version[16], author[16], status[16];
new res = get_plugin(0, szFile, len, name, 16, version, 16, author, 16, status, 16);
return res;
}
stock get_speedchange(id)
return ns_get_speedchange(id);
stock set_speedchange(id, speed)
return ns_set_speedchange(id,speed);
stock get_maxspeed(id)
return ns_get_maxspeed(id);
stock set_player_model(id, model[]="")
return ns_set_player_model(id, model);
stock set_player_skin(id, skin=-1)
return ns_set_player_skin(id, skin);
stock set_player_body(id, body=-1)
return ns_set_player_body(id, body);
stock ns2amx_version()
return 0;
stock set_kvhandled()
return 0;
stock ns2amx_getammo(id,Weapon)
return ns_get_weap_reserve(id, Weapon);
stock ns2amx_setammo(id,Weapon,Value)
return ns_set_weap_reserve(id, Weapon, Value);
stock ns2amx_giveitem(id,svClassname[])
return ns_give_item(id, svClassname);
stock ns2amx_moveto(idMoved,idDest)
{
new Float:origin[3];
entity_get_vector(idDest, EV_VEC_origin,origin);
entity_set_origin(idMoved, origin);
return 1;
}
/* Returns whether or not the player has the MASK_DIGESTING flag set. */
stock ns2amx_isdigesting(id)
return ns_get_mask(id,MASK_DIGESTING);
/* Returns total # of active hives. */
stock ns2amx_gethives()
return ns_get_build("team_hive",1);
/* Returns 1 if the two entities are within the given range. */
stock ns2amx_inrange(ida,idb,range)
{
if (entity_range(ida,idb) <= range)
return 1;
return 0;
}
stock ns2amx_nspopup(id,svMessage[190]) {
new szMessage[180];
copy(szMessage,179,svMessage);
return ns_popup(id, szMessage);
}
stock ns2amx_setres(id,value)
return ns_set_res(id, float(value));
stock ns2amx_getenergy(id)
return floatround(ns_get_energy(id));
stock ns2amx_setenergy(id,energy)
return ns_set_energy(id, float(energy));
stock ns2amx_getjpfuel(id)
return floatround(ns_get_jpfuel(id));
stock ns2amx_setjpfuel(id,fuel)
return ns_set_jpfuel(id, float(fuel));
stock get_mask(id,mask)
return ns_get_mask(id, mask);
stock set_mask(id,mask,value)
return ns_set_mask(id,mask,value);
stock get_special(id,mask)
{
if (pev(id,pev_iuser4) & mask)
return 1;
return 0;
}
stock get_res(id)
return floatround(ns_get_res(id));
stock get_class(id)
return ns_get_class(id);
stock is_combat()
return ns_is_combat();

View File

@@ -0,0 +1,192 @@
/* NS module constants
*
* by the AMX Mod X Development Team
* Most definitions graciously provided by Flayra
*
* This file is provided as is (no warranties).
*/
#if defined NS_CONST_INC
#endinput
#endif
#define NS_CONST_INC
enum NSGameplay
{
NSGame_CantTell, /**< It is too soon to tell (can't find avhgameplay
entity or it doesn't have private data) */
NSGame_MarineVAlien, /**< Marine vs Aliens (standard) gameplay */
NSGame_MarineVMarine, /**< Marine vs Marine */
NSGame_AlienVAlien, /**< Alien vs Alien */
NSGame_Unknown, /**< Can find the gameplay entity, but can't
determine gameplay type. */
};
// entity pev->iuser4 fields
enum {
MASK_NONE = 0,
MASK_SIGHTED = 1,
MASK_DETECTED = 2,
MASK_BUILDABLE = 4,
MASK_BASEBUILD0 = 8, // Base build slot #0
MASK_WEAPONS1 = 8, // Marine weapons 1
MASK_CARAPACE = 8, // Alien carapace
MASK_WEAPONS2 = 16, // Marines weapons 2
MASK_REGENERATION = 16, // Alien regeneration
MASK_BASEBUILD1 = 16, // Base build slot #1
MASK_WEAPONS3 = 32, // Marine weapons 3
MASK_REDEMPTION = 32, // Alien redemption
MASK_BASEBUILD2 = 32, // Base build slot #2
MASK_ARMOR1 = 64, // Marine armor 1
MASK_CELERITY = 64, // Alien celerity
MASK_BASEBUILD3 = 64, // Base build slot #3
MASK_ARMOR2 = 128, // Marine armor 2
MASK_ADRENALINE = 128, // Alien adrenaline
MASK_BASEBUILD4 = 128, // Base build slot #4
MASK_ARMOR3 = 256, // Marine armor 3
MASK_SILENCE = 256, // Alien silence
MASK_BASEBUILD5 = 256, // Base build slot #5
MASK_JETPACK = 512, // Marine jetpacks
MASK_CLOAKING = 512, // Alien cloaking
MASK_BASEBUILD6 = 512, // Base build slot #6
MASK_FOCUS = 1024, // Alien focus
MASK_MOTION = 1024, // Marine motion tracking
MASK_BASEBUILD7 = 1024, // Base build slot #7
MASK_SCENTOFFEAR = 2048, // Alien scent of fear
MASK_DEFENSE2 = 4096, // Defense level 2
MASK_DEFENSE3 = 8192, // Defense level 3
MASK_ELECTRICITY = 8192, // Electricy
MASK_MOVEMENT2 = 16384, // Movement level 2,
MASK_MOVEMENT3 = 32768, // Movement level 3
MASK_HEAVYARMOR = 32768, // Marine heavy armor
MASK_SENSORY2 = 65536, // Sensory level 2
MASK_SENSORY3 = 131072, // Sensory level 3
MASK_ALIEN_MOVEMENT = 262144, // Onos is charging
MASK_WALLSTICKING = 524288, // Flag for wall-sticking
MASK_PRIMALSCREAM = 1048576, // Alien is in range of active primal scream
MASK_UMBRA = 2097152, // In umbra
MASK_DIGESTING = 4194304, // When set on a visible player, player is digesting. When set on invisible player, player is being digested
MASK_RECYCLING = 8388608, // Building is recycling
MASK_TOPDOWN = 16777216, // Commander view
MASK_PLAYER_STUNNED = 33554432, // Player has been stunned by stomp
MASK_ENSNARED = 67108864, // Webbed
MASK_ALIEN_EMBRYO = 134217728, // Gestating
MASK_SELECTABLE = 268435456, // ???
MASK_PARASITED = 536870912, // Parasite flag
MASK_SENSORY_NEARBY = 1073741824 // Sensory chamber in range
};
enum {
CLASS_UNKNOWN = 0,
CLASS_SKULK,
CLASS_GORGE,
CLASS_LERK,
CLASS_FADE,
CLASS_ONOS,
CLASS_MARINE,
CLASS_JETPACK,
CLASS_HEAVY,
CLASS_COMMANDER,
CLASS_GESTATE,
CLASS_DEAD,
CLASS_NOTEAM
};
enum {
WEAPON_NONE = 0,
WEAPON_CLAWS,
WEAPON_SPIT,
WEAPON_SPORES,
WEAPON_SPIKE,
WEAPON_BITE,
WEAPON_BITE2,
WEAPON_SWIPE,
WEAPON_WEBSPINNER,
WEAPON_METABOLIZE,
WEAPON_PARASITE,
WEAPON_BLINK,
WEAPON_DIVINEWIND,
WEAPON_KNIFE,
WEAPON_PISTOL,
WEAPON_LMG,
WEAPON_SHOTGUN,
WEAPON_HMG,
WEAPON_WELDER,
WEAPON_MINE,
WEAPON_GRENADE_GUN,
WEAPON_LEAP,
WEAPON_CHARGE,
WEAPON_UMBRA,
WEAPON_PRIMALSCREAM,
WEAPON_BILEBOMB,
WEAPON_ACIDROCKET,
WEAPON_HEALINGSPRAY,
WEAPON_GRENADE,
WEAPON_STOMP,
WEAPON_DEVOUR,
WEAPON_MAX
};
enum {
HIVETRAIT_NONE = 0,
HIVETRAIT_DC = 92,
HIVETRAIT_SC = 93,
HIVETRAIT_MC = 94
};
enum NSPS_VelShape
{
NSPS_VS_POINT = 1,
NSPS_VS_BOX,
NSPS_VS_SPHERE,
NSPS_VS_BLOB
};
/* Genshape used in ns_set_ps_genshape
* NOTE: The following are in the ns.ps file but
* are not listed in the .fgd file. Use
* at your own risk!
* Line, Triangle, Plane, Cylinder,
* Cone, Disc, Rectangle and None
*/
enum NSPS_GenShape
{
NSPS_GS_POINT = 0,
NSPS_GS_LINE,
NSPS_GS_TRIANGLE,
NSPS_GS_PLANE,
NSPS_GS_BOX,
NSPS_GS_CYLINDER,
NSPS_GS_CONE,
NSPS_GS_BLOB,
NSPS_GS_DISC,
NSPS_GS_RECTANGLE,
NSPS_GS_NONE
};
enum NSPS_RenderMode
{
NSPS_R_NORMAL = 0,
NSPS_R_TRANSCOLOR,
NSPS_R_TRANSTEXTURE,
NSPS_R_GLOW,
NSPS_R_TRANSALPHA,
NSPS_R_ADDITIVE
};
enum NSPS_Flags
{
NSPS_FL_START_ON = 1,
NSPS_FL_PARTICLE_DENSITY = 2,
NSPS_FL_FADE_IN = 4,
NSPS_FL_FADE_OUT = 8,
NSPS_FL_USE_GRAVITY = 16,
NSPS_FL_USE_TRI = 32,
NSPS_FL_CONSTRAIN_PITCH = 128,
NSPS_FL_COLLIDE = 256,
NSPS_FL_HI_DETAIL = 512,
NSPS_FL_FACE_UP = 1024
};

View File

@@ -0,0 +1,61 @@
/* nVault functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _nvault_included
#endinput
#endif
#define _nvault_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib nvault
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib nvault
#endif
#else
#pragma library nvault
#endif
/* All timestamps are in UNIX epoch form. */
/* Opens a vault by name (such as "myvault")
* Returns a vault id, INVALID_HANDLE otherwise (-1)
*/
native nvault_open(const name[]);
/* Gets a vault value by returning an int
* setting a byref float or setting a string + maxlength
*/
native nvault_get(vault, const key[], {Float,_}:...);
/* Looks up a vault value for full information
* Returns 0 if the entry is not found
*/
native nvault_lookup(vault, const key[], value[], maxlen, &timestamp);
/* Sets a vault value (with current timestamp) */
native nvault_set(vault, const key[], const value[]);
/* Sets a permanent vault value (no timestamp) */
native nvault_pset(vault, const key[], const value[]);
/* Prunes the vault for entries that are within the given timestamps.
* This will not erase values set with pset
*/
native nvault_prune(vault, start, end);
/* Closes a vault */
native nvault_close(vault);
/* Removes a key from the vault */
native nvault_remove(vault, const key[]);
/* "Touches" a key to update its timestamp value.
* If stamp is -1 (default), it will use the current time.
* Like the unix command "touch," it will create an empty key
* if the value does not exist.
*/
native nvault_touch(vault, const key[], timestamp=-1);

View File

@@ -0,0 +1,134 @@
/* Regular Expression API
* (C)2004 by David "BAILOPAN" Anderson
* Licensed under the GNU General Public License.
* No warranties of any kind.
*/
#if defined _regex_included
#endinput
#endif
#define _regex_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib regex
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib regex
#endif
#else
#pragma library regex
#endif
enum Regex
{
REGEX_MATCH_FAIL = -2,
REGEX_PATTERN_FAIL,
REGEX_NO_MATCH,
REGEX_OK
};
/**
* Precompile a regular expression. Use this if you intend on using the
* same expression multiple times. Pass the regex handle returned here to
* regex_match_c to check for matches.
*
* @param pattern The regular expression pattern.
* @param errcode Error code encountered, if applicable.
* @param error Error message encountered, if applicable.
* @param maxLen Maximum string length of the error buffer.
* @param flags General flags for the regular expression.
* i = Ignore case
* m = Multilines (affects ^ and $ so that they match
* the start/end of a line rather than matching the
* start/end of the string).
* s = Single line (affects . so that it matches any character,
* even new line characters).
* x = Pattern extension (ignore whitespace and # comments).
*
* @return -1 on error in the pattern, > valid regex handle (> 0) on success.
*
* @note This handle is automatically freed on map change. However,
* if you are completely done with it before then, you should
* call regex_free on this handle.
*/
native Regex:regex_compile(const pattern[], &ret, error[], maxLen, const flags[]="");
/**
* Matches a string against a pre-compiled regular expression pattern.
*
*
* @param pattern The regular expression pattern.
* @param string The string to check.
* @param ret Error code, if applicable, or number of results on success.
*
* @return -2 = Matching error (error code is stored in ret)
* 0 = No match.
* >1 = Number of results.
*
* @note You should free the returned handle (with regex_free())
* when you are done with this pattern.
*
* @note Use the regex handle passed to this function to extract
* matches with regex_substr().
*/
native regex_match_c(const string[], Regex:pattern, &ret);
/**
* Matches a string against a regular expression pattern.
*
* @note If you intend on using the same regular expression pattern
* multiple times, consider using regex_compile and regex_match_c
* instead of making this function reparse the expression each time.
*
* @param string The string to check.
* @param pattern The regular expression pattern.
* @param ret Error code, or result state of the match.
* @param error Error message, if applicable.
* @param maxLen Maximum length of the error buffer.
* @param flags General flags for the regular expression.
* i = Ignore case
* m = Multilines (affects ^ and $ so that they match
* the start/end of a line rather than matching the
* start/end of the string).
* s = Single line (affects . so that it matches any character,
* even new line characters).
* x = Pattern extension (ignore whitespace and # comments).
*
* @return -2 = Matching error (error code is stored in ret)
* -1 = Error in pattern (error message and offset # in error and ret)
* 0 = No match.
* >1 = Handle for getting more information (via regex_substr)
*
* @note Flags only exist in amxmodx 1.8 and later.
* @note You should free the returned handle (with regex_free())
* when you are done extracting all of the substrings.
*/
native Regex:regex_match(const string[], const pattern[], &ret, error[], maxLen, const flags[] = "");
/**
* Returns a matched substring from a regex handle.
* Substring ids start at 0 and end at ret-1, where ret is from the corresponding
* regex_match or regex_match_c function call.
*
* @param id The regex handle to extract data from.
* @param str_id The index of the expression to get - starts at 0, and ends at ret - 1.
* @param buffer The buffer to set to the matching substring.
* @param maxLen The maximum string length of the buffer.
*
*/
native regex_substr(Regex:id, str_id, buffer[], maxLen);
/**
* Frees the memory associated with a regex result, and sets the handle to 0.
* This must be called on all results from regex_match() when you are done extracting
* the results with regex_substr().
* The results of regex_compile() (and subsequently, regex_match_c()) only need to be freed
* when you are done using the pattern.
*
*
* @param id The regex handle to free.
*
* @noreturn
*
* @note Do not use the handle again after freeing it!
*/
native regex_free(&Regex:id);

View File

@@ -0,0 +1,64 @@
/*
*
* AMX Mod X Module
* Basic Socket Functions
*
* Codebase from Ivan, -g-s-ivan@web.de (AMX 0.9.3)
* Modification by Olaf Reusch, kenterfie@hlsw.de (AMXX 0.16, AMX 0.96)
*
*/
#if defined _socket_included
#endinput
#endif
#define _socket_included
#if AMXX_VERSION_NUM >= 175
#pragma reqlib sockets
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib sockets
#endif
#else
#pragma library socket
#endif
// Use SOCKET_TCP for TCP Socket connections
#define SOCKET_TCP 1
// Use SOCKET_UDP for UDP Socket connections
#define SOCKET_UDP 2
/* Opens a new connection to hostname:port via protocol (either SOCKET_TCP or SOCKET_UDP),
* returns a socket (positive) or negative or zero on error.
* States of error:
* 0 - no error
* 1 - error while creating socket
* 2 - couldn't resolve hostname
* 3 - couldn't connect to given hostname:port
*/
native socket_open(const _hostname[], _port, _protocol = SOCKET_TCP, &_error);
/* Closes a Socket */
native socket_close(_socket);
/* Recieves Data to string with the given length */
native socket_recv(_socket, _data[], _length);
/* Sends data to the Socket */
native socket_send(_socket, const _data[], _length);
/* Same as socket_send but Data can contain null bytes */
native socket_send2(_socket, const _data[], _length);
/* This function will return true if the state (buffer content) have changed within the last recieve or
* the timeout, where timeout is a value in µSeconds, (1 sec =1000000 µsec).
* Use to check if new data is in your socket. */
native socket_change(_socket, _timeout=100000);

View File

@@ -0,0 +1,76 @@
/* Sorting functions.
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*
* All sort functions are based off the qsort() function from the
* C standard library, which uses the Quick Sort algorithm.
* For more info, see: http://linux.wku.edu/~lamonml/algor/sort/sort.html
*/
#if defined _sorting_included
#endinput
#endif
#define _sorting_included
enum SortMethod
{
Sort_Ascending = 0,
Sort_Descending = 1,
};
/**
* Basic sorting functions below.
*/
native SortIntegers(array[], array_size, SortMethod:order = Sort_Ascending);
native SortFloats(Float:array[], array_size, SortMethod:order = Sort_Ascending);
native SortStrings(array[][], num_strings, SortMethod:order = Sort_Ascending);
/**
* Custom sorting functions below.
*/
/**
* Sorts a custom 1D array. You must pass in a comparison function.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(elem1, elem2, const array[], const data[], data_size)
*
* elem1, elem2 - Current element pair being compared
* array[] - Array in its current mid-sorted state.
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if elem1 should go before elem2
* 0 if elem1 and elem2 are equal
* 1 if elem1 should go after elem2
* Note that the parameters after elem2 are all optional and you do not need to specify them.
*/
native SortCustom1D(array[], array_size, const comparefunc[], data[]="", data_size=0);
/**
* Sorts a custom 2D array.
* The sorting algorithm then uses your comparison function to sort the data.
* The function is called in the following manner:
*
* public MySortFunc(const elem1[], const elem2[], const array[], data[], data_size)
*
* elem1[], elem2[] - Current element array pairs being compared
* array[][] - Array in its currently being sorted state.
* data[] - Extra data array you passed to the sort func.
* data_size - Size of extra data you passed to the sort func.
*
* Your function should return:
* -1 if elem1[] should go before elem2[]
* 0 if elem1[] and elem2 are equal[]
* 1 if elem1[] should go after elem2[]
* Note that the parameters after elem2[] are all optional and you do not need to specify them.
*/
native SortCustom2D(array[][], array_size, const comparefunc[], data[]="", data_size=0);

View File

@@ -0,0 +1,383 @@
/**
* SQLX - Newer version of SQL stuff
*/
#if defined _sqlx_included
#endinput
#endif
#define _sqlx_included
//eh..
#define SQL_NumRows SQL_NumResults
#if AMXX_VERSION_NUM >= 175
#pragma reqclass sqlx
#if !defined AMXMODX_NOAUTOLOAD
#pragma defclasslib sqlx mysql
#endif //!defined AMXMODX_NOAUTOLOAD
#endif //AMXX_VERSION_NUM
enum Handle
{
Empty_Handle
};
/**
* Creates a connection information tuple.
* This tuple must be passed into connection routines.
* Freeing the tuple is not necessary, but is a good idea if you
* create many of them. You can cache these handles globally.
* !!NOTE!! I have seen most people think that this connects to the DB.
* Nowhere does it say this, and in fact it does not. It only caches
* the connection information, the host/user/pass/etc.
*
* The optional timeout parameter specifies how long connections should wait before
* giving up. If 0, the default (which is undefined) is used.
*
*/
native Handle:SQL_MakeDbTuple(const host[], const user[], const pass[], const db[], timeout=0);
/**
* Frees an SQL handle.
* The handle can be to anything (tuple, connection, query, results, etc).
* If you free a database connection, it closes the connection as well.
*/
native SQL_FreeHandle(Handle:h);
/**
* Opens a database connection.
* Returns an SQL handle, which must be freed.
* Returns Empty_Handle on failure.
*/
native Handle:SQL_Connect(Handle:cn_tuple, &errcode, error[], maxlength);
/**
* Prepares a query.
* The query must always be freed.
* This does not actually do the query!
*/
native Handle:SQL_PrepareQuery(Handle:db, const fmt[], any:...);
/**
* Back-quotes characters in a string for database querying.
* Note: The buffer's maximum size should be 2*strlen(string) to catch
* all scenarios.
*
* @param db Database handle for localization, or Empty_Handle
* for when a handle is not available.
* @param buffer Buffer to copy to.
* @param buflen Maximum size of the buffer.
* @param string String to backquote (should not overlap buffer).
* @return Length of new string, or -1 on failure.
*/
native SQL_QuoteString(Handle:db, buffer[], buflen, const string[]);
/**
* Back-quotes characters in a string for database querying.
* Note: The buffer's maximum size should be 2*strlen(string) to catch
* all scenarios.
*
* @param db Database handle for localization, or Empty_Handle
* for when a handle is not available.
* @param buffer Buffer to copy to.
* @param buflen Maximum size of the buffer.
* @param fmt Format of string to backquote (should not overlap buffer).
* @param ... Format arguments.
* @return Length of new string, or -1 on failure.
*/
native SQL_QuoteStringFmt(Handle:db, buffer[], buflen, const fmt[], any:...);
#define TQUERY_CONNECT_FAILED -2
#define TQUERY_QUERY_FAILED -1
#define TQUERY_SUCCESS 0
/**
* Prepares and executes a threaded query.
* This will not interrupt gameplay in the event of a poor/lossed
* connection, however, the interface is more complicated and
* asynchronous. Furthermore, a new connection/disconnection is
* made for each query to simplify driver support.
* The handler should look like:
*
* @param failstate - One of the three TQUERY_ defines.
* @param query - Handle to the query, do not free it.
* @param error - An error message, if any.
* @param errnum - An error code, if any.
* @param data - Data array you passed in.
* @param size - Size of the data array you passed in.
* @param queuetime - Amount of gametime that passed while the query was resolving.
*
* public QueryHandler(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime)
*
* Note! The handle you pass in is a DB Tuple, NOT an active connection!
* Note! The handle does not need to be freed.
* Also note: This function is not guaranteed to be in another thread
* (in fact - it's not). You're seeing data "after the fact",
* and as such to execute another query you should run
* SQL_ThreadQuery again with new data.
*/
native SQL_ThreadQuery(Handle:db_tuple, const handler[], const query[], const data[]="", dataSize=0);
/**
* Executes a query.
* Returns 1 if the query succeeded.
* Returns 0 if the query failed.
* NOTE: You can call this multiple times as long as its parent
* connection is kept open. Each time the result set will be freed
* from the previous call.
*/
native SQL_Execute(Handle:query);
/**
* Gets information about a failed query error.
* Returns the errorcode.
*/
native SQL_QueryError(Handle:query, error[], maxlength);
/**
* Returns 1 if there are more results to be read,
* 0 otherwise.
*/
native SQL_MoreResults(Handle:query);
/**
* Tells whether a specific column in the current row
* is NULL or not.
*/
native SQL_IsNull(Handle:query, column);
/**
* Retrieves the current result.
* A successful query starts at the first result,
* so you should not call SQL_NextRow() first.
* Passing no extra params - return int
* Passing one extra param - return float in 1st extra arg
* Passing two extra params - return string in 1st arg, max length in 2nd
* Example:
* new num = SQL_ReadResult(query, 0)
* new Float:num2
* new str[32]
* SQL_ReadResult(query, 1, num2)
* SQL_ReadResult(query, 2, str, 31)
*/
native SQL_ReadResult(Handle:query, column, {Float,_}:...);
/**
* Advances to the next result (return value should be ignored).
*/
native SQL_NextRow(Handle:query);
/**
* Returns the number of affected rows.
*/
native SQL_AffectedRows(Handle:query);
/**
* Returns the number of rows total.
*/
native SQL_NumResults(Handle:query);
/**
* Returns the number of columns total.
*/
native SQL_NumColumns(Handle:query);
/**
* Returns the name of a column.
* Errors on a bad field number.
*/
native SQL_FieldNumToName(Handle:query, num, name[], maxlength);
/**
* Returns the number of a named column, or -1 if not found.
*/
native SQL_FieldNameToNum(Handle:query, const name[]);
/**
* Rewinds a result set to the first row.
*/
native SQL_Rewind(Handle:query);
/**
* Returns the insert id of the last INSERT query.
* Returns 0 otherwise.
*/
native SQL_GetInsertId(Handle:query);
/**
* Returns which driver this plugin is currently bound to.
*/
native SQL_GetAffinity(driver[], maxlen);
/**
* Sets driver affinity. You can use this to force a particular
* driver implementation. This will automatically change all SQL
* natives in your plugin to be "bound" to the module in question.
* If no such module is found, it will return 0. This isn't necessarily bad -
* the user might have typed the wrong driver. Unless your plugin is built
* to handle different driver types at once, you should let this error pass.
* Note, that using this while you have open handles to another database
* type will cause problems. I.e., you cannot open a handle, switch
* affinity, then close the handle with a different driver.
* Switching affinity is an O(n*m) operation, where n is the number of
* SQL natives and m is the number of used natives in total.
* Intuitive programmers will note that this causes problems for threaded queries.
* You will have to either force your script to work under one affinity, or to
* pack the affinity type into the query data, check it against the current, then
* set the new affinity if necessary. Then, restore the old for safety.
*/
native SQL_SetAffinity(const driver[]);
/**
* Returns the original query string that a query handle used.
*/
native SQL_GetQueryString(Handle:query, buffer[], maxlength);
/**
* For queries which return multiple result sets, this advances to the next
* result set if one is available. Otherwise, the current result set is
* destroyed and will no longer be accessible.
*
* This function will always return false on SQLite, and when using threaded
* queries in MySQL. Nonetheless, it has the same effect of removing the last
* result set.
*
* @param query Query Handle.
* @return True on success, false on failure.
*/
native bool:SQL_NextResultSet(Handle:query);
/**
* This function can be used to find out if a table in a Sqlite database exists.
* (updated for newer API)
*/
stock bool:sqlite_TableExists(Handle:db, const table[])
{
new Handle:query = SQL_PrepareQuery(
db,
"SELECT name FROM sqlite_master WHERE type='table' AND name='%s' LIMIT 1;",
table);
if (!SQL_Execute(query) || !SQL_NumResults(query))
{
SQL_FreeHandle(query);
return false;
}
SQL_FreeHandle(query);
return true;
}
/**
* Use this for executing a query where you don't care about the result.
* Returns 0 on failure, 1 on success
*/
stock SQL_SimpleQuery(Handle:db, const query[], error[]="", maxlength=0, &rows=0)
{
new Handle:hQuery = SQL_PrepareQuery(db, "%s", query);
if (!SQL_Execute(hQuery))
{
SQL_QueryError(hQuery, error, maxlength);
SQL_FreeHandle(hQuery);
return 0;
}
rows = SQL_NumResults(hQuery);
SQL_FreeHandle(hQuery);
return 1;
}
/**
* Use this for executing a query where you don't care about the result.
* Returns 0 on failure, 1 on success
*/
stock SQL_SimpleQueryFmt(Handle:db, error[]="", maxlength=0, &rows=0, const fmt[], any:...)
{
static query_buf[2048];
vformat(query_buf, 2047, fmt, 6);
new Handle:hQuery = SQL_PrepareQuery(db, "%s", query_buf);
if (!SQL_Execute(hQuery))
{
SQL_QueryError(hQuery, error, maxlength);
SQL_FreeHandle(hQuery);
return 0;
}
rows = SQL_NumResults(hQuery);
SQL_FreeHandle(hQuery);
return 1;
}
/**
* Use this for executing a query and not caring about the error.
* Returns -1 on error, >=0 on success (with number of affected rows)
*/
stock SQL_QueryAndIgnore(Handle:db, const queryfmt[], any:...)
{
static query[4096];
new Handle:hQuery;
new ret;
vformat(query, sizeof(query)-1, queryfmt, 3);
hQuery = SQL_PrepareQuery(db, "%s", query);
if (SQL_Execute(hQuery))
{
ret = SQL_AffectedRows(hQuery);
} else {
ret = -1;
}
SQL_FreeHandle(hQuery);
return ret;
}
stock Handle:SQL_MakeStdTuple(timeout = 0)
{
static host[64], user[32], pass[32], db[128];
static get_type[12], set_type[12];
get_cvar_string("amx_sql_host", host, 63);
get_cvar_string("amx_sql_user", user, 31);
get_cvar_string("amx_sql_pass", pass, 31);
get_cvar_string("amx_sql_type", set_type, 11);
get_cvar_string("amx_sql_db", db, 127);
SQL_GetAffinity(get_type, 12);
if (!equali(get_type, set_type))
{
if (!SQL_SetAffinity(set_type))
{
log_amx("Failed to set affinity from %s to %s.", get_type, set_type);
}
}
return SQL_MakeDbTuple(host, user, pass, db, timeout);
}

View File

@@ -0,0 +1,269 @@
/* Strings manipulation
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _string_included
#endinput
#endif
#define _string_included
#define charsmax(%1) (sizeof(%1)-1)
/* Checks if source contains string. On success function
* returns position in source, on failure returns -1. */
native contain(const source[],const string[]);
/* Checks if source contains string with case ignoring. On success function
* returns position in source, on failure returns -1. */
native containi(const source[],const string[]);
/* Replaces given string to another in given text. */
native replace(text[], len, const what[], const with[]);
/* Adds one string to another. Last parameter different from 0, specifies
* how many chars we want to add. Function returns number of all merged chars. */
native add(dest[],len,const src[],max=0);
/* Fills string with given format and parameters.
* Function returns number of copied chars.
* Example: format(dest,"Hello %s. You are %d years old","Tom",17).
* If any of your input buffers overlap with the destination buffer,
* format() falls back to a "copy-back" version as of 1.65. This is
* slower, so you should using a source string that is the same as
* the destination.
*/
native format(output[] ,len ,const format[] , any:...);
/* Same as format(), except does not perform a "copy back" check.
* This means formatex() is faster, but DOES NOT ALLOW this type
* of call:
* formatex(buffer, len, "%s", buffer)
* formatex(buffer, len, buffer, buffer)
* formatex(buffer, len, "%s", buffer[5])
* This is because the output is directly stored into "buffer",
* rather than copied back at the end.
*/
native formatex(output[] ,len ,const format[] , any:...);
/* Replacement for format_args. Much faster and %L compatible.
* This works exactly like vsnprintf() from C.
* You must pass in the output buffer and its size,
* the string to format, and the number of the FIRST variable
* argument parameter. For example, for:
* function (a, b, c, ...)
* You would pass 4 (a is 1, b is 2, c is 3, et cetera).
* There is no vformatex().
*/
native vformat(buffer[], len, const fmt[], vararg);
/*
* Same as vformat(), except works in normal style dynamic natives.
* Instead of passing the format arg string, you can only pass the
* actual format argument number itself.
* If you pass 0, it will read the format string from an optional
* fifth parameter.
*/
native vdformat(buffer[], len, fmt_arg, vararg, ...);
/* Gets parameters from function as formated string. */
native format_args(output[] ,len ,pos = 0);
/* Converts number to string. */
native num_to_str(num,string[],len);
/* Returns converted string to number. */
native str_to_num(const string[]);
/* Converts float to string. */
native float_to_str(Float:fl, string[], len);
/* Parses a float. */
native Float:str_to_float(const string[]);
/* Checks if two strings equal. If len var is set
* then there are only c chars comapred. */
native equal(const a[],const b[],c=0);
/* Checks if two strings equal with case ignoring.
* If len var is set then there are only c chars comapred. */
native equali(const a[],const b[],c=0);
/* Copies one string to another. By len var
* you may specify max. number of chars to copy. */
native copy(dest[],len,const src[]);
/* Copies one string to another until char ch is found.
* By len var you may specify max. number of chars to copy. */
native copyc(dest[],len,const src[],ch);
/* Sets string with given character. */
native setc(src[],len,ch);
/* Gets parameters from text.
* Example: to split text: "^"This is^" the best year",
* call function like this: parse(text,arg1,len1,arg2,len2,arg3,len3,arg4,len4)
* and you will get: "This is", "the", "best", "year"
* Function returns number of parsed parameters. */
native parse(const text[], ... );
/* Breaks a string into two halves, by token.
See strbreak() for doing this with parameters.
Example:
str1[] = This *is*some text
strtok(str1, left, 24, right, 24, '*')
left will be "This "
Right will be "is*some text"
If you use trimSpaces, all spaces are trimmed from Left.
*/
native strtok(const text[], Left[], leftLen, Right[], rightLen, token=' ', trimSpaces=0);
/* Gets parameters from text one at a time
It breaks a string into the first parameter and the rest of the parameters
(A left side and right side of the string)
Example: to split text: "^"This is^" the best year",
strbreak(text, arg1, len1, arg2, len2)
arg1="This is", arg2=the best year
This is more useful than parse() because you can keep breaking
any number of arguments */
native strbreak(const text[], Left[], leftLen, Right[], rightLen);
/* Strips spaces from the beginning and end of a string. */
native trim(text[]);
/* Converts all chars in string to lower case. */
native strtolower(string[]);
/* Converts all chars in string to upper case. */
native strtoupper(string[]);
/* Make a string's first character uppercase */
native ucfirst(string[]);
/* Returns true when value is digit. */
native isdigit(ch);
/* Returns true when value is letter. */
native isalpha(ch);
/* Returns true when value is space. */
native isspace(ch);
/* Returns true when value is letter or digit. */
native isalnum(ch);
/* Concatenates a string. Maxlength is the total buffer of the destination. */
native strcat(dest[], const source[], maxlength);
/* Finds a string in another string. Returns -1 if not found. */
native strfind(const string[], const sub[], ignorecase=0, pos=0);
/* Compares two strings with the C function strcmp(). Returns 0 on equal. */
native strcmp(const string1[], const string2[], ignorecase=0);
/* Tests if given string contains only digits. Also, returns false for zero-length strings. */
stock bool:is_str_num(const sString[])
{
new i = 0;
while (sString[i] && isdigit(sString[i]))
++i;
return sString[i] == 0 && i != 0;
}
/* It is basically strbreak but you have a delimiter that is more than one character in length.
You pass the Input string, the Left output, the max length of the left output,
the right output , the max right length, and then the delimiter string.
By Suicid3
*/
stock split(const szInput[], szLeft[], pL_Max, szRight[], pR_Max, const szDelim[])
{
new iEnd = contain(szInput, szDelim);
new iStart = iEnd + strlen(szDelim);
//If delimiter isnt in Input just split the string at max lengths
if (iEnd == -1)
{
iStart = copy(szLeft, pL_Max, szInput);
copy(szRight, pR_Max, szInput[iStart]);
return;
}
//If delimter is in Input then split at input for max lengths
if (pL_Max >= iEnd)
copy(szLeft, iEnd, szInput);
else
copy(szLeft, pL_Max, szInput);
copy(szRight, pR_Max, szInput[iStart]);
return;
}
/* Removes a path from szFilePath leaving the name of the file in szFile for a pMax length. */
stock remove_filepath(const szFilePath[], szFile[], pMax)
{
new len = strlen(szFilePath);
while ((--len >= 0) && (szFilePath[len] != '/') && (szFilePath[len] != '\')) { }
copy(szFile, pMax, szFilePath[len + 1]);
return;
}
/* Replaces a contained string iteratively.
* This ensures that no infinite replacements will take place by
* intelligently moving to the next string position each iteration.
*/
stock replace_all(string[], len, const what[], const with[])
{
new pos = 0;
if ((pos = contain(string, what)) == -1)
{
return 0;
}
new total = 0;
new with_len = strlen(with);
new diff = strlen(what) - with_len;
new total_len = strlen(string);
new temp_pos = 0;
while (replace(string[pos], len - pos, what, with) != 0)
{
total++;
/* jump to position after replacement */
pos += with_len;
/* update cached length of string */
total_len -= diff;
/* will the next call be operating on the last character? */
if (pos >= total_len)
{
break;
}
/* find the next position from our offset */
temp_pos = contain(string[pos], what);
/* if it's invalid, we're done */
if (temp_pos == -1)
{
break;
}
/* otherwise, reposition and update counters */
pos += temp_pos;
}
return total;
}

View File

@@ -0,0 +1,16 @@
/* AMX Mod X constants
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _svnversion_included
#endinput
#endif
#define _svnversion_included
#define AMXX_VERSION 1.82
#define AMXX_VERSION_NUM 182
stock const AMXX_VERSION_STR[] = "1.8.2";

View File

@@ -0,0 +1,16 @@
/* AMX Mod X constants
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _svnversion_included
#endinput
#endif
#define _svnversion_included
#define AMXX_VERSION $PMAJOR$.$PMINOR$$PREVISION$
#define AMXX_VERSION_NUM $PMAJOR$$PMINOR$$PREVISION$
stock const AMXX_VERSION_STR[] = "$PMAJOR$.$PMINOR$.$PREVISION$";

View File

@@ -0,0 +1,78 @@
/* TFCX const
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _tfcconst_included
#endinput
#endif
#define _tfcconst_included
#define TFCMAX_WEAPONS 37
enum {
TFC_AMMO_SHELLS = 0,
TFC_AMMO_BULLETS,
TFC_AMMO_CELLS,
TFC_AMMO_ROCKETS,
TFC_AMMO_NADE1,
TFC_AMMO_NADE2,
};
enum {
TFC_WPN_NONE = 0,
TFC_WPN_TIMER,//TFC_WPN_UNK1,
TFC_WPN_SENTRYGUN,//TFC_WPN_UNK2,
TFC_WPN_MEDIKIT,
TFC_WPN_SPANNER,
TFC_WPN_AXE,
TFC_WPN_SNIPERRIFLE,
TFC_WPN_AUTORIFLE,
TFC_WPN_SHOTGUN,
TFC_WPN_SUPERSHOTGUN,
TFC_WPN_NG,
TFC_WPN_SUPERNG,
TFC_WPN_GL,
TFC_WPN_FLAMETHROWER,
TFC_WPN_RPG,
TFC_WPN_IC,
TFC_WPN_FLAMES,//TFC_WPN_UNK16,
TFC_WPN_AC,
TFC_WPN_UNK18,
TFC_WPN_UNK19,
TFC_WPN_TRANQ,
TFC_WPN_RAILGUN,
TFC_WPN_PL,
TFC_WPN_KNIFE,
TFC_WPN_CALTROP, // 24
TFC_WPN_CONCUSSIONGRENADE,
TFC_WPN_NORMALGRENADE,
TFC_WPN_NAILGRENADE,
TFC_WPN_MIRVGRENADE,
TFC_WPN_NAPALMGRENADE,
TFC_WPN_GASGRENADE,
TFC_WPN_EMPGRENADE,
};
enum {
TFC_PC_SCOUT = 1,
TFC_PC_SNIPER,
TFC_PC_SOLDIER,
TFC_PC_DEMOMAN,
TFC_PC_MEDIC,
TFC_PC_HWGUY,
TFC_PC_PYRO,
TFC_PC_SPY,
TFC_PC_ENGENEER,
TFC_PC_CIVILIAN,
};
#define TFC_PC_ENGINEER TFC_PC_ENGENEER
// Goal items
#define TFC_GOALITEM_BLUE (1 << 17)
#define TFC_GOALITEM_RED (1 << 18)
#define TFC_GOALITEM_YELLOW (1 << 24)
#define TFC_GOALITEM_GREEN (1 << 25)

View File

@@ -0,0 +1,55 @@
/* TFCX Stats functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _tfcstats_included
#endinput
#endif
#define _tfcstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();

View File

@@ -0,0 +1,145 @@
/* tfcX functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _tfcx_included
#endinput
#endif
#define _tfcx_included
#include <tfcconst>
#include <tfcstats>
#if AMXX_VERSION_NUM >= 175
#pragma reqclass xstats
#if !defined AMXMODX_NOAUTOLOAD
#pragma defclasslib xstats tfcx
#endif
#else
#pragma library tfcx
#endif
/************* Shared Natives Start ********************************/
/* Forward types */
enum {
XMF_DAMAGE = 0,
XMF_DEATH,
};
/* Use this function to register forwards */
native register_statsfwd( ftype );
/* Function is called after player to player attacks ,
* if players were damaged by teammate TA is set to 1 */
forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA);
/* Function is called after player death ,
* if player was killed by teammate TK is set to 1 */
forward client_death(killer,victim,wpnindex,hitplace,TK);
/* Custom Weapon Support */
/* function will return index of new weapon */
native custom_weapon_add( const wpnname[],melee = 0,const logname[]="" );
/* Function will pass damage done by this custom weapon to stats module and other plugins */
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
/* Function will pass info about custom weapon shot to stats module */
native custom_weapon_shot( weapon,index ); // weapon id , player id
/* function will return 1 if true */
native xmod_is_melee_wpn(wpnindex);
/* Returns weapon name. */
native xmod_get_wpnname(wpnindex,name[],len);
/* Returns weapon logname. */
native xmod_get_wpnlogname(wpnindex,name[],len);
/* Returns weapons array size */
native xmod_get_maxweapons();
/* Returns stats array size ex. 8 in TS , 9 in DoD */
native xmod_get_stats_size();
/* Returns 1 if true */
native xmod_is_custom_wpn(wpnindex);
/************* Shared Natives End ********************************/
stock tfc_isgrenade( weapon ){
switch( weapon )
{
case TFC_WPN_CALTROP,
TFC_WPN_CONCUSSIONGRENADE,
TFC_WPN_NORMALGRENADE,
TFC_WPN_NAILGRENADE,
TFC_WPN_MIRVGRENADE,
TFC_WPN_NAPALMGRENADE,
TFC_WPN_GASGRENADE,
TFC_WPN_EMPGRENADE:
return 1;
default: return 0;
}
return 0;
}
native tfc_userkill( index );
/* Use this function to set private data offsets if needed
Default offsets:
timer: 932
sentrygun: 83
from AssKicR
shells: 53
bullets: 55
cells: 57
rockets: 59
nade1: 14
nade2: 15
*/
native tfc_setpddata(timer,sentrygun,shells,bullets,cells,rockets,nade1,nade2);
/*********************************************************************/
native tfc_setmodel(index, const Model[], const Skin[]);
native tfc_clearmodel(index);
/* Get amount of ammo in backpack on a user for a specific weapon */
/* Ammo Types in tfcconst.inc */
native tfc_getbammo(index, ammo);
/* Set amount of ammo in backpack on a user for a specific weapon */
native tfc_setbammo(index, ammo, value);
/* Returns amount of ammo in weapon's clip (backpack) */
/* Weapons list in tfcconst.inc */
native tfc_getweaponbammo(index, weapon);
/* Sets amount of ammo in weapon's clip (backpack) */
native tfc_setweaponbammo(index, weapon, value);
/* Returns amount of ammo in weapon's clip */
/* Index must be weapon's entity index */
native tfc_getweaponammo(index);
/* Sets amount of ammo in weapon's clip */
/* Index must be weapon's entity index */
native tfc_setweaponammo(index, value);
/* Returns 1 if user is carrying a goal item such as a flag or a keycard, else 0.
* Team is by reference parameter that will be set to owning team(s) of the goal item.
* Use the TFC_GOALITEM_* constants to determine the owning team.
*/
native tfc_get_user_goalitem(index, &team);
/* Returns 1 if the player is a spy and is currently feigning death */
native tfc_is_user_feigning(index);
/* Returns 1 if the two teams are allies, 0 otherwise
* Note: Team must be 1->4
* Team 0 will always return 0
* Any other team will result in an error
*/
native tfc_is_team_ally(TeamA,TeamB);

View File

@@ -0,0 +1,90 @@
/* Time specific functions
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _time_included
#endinput
#endif
#define _time_included
/* Time unit types for get_time_length() */
enum
{
timeunit_seconds = 0,
timeunit_minutes,
timeunit_hours,
timeunit_days,
timeunit_weeks,
};
// seconds are in each time unit
#define SECONDS_IN_MINUTE 60
#define SECONDS_IN_HOUR 3600
#define SECONDS_IN_DAY 86400
#define SECONDS_IN_WEEK 604800
/* Stock by Brad */
stock get_time_length(id, unitCnt, type, output[], outputLen)
{
// IMPORTANT: You must add register_dictionary("time.txt") in plugin_init()
// id: The player whose language the length should be translated to (or 0 for server language).
// unitCnt: The number of time units you want translated into verbose text.
// type: The type of unit (i.e. seconds, minutes, hours, days, weeks) that you are passing in.
// output: The variable you want the verbose text to be placed in.
// outputLen: The length of the output variable.
if (unitCnt > 0)
{
// determine the number of each time unit there are
new weekCnt = 0, dayCnt = 0, hourCnt = 0, minuteCnt = 0, secondCnt = 0;
switch (type)
{
case timeunit_seconds: secondCnt = unitCnt;
case timeunit_minutes: secondCnt = unitCnt * SECONDS_IN_MINUTE;
case timeunit_hours: secondCnt = unitCnt * SECONDS_IN_HOUR;
case timeunit_days: secondCnt = unitCnt * SECONDS_IN_DAY;
case timeunit_weeks: secondCnt = unitCnt * SECONDS_IN_WEEK;
}
weekCnt = secondCnt / SECONDS_IN_WEEK;
secondCnt -= (weekCnt * SECONDS_IN_WEEK);
dayCnt = secondCnt / SECONDS_IN_DAY;
secondCnt -= (dayCnt * SECONDS_IN_DAY);
hourCnt = secondCnt / SECONDS_IN_HOUR;
secondCnt -= (hourCnt * SECONDS_IN_HOUR);
minuteCnt = secondCnt / SECONDS_IN_MINUTE;
secondCnt -= (minuteCnt * SECONDS_IN_MINUTE);
// translate the unit counts into verbose text
new maxElementIdx = -1;
new timeElement[5][33];
if (weekCnt > 0)
format(timeElement[++maxElementIdx], 32, "%i %L", weekCnt, id, (weekCnt == 1) ? "TIME_ELEMENT_WEEK" : "TIME_ELEMENT_WEEKS");
if (dayCnt > 0)
format(timeElement[++maxElementIdx], 32, "%i %L", dayCnt, id, (dayCnt == 1) ? "TIME_ELEMENT_DAY" : "TIME_ELEMENT_DAYS");
if (hourCnt > 0)
format(timeElement[++maxElementIdx], 32, "%i %L", hourCnt, id, (hourCnt == 1) ? "TIME_ELEMENT_HOUR" : "TIME_ELEMENT_HOURS");
if (minuteCnt > 0)
format(timeElement[++maxElementIdx], 32, "%i %L", minuteCnt, id, (minuteCnt == 1) ? "TIME_ELEMENT_MINUTE" : "TIME_ELEMENT_MINUTES");
if (secondCnt > 0)
format(timeElement[++maxElementIdx], 32, "%i %L", secondCnt, id, (secondCnt == 1) ? "TIME_ELEMENT_SECOND" : "TIME_ELEMENT_SECONDS");
switch(maxElementIdx)
{
case 0: format(output, outputLen, "%s", timeElement[0]);
case 1: format(output, outputLen, "%s %L %s", timeElement[0], id, "TIME_ELEMENT_AND", timeElement[1]);
case 2: format(output, outputLen, "%s, %s %L %s", timeElement[0], timeElement[1], id, "TIME_ELEMENT_AND", timeElement[2]);
case 3: format(output, outputLen, "%s, %s, %s %L %s", timeElement[0], timeElement[1], timeElement[2], id, "TIME_ELEMENT_AND", timeElement[3]);
case 4: format(output, outputLen, "%s, %s, %s, %s %L %s", timeElement[0], timeElement[1], timeElement[2], timeElement[3], id, "TIME_ELEMENT_AND", timeElement[4]);
}
}
}

View File

@@ -0,0 +1,146 @@
/* TSFUN constants
*
* (c) 2005, Suzuka
* This file is provided as is (no warranties).
*/
#if defined _tsconst_included
#endinput
#endif
#define _tsconst_included
#define TSMAX_WEAPONS 44 // 37 + throwing knife + brekable + 5 custom weapon slots
#define TSPWUP_NONE 0
#define TSPWUP_RANDOM 0
#define TSPWUP_SLOWMO 1
#define TSPWUP_INFAMMO 2
#define TSPWUP_KUNGFU 4
#define TSPWUP_SLOWPAUSE 8
#define TSPWUP_DFIRERATE 16
#define TSPWUP_GRENADE 32
#define TSPWUP_HEALTH 64
#define TSPWUP_ARMOR 128
#define TSPWUP_SUPERJUMP 256
#define TSITEM_KUNGFU 1<<0
#define TSITEM_SUPERJUMP 1<<1
#define TSKF_STUNTKILL 1<<0
#define TSKF_SLIDINGKILL 1<<1
#define TSKF_DOUBLEKILL 1<<2
#define TSKF_ISSPEC 1<<3
#define TSKF_KILLEDSPEC 1<<4
#define TSA_SILENCER 1
#define TSA_LASERSIGHT 2
#define TSA_FLASHLIGHT 4
#define TSA_SCOPE 8
#define TSMSG_NORMAL 6
#define TSMSG_WAITING 11
#define TSMSG_DEAD 1
#define TSMSG_KILLER 2
#define TSMSG_DEMOLITION 3
#define TSMSG_SPECIALIST 4
#define TSMSG_UNSTOPPABLE 5
#define TSMSG_THEONE 10
#define STUNT_NONE 0
#define STUNT_DUCK 1
#define STUNT_ROLL 2
#define STUNT_DIVE 3
#define STUNT_GETUP 4
#define STUNT_FLIP 5
enum {
TSW_GLOCK18 = 1,
TSW_UNK1,
TSW_UZI,
TSW_M3,
TSW_M4A1,
TSW_MP5SD,
TSW_MP5K,
TSW_ABERETTAS,
TSW_MK23,
TSW_AMK23,
TSW_USAS,
TSW_DEAGLE,
TSW_AK47,
TSW_57,
TSW_AUG,
TSW_AUZI,
TSW_TMP,
TSW_M82A1,
TSW_MP7,
TSW_SPAS,
TSW_GCOLTS,
TSW_GLOCK20,
TSW_UMP,
TSW_M61GRENADE,
TSW_CKNIFE,
TSW_MOSSBERG,
TSW_M16A4,
TSW_MK1,
TSW_C4,
TSW_A57,
TSW_RBULL,
TSW_M60E3,
TSW_SAWED_OFF,
TSW_KATANA,
TSW_SKNIFE,
TSW_KUNG_FU,
TSW_TKNIFE,
};
/*
valid tsweaponid in TS_GiveWeapon
1: "Glock 18"
3: "Mini Uzi"
4: "Benelli M3"
5: "M4A1"
6: "MP5SD"
7: "MP5K"
8: "Akimbo Berettas"
9: "Socom Mk23"
11: "Usas12"
12: "Desert Eagle"
13: "Ak47"
14: "FiveSeven"
15: "Steyr Aug"
17: "Steyr Tmp"
18: "Barrett M82"
19: "HK Pdw"
20: "Spas12"
21: "Akimbo colts"
22: "Glock 20"
23: "Mac10"
25: "Combat Knife"
26: "Mossberg 500"
27: "M16A4"
28: "Ruger Mk1"
24: "M61 Grenade"
29: "C4"
31: "Raging Bull"
32: "M60"
33: "Sawed off"
34: "Katana"
35: "Seal Knife"
valid pwuptype in TS_GivePwUp
0: "Random"
1: "Slow Motion"
2: "Infinite Clip"
4: "Kung Fu"
8: "Slow Pause"
16: "Double Firerate"
32: "Grenade"
64: "Health"
128: "Armor"
256: "Superjump"
*/

View File

@@ -0,0 +1,154 @@
/* TSFUN
*
* (c) 2005-2006, AMX Mod X Dev Team
* This file is provided as is (no warranties).
*/
#if defined _tsxfun_included
#endinput
#endif
#define _tsxfun_included
#include <tsx>
#include <tsconst>
/************* Shared Natives Start ********************************/
/* Forward types */
enum {
XMF_DAMAGE = 0,
XMF_DEATH,
};
#if AMXX_VERSION_NUM >= 175
#pragma reqlib tsfun
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib tsfun
#endif
#else
#pragma library tsfun
#endif
/************* Shared Natives End ********************************/
/* Function is called just before a kung foo attack is done,
* damage and time length may be altered with natives.
* Return PLUGIN_HANDLED to stop attack.
* UNAVAILABLE IN 1.70
*/
forward Melee_Attack(id,Float:time,Float:damage,UNAVAILABLE);
// Returns when someone stunts, after they do it.
//UNAVAILABLE IN 1.70
forward client_stunt(id,stunttype,UNAVAILABLE);
/* Function is called when powerups are ran,
* Returns value of powerup. Use TSPWUP_*'s
* to find exactly which one it is.
* UNAVAILABLE IN 1.70
*/
forward client_powerup(id,powerup,UNAVAILABLE);
/* weapon logname to weapon name convertion */
native ts_wpnlogtoname(const logname[],name[],len);
/* weapon logname to weapon index convertion */
native ts_wpnlogtoid(const logname[]);
//UNAVAILABLE IN 1.70
//native Float:ts_getusertime( index ); //!
//native ts_setusertime( index, Float:time ); //!
native ts_getusercash( index );
native ts_setusercash( index, money );
native ts_getuserslots( index );
native ts_setuserslots( index, slots );
native ts_getuserstate( index );
native ts_getuserwpn( index,&clip=0,&ammo=0,&mode=0,&extra=0 );
native ts_getuserspace( index );
native ts_getuserkillflags(killer);
native ts_getkillingstreak( index );
native ts_getuserlastfrag( index );
native ts_giveweapon( index,weapon,clips,extra );
native ts_getuserpwup( index );
stock ts_has_slowmo(id) return (ts_getuserpwup(id) &TSPWUP_SLOWMO);
stock ts_has_infammo(id) return (ts_getuserpwup(id) &TSPWUP_INFAMMO);
stock ts_has_slowpause(id) return (ts_getuserpwup(id) &TSPWUP_SLOWPAUSE);
stock ts_has_dfirerate(id) return (ts_getuserpwup(id) &TSPWUP_DFIRERATE);
stock ts_has_grenade(id) return (ts_getuserpwup(id) &TSPWUP_GRENADE);
stock ts_has_health(id) return (ts_getuserpwup(id) &TSPWUP_HEALTH);
stock ts_has_armor(id) return (ts_getuserpwup(id) &TSPWUP_ARMOR);
/* Function will create pwup entity and return its index (pwupent) */
native ts_createpwup( pwup );
native ts_givepwup( index,pwupent );
native ts_setpddata( knifeoffset );
// Alters a fu attack. Use with fu forward
// UNAVAILABLE IN 1.70
// native ts_set_fuattack(id,Float:time,Float:damage); //!
// Changes board message
native ts_set_message(id,message);
// Gets the message board message
native ts_get_message(id);
stock ts_is_normal(id)
{
new msg = ts_get_message(id);
if( (msg > 11) || (msg > 6 && msg < 10) ) return 1;
return 0;
}
stock ts_is_waiting(id) return (ts_get_message(id) == TSMSG_WAITING);
stock ts_is_dead(id) return (ts_get_message(id) == TSMSG_DEAD);
stock ts_is_killer(id) return (ts_get_message(id) == TSMSG_KILLER);
stock ts_is_demolition(id) return (ts_get_message(id) == TSMSG_DEMOLITION);
stock ts_is_specialist(id) return (ts_get_message(id) == TSMSG_SPECIALIST);
stock ts_is_unstoppable(id) return (ts_get_message(id) == TSMSG_UNSTOPPABLE);
stock ts_is_theone(id) return (ts_get_message(id) == TSMSG_THEONE);
// Return one on true, 0 on false
// UNAVAILABLE IN 1.70
native ts_has_superjump(id); //!
native ts_has_fupowerup(id); //!
native ts_is_in_slowmo(id);
// Get and set consecutive frags
//UNAVAILABLE IN 1.70
//native ts_get_cons_frags(id);
//native ts_set_cons_frags(id,num);
// Set to see cool bullet trails. Only id will see them.
native ts_set_bullettrail(id,yesorno);
// Sets fake versions of slow mo and slow pause. Use ts_set_speed for more options.
native ts_set_fakeslowmo(id,Float:time);
native ts_set_fakeslowpause(id,Float:time);
/* Sets speed artificially. 1.0 is default, Go into fractions and decimals for slower
* and put in higher numbers for higher speeds. Aura is how far things around you are effected
* Time is the time until it wears off. 0.0 for speed will freeze people. Do not use negatives. */
native ts_set_speed(id,Float:speed,Float:auradist,Float:time);
/* Sets physics speed artificially. Things like sparks and sounds will be effected.
* Any negative number will render all physics paused. */
native ts_set_physics_speed(id,Float:speed);
// Returns 0 if no powerup is running. Returns the powerup type otherwise.
native ts_is_running_powerup(id);
// Highly experimental command which overrides powerup types.
// Use if a powerup is already running, or if a powerup is not running.
// Safe to use in powerup forward.
native ts_force_run_powerup(id,PWUP_TYPE);

View File

@@ -0,0 +1,58 @@
/* TSXMod Stats functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _tsstats_included
#endinput
#endif
#define _tsstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets life (from spawn to spawn) stats from given weapon index.*/
native get_user_wlstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();

View File

@@ -0,0 +1,85 @@
/* TSXMod functions
*
* (c) 2004, SidLuke
* This file is provided as is (no warranties).
*/
#if defined _tsx_included
#endinput
#endif
#define _tsx_included
#include <tsstats>
#if AMXX_VERSION_NUM >= 175
#pragma reqclass xstats
#if !defined AMXMODX_NOAUTOLOAD
#pragma defclasslib xstats tsx
#endif
#else
#pragma library tsx
#endif
/************* Shared Natives Start ********************************/
/* Forward types */
enum {
XMF_DAMAGE = 0,
XMF_DEATH,
};
/* Use this function to register forwards
* DEPRECATED
*/
native register_statsfwd( ftype );
/* Function is called after player to player attacks ,
* if players were damaged by teammate TA is set to 1 */
forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA);
/* Function is called after player death ,
* if player was killed by teammate TK is set to 1 */
forward client_death(killer,victim,wpnindex,hitplace,TK);
/* Custom Weapon Support */
/* function will return index of new weapon */
native custom_weapon_add( const wpnname[],melee = 0,const logname[]="" );
/* Function will pass damage done by this custom weapon to stats module and other plugins */
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
/* Function will pass info about custom weapon shot to stats module */
native custom_weapon_shot( weapon,index ); // weapon id , player id
/* function will return 1 if true */
native xmod_is_melee_wpn(wpnindex);
/* Returns weapon name. */
native xmod_get_wpnname(wpnindex,name[],len);
/* Returns weapon logname. */
native xmod_get_wpnlogname(wpnindex,name[],len);
/* Returns weapons array size */
native xmod_get_maxweapons();
/* Returns stats array size ex. 8 in TS , 9 in DoD */
native xmod_get_stats_size();
/* Returns 1 if true */
native xmod_is_custom_wpn(wpnindex);
/************* Shared Natives End ********************************/
/* Spawns a Weapon */
stock ts_weaponspawn(const weaponid[], const duration[], const extraclip[], const spawnflags[], const Float:Origin[3])
{
new ent = create_entity("ts_groundweapon");
DispatchKeyValue(ent, "tsweaponid", weaponid);
DispatchKeyValue(ent, "wduration", duration);
DispatchKeyValue(ent, "wextraclip", extraclip);
DispatchKeyValue(ent, "spawnflags", spawnflags);
DispatchSpawn(ent);
entity_set_origin(ent, Origin);
return PLUGIN_HANDLED;
}

View File

@@ -0,0 +1,26 @@
/* Vault functions
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* This file is provided as is (no warranties).
*/
#if defined _vault_included
#endinput
#endif
#define _vault_included
/* Reads a data from given key.
* If len is set to zero then get_vaultdata
* returns value as an number. */
native get_vaultdata(const key[], data[] = "", len = 0);
/* Sets a data under given key. */
native set_vaultdata(const key[], const data[] = "");
/* Removes a key from vault.*/
native remove_vaultdata(const key[]);
/* Checks if a key exists in the vault.*/
native vaultdata_exists(const key[]);

View File

@@ -0,0 +1,59 @@
/* Vector functions (now part of Core)
*
* by the AMX Mod X Development Team
*
* This file is provided as is (no warranties).
*/
#if defined _corevector_included
#endinput
#endif
#define _corevector_included
/* Used for angle_vector() */
#define ANGLEVECTOR_FORWARD 1
#define ANGLEVECTOR_RIGHT 2
#define ANGLEVECTOR_UP 3
/* Returns distance between two vectors. */
native get_distance(const origin1[3], const origin2[3]);
/* Gets distance between two origins (float). */
native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]);
/* Gives you a velocity in the direction a player is looking, iVelocity is the multiplier. */
native velocity_by_aim(iIndex, iVelocity, Float:vRetValue[3]);
/* Changes a vector into an angle vector. */
native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
/* Changes an angle vector into a vector. */
native angle_vector(const Float:vector[3], FRU, Float:ret[3]);
/* Gets the length of a vector (float[3]). */
native Float:vector_length(const Float:vVector[3]);
/* Gets the distance between 2 vectors (float[3]). */
native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);
/* Changes an integer vec to a floating vec
* This is not a for loop because that's slower
*/
stock IVecFVec(const IVec[3], Float:FVec[3])
{
FVec[0] = float(IVec[0]);
FVec[1] = float(IVec[1]);
FVec[2] = float(IVec[2]);
return 1;
}
/* Changes a float vec to an integer vec */
stock FVecIVec(const Float:FVec[3], IVec[3])
{
IVec[0] = floatround(FVec[0]);
IVec[1] = floatround(FVec[1]);
IVec[2] = floatround(FVec[2]);
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,315 @@
/* AMX Mod X
* Nextmap Chooser Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
#define SELECTMAPS 5
#define charsof(%1) (sizeof(%1)-1)
new Array:g_mapName;
new g_mapNums;
new g_nextName[SELECTMAPS]
new g_voteCount[SELECTMAPS + 2]
new g_mapVoteNum
new g_teamScore[2]
new g_lastMap[32]
new g_coloredMenus
new bool:g_selected = false
public plugin_init()
{
register_plugin("Nextmap Chooser", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("mapchooser.txt")
register_dictionary("common.txt")
g_mapName=ArrayCreate(32);
new MenuName[64]
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
register_menucmd(register_menuid(MenuName), (-1^(-1<<(SELECTMAPS+2))), "countVote")
register_cvar("amx_extendmap_max", "90")
register_cvar("amx_extendmap_step", "15")
if (cstrike_running())
register_event("TeamScore", "team_score", "a")
get_localinfo("lastMap", g_lastMap, 31)
set_localinfo("lastMap", "")
new maps_ini_file[64]
get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file))
get_cvar_string("mapcyclefile", maps_ini_file, 63)
if (loadSettings(maps_ini_file))
set_task(15.0, "voteNextmap", 987456, "", 0, "b")
g_coloredMenus = colored_menus()
}
public checkVotes()
{
new b = 0
for (new a = 0; a < g_mapVoteNum; ++a)
if (g_voteCount[b] < g_voteCount[a])
b = a
if (g_voteCount[SELECTMAPS] > g_voteCount[b]
&& g_voteCount[SELECTMAPS] > g_voteCount[SELECTMAPS+1])
{
new mapname[32]
get_mapname(mapname, 31)
new Float:steptime = get_cvar_float("amx_extendmap_step")
set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime)
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_EXT", steptime)
log_amx("Vote: Voting for the nextmap finished. Map %s will be extended to next %.0f minutes", mapname, steptime)
return
}
new smap[32]
if (g_voteCount[b] && g_voteCount[SELECTMAPS + 1] <= g_voteCount[b])
{
ArrayGetString(g_mapName, g_nextName[b], smap, charsof(smap));
set_cvar_string("amx_nextmap", smap);
}
get_cvar_string("amx_nextmap", smap, 31)
client_print(0, print_chat, "%L", LANG_PLAYER, "CHO_FIN_NEXT", smap)
log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap)
}
public countVote(id, key)
{
if (get_cvar_float("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)
if (key == SELECTMAPS)
client_print(0, print_chat, "%L", LANG_PLAYER, "CHOSE_EXT", name)
else if (key < SELECTMAPS)
{
new map[32];
ArrayGetString(g_mapName, g_nextName[key], map, charsof(map));
client_print(0, print_chat, "%L", LANG_PLAYER, "X_CHOSE_X", name, map);
}
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
bool:isInMenu(id)
{
for (new a = 0; a < g_mapVoteNum; ++a)
if (id == g_nextName[a])
return true
return false
}
public voteNextmap()
{
new winlimit = get_cvar_num("mp_winlimit")
new maxrounds = get_cvar_num("mp_maxrounds")
if (winlimit)
{
new c = winlimit - 2
if ((c > g_teamScore[0]) && (c > g_teamScore[1]))
{
g_selected = false
return
}
}
else if (maxrounds)
{
if ((maxrounds - 2) > (g_teamScore[0] + g_teamScore[1]))
{
g_selected = false
return
}
} else {
new timeleft = get_timeleft()
if (timeleft < 1 || timeleft > 129)
{
g_selected = false
return
}
}
if (g_selected)
return
g_selected = true
new menu[512], a, mkeys = (1<<SELECTMAPS + 1)
new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
for (g_mapVoteNum = 0; g_mapVoteNum < dmax; ++g_mapVoteNum)
{
a = random_num(0, g_mapNums - 1)
while (isInMenu(a))
if (++a >= g_mapNums) a = 0
g_nextName[g_mapVoteNum] = a
pos += format(menu[pos], 511, "%d. %a^n", g_mapVoteNum + 1, ArrayGetStringHandle(g_mapName, a));
mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0
}
menu[pos++] = '^n'
g_voteCount[SELECTMAPS] = 0
g_voteCount[SELECTMAPS + 1] = 0
new mapname[32]
get_mapname(mapname, 31)
if ((winlimit + maxrounds) == 0 && (get_cvar_float("mp_timelimit") < get_cvar_float("amx_extendmap_max")))
{
pos += format(menu[pos], 511, "%d. %L^n", SELECTMAPS + 1, LANG_SERVER, "EXTED_MAP", mapname)
mkeys |= (1<<SELECTMAPS)
}
format(menu[pos], 511, "%d. %L", SELECTMAPS+2, LANG_SERVER, "NONE")
new MenuName[64]
format(MenuName, 63, "%L", "en", "CHOOSE_NEXTM")
show_menu(0, mkeys, menu, 15, MenuName)
set_task(15.0, "checkVotes")
client_print(0, print_chat, "%L", LANG_SERVER, "TIME_CHOOSE")
client_cmd(0, "spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started")
}
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new szText[32]
new currentMap[32]
new buff[256];
get_mapname(currentMap, 31)
new fp=fopen(filename,"r");
while (!feof(fp))
{
buff[0]='^0';
szText[0]='^0';
fgets(fp, buff, charsof(buff));
parse(buff, szText, charsof(szText));
if (szText[0] != ';' &&
ValidMap(szText) &&
!equali(szText, g_lastMap) &&
!equali(szText, currentMap))
{
ArrayPushString(g_mapName, szText);
++g_mapNums;
}
}
fclose(fp);
return g_mapNums
}
public team_score()
{
new team[2]
read_data(1, team, 1)
g_teamScore[(team[0]=='C') ? 0 : 1] = read_data(2)
}
public plugin_end()
{
new current_map[32]
get_mapname(current_map, 31)
set_localinfo("lastMap", current_map)
}

View File

@@ -0,0 +1,595 @@
/* AMX Mod X
* Maps Menu Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
new Array:g_mapName;
new g_mapNums
new g_menuPosition[33]
new g_voteCount[5]
new g_voteSelected[33][4]
new g_voteSelectedNum[33]
new g_coloredMenus
new g_choosed
public plugin_init()
{
register_plugin("Maps Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("mapsmenu.txt")
register_dictionary("common.txt")
register_clcmd("amx_mapmenu", "cmdMapsMenu", ADMIN_MAP, "- displays changelevel menu")
register_clcmd("amx_votemapmenu", "cmdVoteMapMenu", ADMIN_VOTE, "- displays votemap menu")
register_menucmd(register_menuid("Changelevel Menu"), 1023, "actionMapsMenu")
register_menucmd(register_menuid("Which map do you want?"), 527, "voteCount")
register_menucmd(register_menuid("Change map to"), 527, "voteCount")
register_menucmd(register_menuid("Votemap Menu"), 1023, "actionVoteMapMenu")
register_menucmd(register_menuid("The winner: "), 3, "actionResult")
g_mapName=ArrayCreate(32);
new maps_ini_file[64];
get_configsdir(maps_ini_file, 63);
format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file);
if (!file_exists(maps_ini_file))
get_cvar_string("mapcyclefile", maps_ini_file, sizeof(maps_ini_file) - 1);
if (!file_exists(maps_ini_file))
format(maps_ini_file, 63, "mapcycle.txt")
load_settings(maps_ini_file)
g_coloredMenus = colored_menus()
}
public autoRefuse()
{
log_amx("Vote: %L", "en", "RESULT_REF")
client_print(0, print_chat, "%L", LANG_PLAYER, "RESULT_REF")
}
public actionResult(id, key)
{
remove_task(4545454)
switch (key)
{
case 0:
{
new _modName[10]
get_modname(_modName, 9)
if (!equal(_modName, "zp"))
{
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
}
new tempMap[32];
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
log_amx("Vote: %L", "en", "RESULT_ACC")
client_print(0, print_chat, "%L", LANG_PLAYER, "RESULT_ACC")
}
case 1: autoRefuse()
}
return PLUGIN_HANDLED
}
public checkVotes(id)
{
id -= 34567
new num, ppl[32], a = 0
get_players(ppl, num, "c")
if (num == 0) num = 1
g_choosed = -1
for (new i = 0; i < g_voteSelectedNum[id]; ++i)
if (g_voteCount[a] < g_voteCount[i])
a = i
new votesNum = g_voteCount[0] + g_voteCount[1] + g_voteCount[2] + g_voteCount[3] + g_voteCount[4]
new iRatio = votesNum ? floatround(get_cvar_float("amx_votemap_ratio") * float(votesNum), floatround_ceil) : 1
new iResult = g_voteCount[a]
if (iResult >= iRatio)
{
g_choosed = g_voteSelected[id][a]
new tempMap[32];
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
client_print(0, print_chat, "%L %s", LANG_PLAYER, "VOTE_SUCCESS", tempMap);
log_amx("Vote: %L %s", "en", "VOTE_SUCCESS", tempMap);
}
if (g_choosed != -1)
{
if (is_user_connected(id))
{
new menuBody[512]
new tempMap[32];
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
new len = format(menuBody, 511, g_coloredMenus ? "\y%L: \w%s^n^n" : "%L: %s^n^n", id, "THE_WINNER", tempMap)
len += format(menuBody[len], 511 - len, g_coloredMenus ? "\y%L^n\w" : "%L^n", id, "WANT_CONT")
format(menuBody[len], 511-len, "^n1. %L^n2. %L", id, "YES", id, "NO")
show_menu(id, 0x03, menuBody, 10, "The winner: ")
set_task(10.0, "autoRefuse", 4545454)
} else {
new _modName[10]
get_modname(_modName, 9)
if (!equal(_modName, "zp"))
{
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
}
new tempMap[32];
ArrayGetString(g_mapName, g_choosed, tempMap, charsmax(tempMap));
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
}
} else {
client_print(0, print_chat, "%L", LANG_PLAYER, "VOTE_FAILED")
log_amx("Vote: %L", "en", "VOTE_FAILED")
}
remove_task(34567 + id)
}
public voteCount(id, key)
{
if (key > 3)
{
client_print(0, print_chat, "%L", LANG_PLAYER, "VOT_CANC")
remove_task(34567 + id)
set_cvar_float("amx_last_voting", get_gametime())
log_amx("Vote: Cancel vote session")
return PLUGIN_HANDLED
}
if (get_cvar_float("amx_vote_answers"))
{
new name[32]
get_user_name(id, name, 31)
client_print(0, print_chat, "%L", LANG_PLAYER, "X_VOTED_FOR", name, key + 1)
}
++g_voteCount[key]
return PLUGIN_HANDLED
}
isMapSelected(id, pos)
{
for (new a = 0; a < g_voteSelectedNum[id]; ++a)
if (g_voteSelected[id][a] == pos)
return 1
return 0
}
displayVoteMapsMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512], b = 0, start = pos * 7
if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "VOTEMAP_MENU", pos + 1, (g_mapNums / 7 + ((g_mapNums % 7) ? 1 : 0)))
new end = start + 7, keys = MENU_KEY_0
if (end > g_mapNums)
end = g_mapNums
new tempMap[32];
for (new a = start; a < end; ++a)
{
ArrayGetString(g_mapName, a, tempMap, charsmax(tempMap));
if (g_voteSelectedNum[id] == 4 || isMapSelected(id, pos * 7 + b))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, tempMap)
else
len += format(menuBody[len], 511-len, "#. %s^n", tempMap)
} else {
keys |= (1<<b)
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, tempMap)
}
}
if (g_voteSelectedNum[id])
{
keys |= MENU_KEY_8
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "START_VOT")
}
else
len += format(menuBody[len], 511-len, g_coloredMenus ? "^n\d8. %L^n\w" : "^n#. %L^n", id, "START_VOT")
if (end != g_mapNums)
{
len += format(menuBody[len], 511-len, "^n9. %L...^n0. %L^n", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
len += format(menuBody[len], 511-len, "^n0. %L^n", id, pos ? "BACK" : "EXIT")
if (g_voteSelectedNum[id])
len += format(menuBody[len], 511-len, g_coloredMenus ? "^n\y%L:^n\w" : "^n%L:^n", id, "SEL_MAPS")
else
len += format(menuBody[len], 511-len, "^n^n")
for (new c = 0; c < 4; c++)
{
if (c < g_voteSelectedNum[id])
{
ArrayGetString(g_mapName, g_voteSelected[id][c], tempMap, charsmax(tempMap));
len += format(menuBody[len], 511-len, "%s^n", tempMap)
}
else
len += format(menuBody[len], 511-len, "^n")
}
new menuName[64]
format(menuName, 63, "%L", "en", "VOTEMAP_MENU")
show_menu(id, keys, menuBody, -1, menuName)
}
public cmdVoteMapMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (get_cvar_float("amx_last_voting") > get_gametime())
{
client_print(id, print_chat, "%L", id, "ALREADY_VOT")
return PLUGIN_HANDLED
}
g_voteSelectedNum[id] = 0
if (g_mapNums)
{
displayVoteMapsMenu(id, g_menuPosition[id] = 0)
} else {
console_print(id, "%L", id, "NO_MAPS_MENU")
client_print(id, print_chat, "%L", id, "NO_MAPS_MENU")
}
return PLUGIN_HANDLED
}
public cmdMapsMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
if (g_mapNums)
{
displayMapsMenu(id, g_menuPosition[id] = 0)
} else {
console_print(id, "%L", id, "NO_MAPS_MENU")
client_print(id, print_chat, "%L", id, "NO_MAPS_MENU")
}
return PLUGIN_HANDLED
}
public delayedChange(mapname[])
server_cmd("changelevel %s", mapname)
public actionVoteMapMenu(id, key)
{
new tempMap[32];
switch (key)
{
case 7:
{
new Float:voting = get_cvar_float("amx_last_voting")
if (voting > get_gametime())
{
client_print(id, print_chat, "%L", id, "ALREADY_VOT")
return PLUGIN_HANDLED
}
if (voting && voting + get_cvar_float("amx_vote_delay") > get_gametime())
{
client_print(id, print_chat, "%L", id, "VOT_NOW_ALLOW")
return PLUGIN_HANDLED
}
g_voteCount = {0, 0, 0, 0, 0}
new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting", get_gametime() + vote_time)
new iVoteTime = floatround(vote_time)
set_task(vote_time, "checkVotes", 34567 + id)
new menuBody[512]
new players[32]
new pnum, keys, len
get_players(players, pnum)
if (g_voteSelectedNum[id] > 1)
{
len = format(menuBody, 511, g_coloredMenus ? "\y%L^n\w^n" : "%L^n^n", id, "WHICH_MAP")
for (new c = 0; c < g_voteSelectedNum[id]; ++c)
{
ArrayGetString(g_mapName, g_voteSelected[id][c], tempMap, charsmax(tempMap));
len += format(menuBody[len], 511, "%d. %s^n", c + 1, tempMap)
keys |= (1<<c)
}
keys |= (1<<8)
len += format(menuBody[len], 511, "^n9. %L^n", id, "NONE")
} else {
ArrayGetString(g_mapName, g_voteSelected[id][0], tempMap, charsmax(tempMap));
len = format(menuBody, 511, g_coloredMenus ? "\y%L^n%s?^n\w^n1. %L^n2. %L^n" : "%L^n%s?^n^n1. %L^n2. %L^n", id, "CHANGE_MAP_TO", tempMap, id, "YES", id, "NO")
keys = MENU_KEY_1|MENU_KEY_2
}
new menuName[64]
format(menuName, 63, "%L", "en", "WHICH_MAP")
for (new b = 0; b < pnum; ++b)
if (players[b] != id)
show_menu(players[b], keys, menuBody, iVoteTime, menuName)
format(menuBody[len], 511, "^n0. %L", id, "CANC_VOTE")
keys |= MENU_KEY_0
show_menu(id, keys, menuBody, iVoteTime, menuName)
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
show_activity_key("ADMIN_V_MAP_1", "ADMIN_V_MAP_2", name);
new tempMapA[32];
new tempMapB[32];
new tempMapC[32];
new tempMapD[32];
if (g_voteSelectedNum[id] > 0)
{
ArrayGetString(g_mapName, g_voteSelected[id][0], tempMapA, charsmax(tempMapA));
}
else
{
copy(tempMapA, charsmax(tempMapA), "");
}
if (g_voteSelectedNum[id] > 1)
{
ArrayGetString(g_mapName, g_voteSelected[id][1], tempMapB, charsmax(tempMapB));
}
else
{
copy(tempMapB, charsmax(tempMapB), "");
}
if (g_voteSelectedNum[id] > 2)
{
ArrayGetString(g_mapName, g_voteSelected[id][2], tempMapC, charsmax(tempMapC));
}
else
{
copy(tempMapC, charsmax(tempMapC), "");
}
if (g_voteSelectedNum[id] > 3)
{
ArrayGetString(g_mapName, g_voteSelected[id][3], tempMapD, charsmax(tempMapD));
}
else
{
copy(tempMapD, charsmax(tempMapD), "");
}
log_amx("Vote: ^"%s<%d><%s><>^" vote maps (map#1 ^"%s^") (map#2 ^"%s^") (map#3 ^"%s^") (map#4 ^"%s^")",
name, get_user_userid(id), authid,
tempMapA, tempMapB, tempMapC, tempMapD)
}
case 8: displayVoteMapsMenu(id, ++g_menuPosition[id])
case 9: displayVoteMapsMenu(id, --g_menuPosition[id])
default:
{
g_voteSelected[id][g_voteSelectedNum[id]++] = g_menuPosition[id] * 7 + key
displayVoteMapsMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
public actionMapsMenu(id, key)
{
switch (key)
{
case 8: displayMapsMenu(id, ++g_menuPosition[id])
case 9: displayMapsMenu(id, --g_menuPosition[id])
default:
{
new a = g_menuPosition[id] * 8 + key
new _modName[10]
get_modname(_modName, 9)
if (!equal(_modName, "zp"))
{
message_begin(MSG_ALL, SVC_INTERMISSION)
message_end()
}
new authid[32], name[32]
get_user_authid(id, authid, 31)
get_user_name(id, name, 31)
new tempMap[32];
ArrayGetString(g_mapName, a, tempMap, charsmax(tempMap));
show_activity_key("ADMIN_CHANGEL_1", "ADMIN_CHANGEL_2", name, tempMap);
log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^"", name, get_user_userid(id), authid, tempMap)
set_task(2.0, "delayedChange", 0, tempMap, strlen(tempMap) + 1)
/* displayMapsMenu(id, g_menuPosition[id]) */
}
}
return PLUGIN_HANDLED
}
displayMapsMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512]
new tempMap[32]
new start = pos * 8
new b = 0
if (start >= g_mapNums)
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CHANGLE_MENU", pos + 1, (g_mapNums / 8 + ((g_mapNums % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
if (end > g_mapNums)
end = g_mapNums
for (new a = start; a < end; ++a)
{
keys |= (1<<b)
ArrayGetString(g_mapName, a, tempMap, charsmax(tempMap));
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, tempMap)
}
if (end != g_mapNums)
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
new menuName[64]
format(menuName, 63, "%L", "en", "CHANGLE_MENU")
show_menu(id, keys, menuBody, -1, menuName)
}
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
load_settings(filename[])
{
new fp = fopen(filename, "r");
if (!fp)
{
return 0;
}
new text[256];
new tempMap[32];
while (!feof(fp))
{
fgets(fp, text, charsmax(text));
if (text[0] == ';')
{
continue;
}
if (parse(text, tempMap, charsmax(tempMap)) < 1)
{
continue;
}
if (!ValidMap(tempMap))
{
continue;
}
ArrayPushString(g_mapName, tempMap);
g_mapNums++;
}
fclose(fp);
return 1;
}

View File

@@ -0,0 +1,391 @@
/* AMX Mod X
* Menus Front-End Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
#define MAXMENUS 128
#define STRINGSIZE 32
#define STRINGLENGTH STRINGSIZE - 1
#define MENUITEMSPERPAGE 8
//#define MENUS_NUMBER 16
new g_menuPosition[33]
new g_menusNumber = 0
new g_menuBody[MAXMENUS][STRINGSIZE]
new bool:g_menuBodyPhrase[MAXMENUS]
new g_menuCmd[MAXMENUS][STRINGSIZE]
new g_menuAccess[MAXMENUS]
new g_menuPlugin[MAXMENUS][STRINGSIZE]
new g_coloredMenus
new g_clientMenuPosition[33]
new g_clientMenusNumber = 0
new g_clientMenuBody[MAXMENUS][STRINGSIZE]
new bool:g_clientMenuBodyPhrase[MAXMENUS]
new g_clientMenuCmd[MAXMENUS][STRINGSIZE]
new g_clientMenuAccess[MAXMENUS]
new g_clientMenuPlugin[MAXMENUS][STRINGSIZE]
// menuBody: Text that will be shown for this item in menu
// menuCmd: Command that should be executed to start menu
// menuAccess: Access required for menu
// menuPlugin: The exact case-insensitive name of plugin holding the menu command
public AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
{
if (g_menusNumber + 1 == MAXMENUS)
{
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
return
}
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
g_menuBodyPhrase[g_menusNumber] = false
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
g_menuAccess[g_menusNumber] = menuAccess
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
g_menusNumber++
server_print("Menu item %d added to Menus Front-End: ^"%s^" from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
}
public AddMenuLang(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
{
if (g_menusNumber + 1 == MAXMENUS)
{
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
return
}
copy(g_menuBody[g_menusNumber], STRINGLENGTH, menuBody)
g_menuBodyPhrase[g_menusNumber] = true
copy(g_menuCmd[g_menusNumber], STRINGLENGTH, menuCmd)
g_menuAccess[g_menusNumber] = menuAccess
copy(g_menuPlugin[g_menusNumber], STRINGLENGTH, menuPlugin)
g_menusNumber++
//server_print("Menu item %d added to Menus Front-End: ^"%s^" (LANG) from plugin ^"%s^"", g_menusNumber, menuBody, menuPlugin)
}
public AddClientMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
{
if (g_clientMenusNumber + 1 == MAXMENUS)
{
log_amx("Error: Plugin ^"%s^" tried to add a menu item to Menu Front-End plugin with maximum menu items reached!", menuPlugin)
return
}
copy(g_clientMenuBody[g_clientMenusNumber], STRINGLENGTH, menuBody)
g_clientMenuBodyPhrase[g_clientMenusNumber] = false
copy(g_clientMenuCmd[g_clientMenusNumber], STRINGLENGTH, menuCmd)
g_clientMenuAccess[g_clientMenusNumber] = menuAccess
copy(g_clientMenuPlugin[g_clientMenusNumber], STRINGLENGTH, menuPlugin)
g_clientMenusNumber++
server_print("Client menu item %d added to Client Menus Front-End: ^"%s^" from plugin ^"%s^"", g_clientMenusNumber, menuBody, menuPlugin)
}
AddDefaultMenus()
{
new flags;
AddMenuLang("KICK_PLAYER", "amx_kickmenu", get_clcmd_flags("amx_kickmenu", flags) ? flags : ADMIN_KICK , "Players Menu")
AddMenuLang("BAN_PLAYER", "amx_banmenu", get_clcmd_flags("amx_banmenu", flags) ? flags : ADMIN_BAN, "Players Menu")
AddMenuLang("SLAP_SLAY", "amx_slapmenu", get_clcmd_flags("amx_slapmenu", flags) ? flags : ADMIN_SLAY, "Players Menu")
AddMenuLang("TEAM_PLAYER", "amx_teammenu", get_clcmd_flags("amx_teammenu", flags) ? flags : ADMIN_LEVEL_A, "Players Menu")
AddMenuLang("CHANGEL", "amx_mapmenu", get_clcmd_flags("amx_mapmenu", flags) ? flags : ADMIN_MAP, "Maps Menu")
AddMenuLang("VOTE_MAPS", "amx_votemapmenu", get_clcmd_flags("amx_votemapmenu", flags) ? flags : ADMIN_VOTE, "Maps Menu")
AddMenuLang("SPECH_STUFF", "amx_speechmenu", get_clcmd_flags("amx_speechmenu", flags) ? flags : ADMIN_MENU, "Commands Menu")
AddMenuLang("CLIENT_COM", "amx_clcmdmenu", get_clcmd_flags("amx_clcmdmenu", flags) ? flags : ADMIN_LEVEL_A, "Players Menu")
AddMenuLang("SERVER_COM", "amx_cmdmenu", get_clcmd_flags("amx_cmdmenu", flags) ? flags : ADMIN_MENU, "Commands Menu")
AddMenuLang("CVARS_SET", "amx_cvarmenu", get_clcmd_flags("amx_cvarmenu", flags) ? flags : ADMIN_CVAR, "Commands Menu")
AddMenuLang("CONFIG", "amx_cfgmenu", get_clcmd_flags("amx_cfgmenu", flags) ? flags : ADMIN_MENU, "Commands Menu")
AddMenuLang("LANG_SET", "amx_langmenu", get_clcmd_flags("amx_langmenu", flags) ? flags : ADMIN_CFG, "Multi-Lingual System")
AddMenuLang("STATS_SET", "amx_statscfgmenu", get_clcmd_flags("amx_statscfgmenu", flags) ? flags : ADMIN_CFG, "Stats Configuration")
AddMenuLang("PAUSE_PLUG", "amx_pausecfgmenu", get_clcmd_flags("amx_pausecfgmenu", flags) ? flags : ADMIN_CFG, "Pause Plugins")
AddMenuLang("RES_WEAP", "amx_restmenu", get_clcmd_flags("amx_restmenu", flags) ? flags : ADMIN_CFG, "Restrict Weapons")
AddMenuLang("TELE_PLAYER", "amx_teleportmenu", get_clcmd_flags("amx_teleportmenu", flags) ? flags : ADMIN_CFG, "Teleport Menu")
}
stock bool:get_clcmd_flags(const search_command[], &flags)
{
new count = get_clcmdsnum(-1);
static cmd[128];
static info[1];
new _flags;
for (new i = 0; i < count; i++)
{
get_clcmd(i, cmd, charsmax(cmd), _flags, info, charsmax(info), -1);
if (strcmp(cmd, search_command) == 0)
{
flags = _flags;
return true;
}
}
return false;
}
public actionMenu(id, key)
{
switch (key)
{
case 8: displayMenu(id, ++g_menuPosition[id])
case 9: displayMenu(id, --g_menuPosition[id])
default: client_cmd(id, "%s", g_menuCmd[g_menuPosition[id] * 8 + key])
}
return PLUGIN_HANDLED
}
public clientActionMenu(id, key)
{
switch (key)
{
case 8: clientDisplayMenu(id, ++g_clientMenuPosition[id])
case 9: clientDisplayMenu(id, --g_clientMenuPosition[id])
default: client_cmd(id, "%s", g_clientMenuCmd[g_clientMenuPosition[id] * 8 + key])
}
return PLUGIN_HANDLED
}
displayMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512]
new b = 0
new start = pos * MENUITEMSPERPAGE
if (start >= g_menusNumber) // MENUS_NUMBER
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511,
g_coloredMenus ? "\yAMX Mod X Menu\R%d/%d^n\w^n" : "AMX Mod X Menu %d/%d^n^n" , pos + 1, (g_menusNumber / MENUITEMSPERPAGE) + (((g_menusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
new end = start + MENUITEMSPERPAGE
new keys = MENU_KEY_0
if (end > g_menusNumber) // MENUS_NUMBER
end = g_menusNumber // MENUS_NUMBER
for (new a = start; a < end; ++a)
{
if ( access(id, g_menuAccess[a]) &&
((is_plugin_loaded(g_menuPlugin[a]) != -1) || // search plugins for registered name
(is_plugin_loaded(g_menuPlugin[a], true) != -1))) // search plugins for filename
{
keys |= (1<<b)
if (g_menuBodyPhrase[a])
len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_menuBody[a])
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_menuBody[a])
} else {
++b
if (g_coloredMenus)
{
if (g_menuBodyPhrase[a])
len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_menuBody[a])
else
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_menuBody[a])
} else {
if (g_menuBodyPhrase[a])
len += format(menuBody[len], 511-len, "#. %L^n", id, g_menuBody[a])
else
len += format(menuBody[len], 511-len, "#. %s^n", g_menuBody[a])
}
}
}
if (end != g_menusNumber) // MENUS_NUMBER
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
} else {
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
}
show_menu(id, keys, menuBody)
}
clientDisplayMenu(id, pos)
{
if (pos < 0)
return
new menuBody[512]
new b = 0
new start = pos * MENUITEMSPERPAGE
if (start >= g_clientMenusNumber) // MENUS_NUMBER
start = pos = g_clientMenuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\yAMX Mod X Client Menu\R%d/%d^n\w^n" : "AMX Mod X Client Menu %d/%d^n^n" , pos + 1, (g_clientMenusNumber / MENUITEMSPERPAGE) + (((g_clientMenusNumber % MENUITEMSPERPAGE) > 0) ? 1 : 0))
new end = start + MENUITEMSPERPAGE
new keys = MENU_KEY_0
if (end > g_clientMenusNumber) // MENUS_NUMBER
end = g_clientMenusNumber // MENUS_NUMBER
for (new a = start; a < end; ++a)
{
if ( access(id, g_clientMenuAccess[a]) &&
((is_plugin_loaded(g_clientMenuPlugin[a]) != -1) || // search plugins for registered name
(is_plugin_loaded(g_clientMenuPlugin[a], true) != -1))) // search plugins for file name
{
keys |= (1<<b)
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len], 511-len, "%d. %L^n", ++b, id, g_clientMenuBody[a])
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, g_clientMenuBody[a])
} else {
++b
if (g_coloredMenus)
{
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len], 511-len, "\d%d. %L^n\w", b, id, g_clientMenuBody[a])
else
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, g_clientMenuBody[a])
} else {
if (g_clientMenuBodyPhrase[a])
len += format(menuBody[len], 511-len, "#. %L^n", id, g_clientMenuBody[a])
else
len += format(menuBody[len], 511-len, "#. %s^n", g_clientMenuBody[a])
}
}
}
if (end != g_clientMenusNumber) // MENUS_NUMBER
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else {
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
}
show_menu(id, keys, menuBody)
}
public cmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
public clientCmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
clientDisplayMenu(id, g_clientMenuPosition[id] = 0)
return PLUGIN_HANDLED
}
public addmenuitem_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 5))
return PLUGIN_HANDLED
// AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
new menuBody[STRINGSIZE], menuCmd[STRINGSIZE], flags[STRINGSIZE], menuAccess = 0, menuPlugin[STRINGSIZE]
read_argv(1, menuBody, STRINGLENGTH)
read_argv(2, menuCmd, STRINGLENGTH)
read_argv(3, flags, STRINGLENGTH)
menuAccess = read_flags(flags)
read_argv(4, menuPlugin, STRINGLENGTH)
AddMenu(menuBody, menuCmd, menuAccess, menuPlugin)
return PLUGIN_HANDLED
}
public addclientmenuitem_cmd(id, level, cid)
{
if (!cmd_access(id, level, cid, 5))
return PLUGIN_HANDLED
// AddMenu(const menuBody[], const menuCmd[], const menuAccess, const menuPlugin[])
new menuBody[STRINGSIZE], menuCmd[STRINGSIZE], flags[STRINGSIZE], menuAccess = 0, menuPlugin[STRINGSIZE]
read_argv(1, menuBody, STRINGLENGTH)
read_argv(2, menuCmd, STRINGLENGTH)
read_argv(3, flags, STRINGLENGTH)
menuAccess = read_flags(flags)
read_argv(4, menuPlugin, STRINGLENGTH)
AddClientMenu(menuBody, menuCmd, menuAccess, menuPlugin)
return PLUGIN_HANDLED
}
public plugin_init()
{
register_plugin("Menus Front-End", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("menufront.txt")
register_dictionary("common.txt")
register_menucmd(register_menuid("AMX Mod X Menu"), 1023, "actionMenu")
register_menucmd(register_menuid("AMX Mod X Client Menu"), 1023, "clientActionMenu")
register_clcmd("amxmodmenu", "cmdMenu", ADMIN_MENU, "- displays menus")
register_clcmd("amx_menu", "clientCmdMenu", 0, "- displays menus available to client")
register_srvcmd("amx_addmenuitem", "addmenuitem_cmd", 0, "<menu text> <menu command> <access flags> <plugin name | plugin filename> - Add a menu item to Menus Front-End")
register_srvcmd("amx_addclientmenuitem", "addclientmenuitem_cmd", 0, "<menu text> <menu command> <access flags> <plugin name | plugin filename> - Add a menu item to Client Menus Front-End")
g_coloredMenus = colored_menus()
}
public plugin_cfg()
{
AddDefaultMenus()
new configs[128]
get_configsdir(configs, 127)
server_cmd("exec %s/custommenuitems.cfg", configs)
}

View File

@@ -0,0 +1,778 @@
/* AMX Mod X
* Misc. Stats Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <csx>
#include <cstrike>
public MultiKill
public MultiKillSound
public BombPlanting
public BombDefusing
public BombPlanted
public BombDefused
public BombFailed
public BombPickUp
public BombDrop
public BombCountVoice
public BombCountDef
public BombReached
public ItalyBonusKill
public EnemyRemaining
public LastMan
public KnifeKill
public KnifeKillSound
public GrenadeKill
public GrenadeSuicide
public HeadShotKill
public HeadShotKillSound
public RoundCounterSound
public RoundCounter
public KillingStreak
public KillingStreakSound
public DoubleKill
public DoubleKillSound
public PlayerName
public FirstBloodSound
new g_streakKills[33][2]
new g_multiKills[33][2]
new g_C4Timer
new g_Defusing
new g_Planter
new Float:g_LastOmg
new g_LastAnnounce
new g_roundCount
new Float:g_doubleKill
new g_doubleKillId
new g_friend[33]
new g_firstBlood
new g_center1_sync
new g_announce_sync
new g_status_sync
new g_left_sync
new g_bottom_sync
new g_he_sync
new g_MultiKillMsg[7][] =
{
"Multi-Kill! %s^n%L %d %L (%d %L)",
"Ultra-Kill!!! %s^n%L %d %L (%d %L)",
"%s IS ON A KILLING SPREE!!!^n%L %d %L (%d %L)",
"RAMPAGE!!! %s^n%L %d %L (%d hs)",
"%s IS UNSTOPPABLE!!!^n%L %d %L (%d %L)",
"%s IS A MONSTER!^n%L %d %L (%d %L)",
"%s IS GODLIKE!!!!^n%L %d %L (%d %L)"
}
new g_Sounds[7][] =
{
"multikill",
"ultrakill",
"killingspree",
"rampage",
"unstoppable",
"monsterkill",
"godlike"
}
new g_KillingMsg[7][] =
{
"%s: Multi-Kill!",
"%s: Ultra-Kill!!!",
"%s IS ON A KILLING SPREE!!!",
"%s: RAMPAGE!!!",
"%s IS UNSTOPPABLE!!!",
"%s IS A MONSTER!",
"%s IS GODLIKE!!!"
}
new g_KinfeMsg[4][] =
{
"KNIFE_MSG_1",
"KNIFE_MSG_2",
"KNIFE_MSG_3",
"KNIFE_MSG_4"
}
new g_LastMessages[4][] =
{
"LAST_MSG_1",
"LAST_MSG_2",
"LAST_MSG_3",
"LAST_MSG_4"
}
new g_HeMessages[4][] =
{
"HE_MSG_1",
"HE_MSG_2",
"HE_MSG_3",
"HE_MSG_4"
}
new g_SHeMessages[4][] =
{
"SHE_MSG_1",
"SHE_MSG_2",
"SHE_MSG_3",
"SHE_MSG_4"
}
new g_HeadShots[7][] =
{
"HS_MSG_1",
"HS_MSG_2",
"HS_MSG_3",
"HS_MSG_4",
"HS_MSG_5",
"HS_MSG_6",
"HS_MSG_7"
}
new g_teamsNames[4][] =
{
"TERRORIST",
"CT",
"TERRORISTS",
"CTS"
}
public plugin_init()
{
register_plugin("CS Misc. Stats", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("miscstats.txt")
register_event("TextMsg", "eRestart", "a", "2&#Game_C", "2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
register_event("RoundTime", "eNewRound", "bc")
register_event("StatusValue", "setTeam", "be", "1=1")
register_event("StatusValue", "showStatus", "be", "1=2", "2!0")
register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")
new mapname[32]
get_mapname(mapname, 31)
if (equali(mapname, "de_", 3) || equali(mapname, "csde_", 5))
{
register_event("StatusIcon", "eGotBomb", "be", "1=1", "1=2", "2=c4")
register_event("TextMsg", "eBombPickUp", "bc", "2&#Got_bomb")
register_event("TextMsg", "eBombDrop", "bc", "2&#Game_bomb_d")
}
else if (equali(mapname, "cs_italy"))
{
register_event("23", "chickenKill", "a", "1=108", /*"12=106", */ "15=4")
register_event("23", "radioKill", "a", "1=108", /*"12=294", */ "15=2")
}
g_center1_sync = CreateHudSyncObj()
g_announce_sync = CreateHudSyncObj()
g_status_sync = CreateHudSyncObj()
g_left_sync = CreateHudSyncObj()
g_bottom_sync = CreateHudSyncObj()
g_he_sync = CreateHudSyncObj()
}
public plugin_cfg()
{
new g_addStast[] = "amx_statscfg add ^"%s^" %s"
server_cmd(g_addStast, "ST_MULTI_KILL", "MultiKill")
server_cmd(g_addStast, "ST_MULTI_KILL_SOUND", "MultiKillSound")
server_cmd(g_addStast, "ST_BOMB_PLANTING", "BombPlanting")
server_cmd(g_addStast, "ST_BOMB_DEFUSING", "BombDefusing")
server_cmd(g_addStast, "ST_BOMB_PLANTED", "BombPlanted")
server_cmd(g_addStast, "ST_BOMB_DEF_SUCC", "BombDefused")
server_cmd(g_addStast, "ST_BOMB_DEF_FAIL", "BombFailed")
server_cmd(g_addStast, "ST_BOMB_PICKUP", "BombPickUp")
server_cmd(g_addStast, "ST_BOMB_DROP", "BombDrop")
server_cmd(g_addStast, "ST_BOMB_CD_VOICE", "BombCountVoice")
server_cmd(g_addStast, "ST_BOMB_CD_DEF", "BombCountDef")
server_cmd(g_addStast, "ST_BOMB_SITE", "BombReached")
server_cmd(g_addStast, "ST_ITALY_BONUS", "ItalyBonusKill")
server_cmd(g_addStast, "ST_LAST_MAN", "LastMan")
server_cmd(g_addStast, "ST_KNIFE_KILL", "KnifeKill")
server_cmd(g_addStast, "ST_KNIFE_KILL_SOUND", "KnifeKillSound")
server_cmd(g_addStast, "ST_HE_KILL", "GrenadeKill")
server_cmd(g_addStast, "ST_HE_SUICIDE", "GrenadeSuicide")
server_cmd(g_addStast, "ST_HS_KILL", "HeadShotKill")
server_cmd(g_addStast, "ST_HS_KILL_SOUND", "HeadShotKillSound")
server_cmd(g_addStast, "ST_ROUND_CNT", "RoundCounter")
server_cmd(g_addStast, "ST_ROUND_CNT_SOUND", "RoundCounterSound")
server_cmd(g_addStast, "ST_KILL_STR", "KillingStreak")
server_cmd(g_addStast, "ST_KILL_STR_SOUND", "KillingStreakSound")
server_cmd(g_addStast, "ST_ENEMY_REM", "EnemyRemaining")
server_cmd(g_addStast, "ST_DOUBLE_KILL", "DoubleKill")
server_cmd(g_addStast, "ST_DOUBLE_KILL_SOUND", "DoubleKillSound")
server_cmd(g_addStast, "ST_PLAYER_NAME", "PlayerName")
server_cmd(g_addStast, "ST_FIRST_BLOOD_SOUND", "FirstBloodSound")
}
public client_putinserver(id)
{
g_multiKills[id] = {0, 0}
g_streakKills[id] = {0, 0}
}
public client_death(killer, victim, wpnindex, hitplace, TK)
{
if (wpnindex == CSW_C4)
return
new headshot = (hitplace == HIT_HEAD) ? 1 : 0
new selfkill = (killer == victim) ? 1 : 0
if (g_firstBlood)
{
g_firstBlood = 0
if (FirstBloodSound)
play_sound("misc/firstblood")
}
if ((KillingStreak || KillingStreakSound) && !TK)
{
g_streakKills[victim][1]++
g_streakKills[victim][0] = 0
if (!selfkill)
{
g_streakKills[killer][0]++
g_streakKills[killer][1] = 0
new a = g_streakKills[killer][0] - 3
if ((a > -1) && !(a % 2))
{
new name[32]
get_user_name(killer, name, 31)
if ((a >>= 1) > 6)
a = 6
if (KillingStreak)
{
set_hudmessage(0, 100, 255, 0.05, 0.50, 2, 0.02, 6.0, 0.01, 0.1, -1)
ShowSyncHudMsg(0, g_left_sync, g_KillingMsg[a], name)
}
if (KillingStreakSound)
{
new file[32]
format(file, 31, "misc/%s", g_Sounds[a])
play_sound(file)
}
}
}
}
if (MultiKill || MultiKillSound)
{
if (!selfkill && !TK && killer)
{
g_multiKills[killer][0]++
g_multiKills[killer][1] += headshot
new param[2]
param[0] = killer
param[1] = g_multiKills[killer][0]
set_task(4.0 + float(param[1]), "checkKills", 0, param, 2)
}
}
if (EnemyRemaining && is_user_connected(victim))
{
new ppl[32], pplnum = 0, maxplayers = get_maxplayers()
new epplnum = 0
new CsTeams:team = cs_get_user_team(victim)
new CsTeams:other_team
new CsTeams:enemy_team = (team == CS_TEAM_T) ? CS_TEAM_CT : CS_TEAM_T
if (team == CS_TEAM_T || team == CS_TEAM_CT)
{
for (new i=1; i<=maxplayers; i++)
{
if (!is_user_connected(i))
{
continue
}
if (i == victim)
{
continue
}
other_team = cs_get_user_team(i)
if (other_team == team && is_user_alive(i))
{
epplnum++
} else if (other_team == enemy_team) {
ppl[pplnum++] = i
}
}
if (pplnum && epplnum)
{
new message[128], team_name[32]
set_hudmessage(255, 255, 255, 0.02, 0.85, 2, 0.05, 0.1, 0.02, 3.0, -1)
/* This is a pretty stupid thing to translate, but whatever */
new _teamname[32]
if (team == CS_TEAM_T)
{
format(_teamname, 31, "TERRORIST%s", (epplnum == 1) ? "" : "S")
} else if (team == CS_TEAM_CT) {
format(_teamname, 31, "CT%s", (epplnum == 1) ? "" : "S")
}
for (new a = 0; a < pplnum; ++a)
{
format(team_name, 31, "%L", ppl[a], _teamname)
format(message, 127, "%L", ppl[a], "REMAINING", epplnum, team_name)
ShowSyncHudMsg(ppl[a], g_bottom_sync, "%s", message)
}
}
}
}
if (LastMan)
{
new cts[32], ts[32], ctsnum, tsnum
new maxplayers = get_maxplayers()
new CsTeams:team
for (new i=1; i<=maxplayers; i++)
{
if (!is_user_connected(i) || !is_user_alive(i))
{
continue
}
team = cs_get_user_team(i)
if (team == CS_TEAM_T)
{
ts[tsnum++] = i
} else if (team == CS_TEAM_CT) {
cts[ctsnum++] = i
}
}
if (ctsnum == 1 && tsnum == 1)
{
new ctname[32], tname[32]
get_user_name(cts[0], ctname, 31)
get_user_name(ts[0], tname, 31)
set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_center1_sync, "%s vs. %s", ctname, tname)
play_sound("misc/maytheforce")
}
else if (!g_LastAnnounce)
{
new oposite = 0, _team = 0
if (ctsnum == 1 && tsnum > 1)
{
g_LastAnnounce = cts[0]
oposite = tsnum
_team = 0
}
else if (tsnum == 1 && ctsnum > 1)
{
g_LastAnnounce = ts[0]
oposite = ctsnum
_team = 1
}
if (g_LastAnnounce)
{
new name[32]
get_user_name(g_LastAnnounce, name, 31)
set_hudmessage(0, 255, 255, -1.0, 0.38, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_center1_sync, "%s (%d HP) vs. %d %s%s: %L", name, get_user_health(g_LastAnnounce), oposite, g_teamsNames[_team], (oposite == 1) ? "" : "S", LANG_PLAYER, g_LastMessages[random_num(0, 3)])
if (!is_user_connecting(g_LastAnnounce))
{
client_cmd(g_LastAnnounce, "spk misc/oneandonly")
}
}
}
}
if (wpnindex == CSW_KNIFE && (KnifeKill || KnifeKillSound))
{
if (KnifeKill)
{
new killer_name[32], victim_name[32]
get_user_name(killer, killer_name, 31)
get_user_name(victim, victim_name, 31)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_he_sync, "%L", LANG_PLAYER, g_KinfeMsg[random_num(0, 3)], killer_name, victim_name)
}
if (KnifeKillSound)
play_sound("misc/humiliation")
}
if (wpnindex == CSW_HEGRENADE && (GrenadeKill || GrenadeSuicide))
{
new killer_name[32], victim_name[32]
get_user_name(killer, killer_name, 31)
get_user_name(victim, victim_name, 31)
set_hudmessage(255, 100, 100, -1.0, 0.25, 1, 6.0, 6.0, 0.5, 0.15, -1)
if (!selfkill)
{
if (GrenadeKill)
ShowSyncHudMsg(0, g_he_sync, "%L", LANG_PLAYER, g_HeMessages[random_num(0, 3)], killer_name, victim_name)
}
else if (GrenadeSuicide)
ShowSyncHudMsg(0, g_he_sync, "%L", LANG_PLAYER, g_SHeMessages[random_num(0, 3)], victim_name)
}
if (headshot && (HeadShotKill || HeadShotKillSound))
{
if (HeadShotKill && wpnindex)
{
new killer_name[32], victim_name[32], weapon_name[32], message[256], players[32], pnum
xmod_get_wpnname(wpnindex, weapon_name, 31)
get_user_name(killer, killer_name, 31)
get_user_name(victim, victim_name, 31)
get_players(players, pnum, "c")
for (new i = 0; i < pnum; i++)
{
format(message, sizeof(message)-1, "%L", players[i], g_HeadShots[random_num(0, 6)])
replace(message, sizeof(message)-1, "$vn", victim_name)
replace(message, sizeof(message)-1, "$wn", weapon_name)
replace(message, sizeof(message)-1, "$kn", killer_name)
set_hudmessage(100, 100, 255, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(players[i], g_announce_sync, "%s", message)
}
}
if (HeadShotKillSound)
{
client_cmd(killer, "spk misc/headshot")
client_cmd(victim, "spk misc/headshot")
}
}
if ((DoubleKill || DoubleKillSound) && !selfkill)
{
new Float:nowtime = get_gametime()
if (g_doubleKill == nowtime && g_doubleKillId == killer)
{
if (DoubleKill)
{
new name[32]
get_user_name(killer, name, 31)
set_hudmessage(255, 0, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_center1_sync, "%L", LANG_PLAYER, "DOUBLE_KILL", name)
}
if (DoubleKillSound)
play_sound("misc/doublekill")
}
g_doubleKill = nowtime
g_doubleKillId = killer
}
}
public hideStatus(id)
{
if (PlayerName)
{
ClearSyncHud(id, g_status_sync)
}
}
public setTeam(id)
g_friend[id] = read_data(2)
public showStatus(id)
{
if(!is_user_bot(id) && is_user_connected(id) && PlayerName)
{
new name[32], pid = read_data(2)
get_user_name(pid, name, 31)
new color1 = 0, color2 = 0
if (get_user_team(pid) == 1)
color1 = 255
else
color2 = 255
if (g_friend[id] == 1) // friend
{
new clip, ammo, wpnid = get_user_weapon(pid, clip, ammo)
new wpnname[32]
if (wpnid)
xmod_get_wpnname(wpnid, wpnname, 31)
set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_status_sync, "%s -- %d HP / %d AP / %s", name, get_user_health(pid), get_user_armor(pid), wpnname)
} else {
set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
ShowSyncHudMsg(id, g_status_sync, "%s", name)
}
}
}
public eNewRound()
{
if (read_data(1) == floatround(get_cvar_float("mp_roundtime") * 60.0,floatround_floor))
{
g_firstBlood = 1
g_C4Timer = 0
++g_roundCount
if (RoundCounter)
{
set_hudmessage(200, 0, 0, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_announce_sync, "%L", LANG_PLAYER, "PREPARE_FIGHT", g_roundCount)
}
if (RoundCounterSound)
play_sound("misc/prepare")
if (KillingStreak)
{
new appl[32], ppl, i
get_players(appl, ppl, "ac")
for (new a = 0; a < ppl; ++a)
{
i = appl[a]
if (g_streakKills[i][0] >= 2)
client_print(i, print_chat, "* %L", i, "KILLED_ROW", g_streakKills[i][0])
else if (g_streakKills[i][1] >= 2)
client_print(i, print_chat, "* %L", i, "DIED_ROUNDS", g_streakKills[i][1])
}
}
}
}
public eRestart()
{
eEndRound()
g_roundCount = 0
g_firstBlood = 1
}
public eEndRound()
{
g_C4Timer = -2
g_LastOmg = 0.0
remove_task(8038)
g_LastAnnounce = 0
}
public checkKills(param[])
{
new id = param[0]
new a = param[1]
if (a == g_multiKills[id][0])
{
a -= 3
if (a > -1)
{
if (a > 6)
{
a = 6
}
if (MultiKill)
{
new name[32]
get_user_name(id, name, 31)
set_hudmessage(255, 0, 100, 0.05, 0.50, 2, 0.02, 6.0, 0.01, 0.1, -1)
ShowSyncHudMsg(0, g_left_sync, g_MultiKillMsg[a], name, LANG_PLAYER, "WITH", g_multiKills[id][0], LANG_PLAYER, "KILLS", g_multiKills[id][1], LANG_PLAYER, "HS")
}
if (MultiKillSound)
{
new sound[24]
format(sound, 23, "misc/%s", g_Sounds[a])
play_sound(sound)
}
}
g_multiKills[id] = {0, 0}
}
}
public chickenKill()
{
if (ItalyBonusKill)
announceEvent(0, "KILLED_CHICKEN")
}
public radioKill()
{
if (ItalyBonusKill)
announceEvent(0, "BLEW_RADIO")
}
announceEvent(id, message[])
{
new name[32]
get_user_name(id, name, 31)
set_hudmessage(255, 100, 50, -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, -1)
ShowSyncHudMsg(0, g_announce_sync, "%L", LANG_PLAYER, message, name)
}
public eBombPickUp(id)
{
if (BombPickUp)
announceEvent(id, "PICKED_BOMB")
}
public eBombDrop()
{
if (BombDrop)
announceEvent(g_Planter, "DROPPED_BOMB")
}
public eGotBomb(id)
{
g_Planter = id
if (BombReached && read_data(1) == 2 && g_LastOmg < get_gametime())
{
g_LastOmg = get_gametime() + 15.0
announceEvent(g_Planter, "REACHED_TARGET")
}
}
public bombTimer()
{
if (--g_C4Timer > 0)
{
if (BombCountVoice)
{
if (g_C4Timer == 30 || g_C4Timer == 20)
{
new temp[64]
num_to_word(g_C4Timer, temp, 63)
format(temp, 63, "^"vox/%s seconds until explosion^"", temp)
play_sound(temp)
}
else if (g_C4Timer < 11)
{
new temp[64]
num_to_word(g_C4Timer, temp, 63)
format(temp, 63, "^"vox/%s^"", temp)
play_sound(temp)
}
}
if (BombCountDef && g_Defusing)
client_print(g_Defusing, print_center, "%d", g_C4Timer)
}
else
remove_task(8038)
}
public bomb_planted(planter)
{
g_Defusing = 0
if (BombPlanted)
announceEvent(planter, "SET_UP_BOMB")
g_C4Timer = get_cvar_num("mp_c4timer")
set_task(1.0, "bombTimer", 8038, "", 0, "b")
}
public bomb_planting(planter)
{
if (BombPlanting)
announceEvent(planter, "PLANT_BOMB")
}
public bomb_defusing(defuser)
{
if (BombDefusing)
announceEvent(defuser, "DEFUSING_BOMB")
g_Defusing = defuser
}
public bomb_defused(defuser)
{
if (BombDefused)
announceEvent(defuser, "DEFUSED_BOMB")
}
public bomb_explode(planter, defuser)
{
if (BombFailed && defuser)
announceEvent(defuser, "FAILED_DEFU")
}
public play_sound(sound[])
{
new players[32], pnum
get_players(players, pnum, "c")
new i
for (i = 0; i < pnum; i++)
{
if (is_user_connecting(players[i]))
continue
client_cmd(players[i], "spk %s", sound)
}
}

View File

@@ -0,0 +1,230 @@
/* AMX Mod X script.
* Multilingual System 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 <amxmisc>
#define DISPLAY_MSG // Comment to disable message on join
new g_menuLang[33][2]
new g_serverLang
new g_langNum
new g_coloredMenus
public plugin_init()
{
register_plugin("Multi-Lingual System", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("multilingual.txt")
register_dictionary("common.txt")
register_dictionary("languages.txt")
register_cvar("amx_language", "en", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
//Set to zero to disable client effects
register_cvar("amx_client_languages", "1")
register_concmd("amx_setlang", "cmdLang", ADMIN_CFG, "<language>")
register_clcmd("amx_langmenu", "cmdLangMenu", ADMIN_ALL)
register_menu("Language Menu", 1023, "actionMenu")
new lang[3]
if (vaultdata_exists("server_language"))
{
get_vaultdata("server_language", lang, 2)
} else {
copy(lang, 2, "en")
set_vaultdata("server_language", lang)
}
set_cvar_string("amx_language", lang)
g_langNum = get_langsnum()
g_serverLang = get_lang_id(lang)
g_coloredMenus = colored_menus()
}
#if defined DISPLAY_MSG
public client_putinserver(id)
{
if (get_cvar_num("amx_client_languages") && !is_user_bot(id))
set_task(10.0, "dispInfo", id)
}
public client_disconnect(id)
{
remove_task(id)
}
public dispInfo(id)
{
if (get_cvar_num("amx_client_languages"))
client_print(id, print_chat, "%L", id, "TYPE_LANGMENU")
}
#endif
public cmdLang(id, level, cid)
{
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new arg[3]
read_argv(1, arg, 2)
if (!lang_exists(arg))
{
console_print(id, "[AMXX] %L", id, "LANG_NOT_EXISTS")
return PLUGIN_HANDLED
}
set_vaultdata("server_language", arg)
set_cvar_string("amx_language", arg)
g_serverLang = get_lang_id(arg)
return PLUGIN_HANDLED
}
public cmdLangMenu(id, level, cid)
{
new buffer[3]
if (!get_cvar_num("amx_client_languages"))
{
client_print(id, print_console, "[AMXX] %L", LANG_SERVER, "LANG_MENU_DISABLED")
return PLUGIN_HANDLED
}
get_user_info(id, "lang", buffer, 2)
g_menuLang[id][0] = get_lang_id(buffer)
g_menuLang[id][1] = g_serverLang
showMenu(id)
return PLUGIN_HANDLED
}
showMenu(id)
{
if (!get_cvar_num("amx_client_languages"))
return PLUGIN_HANDLED
new menuBody[512], pLang[3]
get_lang(g_menuLang[id][0], pLang)
new len = format(menuBody, 511, (g_coloredMenus ? "\y%L\w^n^n" : "%L^n^n"), id, "LANG_MENU")
len += format(menuBody[len], 511-len, (g_coloredMenus ? "1. %L\R\r%L\w^n" : "1. %L %L^n"), id, "PERSO_LANG", pLang, "LANG_NAME")
if (access(id, ADMIN_CFG))
{
new sLang[3]
get_lang(g_menuLang[id][1], sLang)
len += format(menuBody[len], 511-len, (g_coloredMenus ? "2. %L\R\r%L\w^n^n" : "2. %L %L^n^n"), id, "SERVER_LANG", sLang, "LANG_NAME")
len += format(menuBody[len], 511-len, "3. %L", id, "SAVE_LANG")
} else {
len += format(menuBody[len], 511-len, "^n2. %L", id, "SAVE_LANG")
}
format(menuBody[len], 511-len, "^n^n0. %L", id, "EXIT")
show_menu(id, MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3, menuBody, -1, "Language Menu")
return 1
}
public actionMenu(id, key)
{
if (!get_cvar_num("amx_client_languages"))
return 0
new isAdmin = access(id, ADMIN_CFG)
if (key == 0)
{
if (g_menuLang[id][0] < (g_langNum-1))
g_menuLang[id][0]++
else
g_menuLang[id][0] = 0
showMenu(id)
}
if (isAdmin && (key == 1))
{
if (g_menuLang[id][1] < (g_langNum - 1))
g_menuLang[id][1]++
else
g_menuLang[id][1] = 0
showMenu(id)
}
new pLang[3], pLang_old[3], sLang[3], sLang_old[3], lName[64]
get_lang(g_menuLang[id][0], pLang)
get_lang(g_menuLang[id][1], sLang)
get_user_info(id, "lang", pLang_old, 2)
get_lang(g_serverLang, sLang_old)
if (isAdmin && (key == 2) && !equali(sLang, sLang_old))
{
set_vaultdata("server_language", sLang)
set_cvar_string("amx_language", sLang)
g_serverLang = g_menuLang[id][1]
format(lName, 63, "%L", sLang, "LANG_NAME")
client_print(id, print_chat, "%L", pLang, "SET_LANG_SERVER", lName)
}
if (!equali(pLang, pLang_old) && ((isAdmin && (key == 2)) || (!isAdmin && (key == 1))))
{
client_cmd(id, "setinfo ^"lang^" ^"%s^"", pLang)
format(lName, 63, "%L", pLang, "LANG_NAME")
client_print(id, print_chat, "%L", pLang, "SET_LANG_USER", lName)
}
return 0
}
get_lang_id(lang[])
{
new tLang[3]
for (new i = 0; i < g_langNum; i++)
{
get_lang(i, tLang)
if (equali(tLang, lang))
return i
}
return 0
}

View File

@@ -0,0 +1,238 @@
/* AMX Mod X
* NextMap Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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>
// WARNING: If you comment this line make sure
// that in your mapcycle file maps don't repeat.
// However the same map in a row is still valid.
#define OBEY_MAPCYCLE
new g_nextMap[32]
new g_mapCycle[32]
new g_pos
public plugin_init()
{
register_plugin("NextMap", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("nextmap.txt")
register_event("30", "changeMap", "a")
register_clcmd("say nextmap", "sayNextMap", 0, "- displays nextmap")
register_clcmd("say currentmap", "sayCurrentMap", 0, "- display current map")
register_clcmd("say ff", "sayFFStatus", 0, "- display friendly fire status")
register_cvar("amx_nextmap", "", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
new szString[32], szString2[32], szString3[8]
get_localinfo("lastmapcycle", szString, 31)
parse(szString, szString2, 31, szString3, 7)
g_pos = str_to_num(szString3)
get_cvar_string("mapcyclefile", g_mapCycle, 31)
if (!equal(g_mapCycle, szString2))
g_pos = 0 // mapcyclefile has been changed - go from first
readMapCycle(g_mapCycle, g_nextMap, 31)
set_cvar_string("amx_nextmap", g_nextMap)
format(szString3, 31, "%s %d", g_mapCycle, g_pos) // save lastmapcycle settings
set_localinfo("lastmapcycle", szString3)
}
getNextMapName(szArg[], iMax)
{
new len = get_cvar_string("amx_nextmap", szArg, iMax)
if (ValidMap(szArg)) return len
len = copy(szArg, iMax, g_nextMap)
set_cvar_string("amx_nextmap", g_nextMap)
return len
}
public sayNextMap()
{
new name[32]
getNextMapName(name, 31)
client_print(0, print_chat, "%L %s", LANG_PLAYER, "NEXT_MAP", name)
}
public sayCurrentMap()
{
new mapname[32]
get_mapname(mapname, 31)
client_print(0, print_chat, "%L: %s", LANG_PLAYER, "PLAYED_MAP", mapname)
}
public sayFFStatus()
{
client_print(0, print_chat, "%L: %L", LANG_PLAYER, "FRIEND_FIRE", LANG_PLAYER, get_cvar_num("mp_friendlyfire") ? "ON" : "OFF")
}
public delayedChange(param[])
{
set_cvar_float("mp_chattime", get_cvar_float("mp_chattime") - 2.0)
server_cmd("changelevel %s", param)
}
public changeMap()
{
new string[32]
new Float:chattime = get_cvar_float("mp_chattime")
set_cvar_float("mp_chattime", chattime + 2.0) // make sure mp_chattime is long
new len = getNextMapName(string, 31) + 1
set_task(chattime, "delayedChange", 0, string, len) // change with 1.5 sec. delay
}
new g_warning[] = "WARNING: Couldn't find a valid map or the file doesn't exist (file ^"%s^")"
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
#if defined OBEY_MAPCYCLE
readMapCycle(szFileName[], szNext[], iNext)
{
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32]
if (file_exists(szFileName))
{
while (read_file(szFileName, i++, szBuffer, 31, b))
{
if (!isalnum(szBuffer[0]) || !ValidMap(szBuffer)) continue
if (!iMaps)
copy(szFirst, 31, szBuffer)
if (++iMaps > g_pos)
{
copy(szNext, iNext, szBuffer)
g_pos = iMaps
return
}
}
}
if (!iMaps)
{
log_amx(g_warning, szFileName)
get_mapname(szFirst, 31)
}
copy(szNext, iNext, szFirst)
g_pos = 1
}
#else
readMapCycle(szFileName[], szNext[], iNext)
{
new b, i = 0, iMaps = 0
new szBuffer[32], szFirst[32], szCurrent[32]
get_mapname(szCurrent, 31)
new a = g_pos
if (file_exists(szFileName))
{
while (read_file(szFileName, i++, szBuffer, 31, b))
{
if (!isalnum(szBuffer[0]) || !ValidMap(szBuffer)) continue
if (!iMaps)
{
iMaps = 1
copy(szFirst, 31, szBuffer)
}
if (iMaps == 1)
{
if (equali(szCurrent, szBuffer))
{
if (a-- == 0)
iMaps = 2
}
} else {
if (equali(szCurrent, szBuffer))
++g_pos
else
g_pos = 0
copy(szNext, iNext, szBuffer)
return
}
}
}
if (!iMaps)
{
log_amx(g_warning, szFileName)
copy(szNext, iNext, szCurrent)
}
else
copy(szNext, iNext, szFirst)
g_pos = 0
}
#endif

View File

@@ -0,0 +1,551 @@
/* AMX Mod X
* Pause Plugins Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
// Uncomment if you want to have two new commands
// amx_off - pause plugins not marked as unpauseable
// amx_on - enable plugins not marked as unpauseable
#define DIRECT_ONOFF
#define MAX_SYSTEM 32
new g_menuPos[33]
new g_fileToSave[64]
new g_coloredMenus
new g_Modified
new g_addCmd[] = "amx_pausecfg add ^"%s^""
new g_system[MAX_SYSTEM]
new g_systemNum
public plugin_init()
{
register_plugin("Pause Plugins", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("pausecfg.txt")
register_dictionary("common.txt")
register_dictionary("admincmd.txt")
register_concmd("amx_pausecfg", "cmdPlugin", ADMIN_CFG, "- list commands for pause/unpause management")
register_clcmd("amx_pausecfgmenu", "cmdMenu", ADMIN_CFG, "- pause/unpause plugins with menu")
#if defined DIRECT_ONOFF
register_concmd("amx_off", "cmdOFF", ADMIN_CFG, "- pauses some plugins")
register_concmd("amx_on", "cmdON", ADMIN_CFG, "- unpauses some plugins")
#endif
register_menucmd(register_menuid("Pause/Unpause Plugins"), 1023, "actionMenu")
g_coloredMenus = colored_menus()
get_configsdir(g_fileToSave, 63);
format(g_fileToSave, 63, "%s/pausecfg.ini", g_fileToSave);
return PLUGIN_CONTINUE
}
#if defined DIRECT_ONOFF
public cmdOFF(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
pausePlugins(id)
return PLUGIN_HANDLED
}
public cmdON(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
unpausePlugins(id)
return PLUGIN_HANDLED
}
#endif
public plugin_cfg()
{
loadSettings(g_fileToSave)
// Put here titles of plugins which you don't want to pause
server_cmd(g_addCmd, "Admin Base")
server_cmd(g_addCmd, "Admin Base (SQL)")
server_cmd(g_addCmd, "Pause Plugins")
server_cmd(g_addCmd, "TimeLeft")
server_cmd(g_addCmd, "NextMap")
server_cmd(g_addCmd, "Slots Reservation")
}
public actionMenu(id, key)
{
switch (key)
{
case 6:
{
if (file_exists(g_fileToSave))
{
delete_file(g_fileToSave)
client_print(id, print_chat, "* %L", id, "PAUSE_CONF_CLEARED")
}
else
client_print(id, print_chat, "* %L", id, "PAUSE_ALR_CLEARED")
displayMenu(id, g_menuPos[id])
}
case 7:
{
if (saveSettings(g_fileToSave))
{
g_Modified = 0
client_print(id, print_chat, "* %L", id, "PAUSE_CONF_SAVED")
}
else
client_print(id, print_chat, "* %L", id, "PAUSE_SAVE_FAILED")
displayMenu(id, g_menuPos[id])
}
case 8: displayMenu(id, ++g_menuPos[id])
case 9: displayMenu(id, --g_menuPos[id])
default:
{
new option = g_menuPos[id] * 6 + key
new file[32], status[2]
get_plugin(option, file, 31, status, 0, status, 0, status, 0, status, 1)
switch (status[0])
{
// "running"
case 'r': pause("ac", file)
// "debug"
case 'd': pause("ac", file)
// "paused"
case 'p':
{
g_Modified = 1
unpause("ac", file)
}
// "stopped"
case 's':
{
client_print(id, print_chat, "%L", id, "CANT_UNPAUSE_PLUGIN", file);
}
}
displayMenu(id, g_menuPos[id])
}
}
return PLUGIN_HANDLED
}
getStatus(id, code, &statusCode, lStatus[], lLen)
{
switch (code)
{
// "running"
case 'r':
{
statusCode = 'O'
format(lStatus, lLen, "%L", id, "ON")
}
// "debug"
case 'd':
{
statusCode = 'O'
format(lStatus, lLen, "%L", id, "ON")
}
// "stopped"
case 's':
{
statusCode = 'S'
format(lStatus, lLen, "%L", id, "STOPPED")
}
// "paused"
case 'p':
{
statusCode = 'O'
format(lStatus, lLen, "%L", id, "OFF")
}
// "bad load"
case 'b':
{
statusCode = 'E'
format(lStatus, lLen, "%L", id, "ERROR")
}
default:
{
statusCode = 'L'
format(lStatus, lLen, "%L", id, "LOCKED")
}
}
}
isSystem(id)
{
for (new a = 0; a < g_systemNum; ++a)
if (g_system[a] == id)
return 1
return 0
}
displayMenu(id, pos)
{
if (pos < 0) return
new filename[32], title[32], status[8], statusCode
new datanum = get_pluginsnum()
new menu_body[512], start = pos * 6, k = 0
if (start >= datanum)
start = pos = g_menuPos[id] = 0
new len = format(menu_body, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "PAUSE_UNPAUSE", pos + 1, ((datanum / 6) + ((datanum % 6) ? 1 : 0)))
new end = start + 6, keys = MENU_KEY_0|MENU_KEY_8|MENU_KEY_7
if (end > datanum)
end = datanum
for (new a = start; a < end; ++a)
{
get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
getStatus(id, status[0], statusCode, status, 7)
if (isSystem(a) || (statusCode != 'O' && statusCode != 'S'))
{
if (g_coloredMenus)
{
len += format(menu_body[len], 511-len, "\d%d. %s\R%s^n\w", ++k, title, status)
} else {
++k
len += format(menu_body[len], 511-len, "#. %s %s^n", title, status)
}
} else {
keys |= (1<<k)
len += format(menu_body[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++k, title, status)
}
}
len += format(menu_body[len], 511-len, "^n7. %L^n", id, "CLEAR_PAUSED")
len += format(menu_body[len], 511-len, g_coloredMenus ? "8. %L \y\R%s^n\w" : "8. %L %s^n", id, "SAVE_PAUSED", g_Modified ? "*" : "")
if (end != datanum)
{
format(menu_body[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menu_body[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menu_body, -1, "Pause/Unpause Plugins")
}
public cmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayMenu(id, g_menuPos[id] = 0)
return PLUGIN_HANDLED
}
pausePlugins(id)
{
new filename[32], title[32], status[2]
new count = 0, imax = get_pluginsnum()
for (new a = 0; a < imax; ++a)
{
get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
if (!isSystem(a) && status[0] == 'r' && pause("ac", filename))
{
//console_print(id, "Pausing %s (file ^"%s^")", title, filename)
++count
}
}
console_print(id, "%L", id, (count == 1) ? "PAUSED_PLUGIN" : "PAUSED_PLUGINS", count)
}
unpausePlugins(id)
{
new filename[32], title[32], status[2]
new count = 0, imax = get_pluginsnum()
for (new a = 0; a < imax; ++a)
{
get_plugin(a, filename, 31, title, 31, status, 0, status, 0, status, 1)
if (!isSystem(a) && status[0] == 'p' && unpause("ac", filename))
{
//console_print(id, "Unpausing %s (file ^"%s^")", title, filename)
++count
}
}
console_print(id, "%L", id, (count == 1) ? "UNPAUSED_PLUGIN" : "UNPAUSED_PLUGINS", count)
}
findPluginByFile(arg[32], &len)
{
new name[32], title[32], status[2]
new inum = get_pluginsnum()
for (new a = 0; a < inum; ++a)
{
get_plugin(a, name, 31, title, 31, status, 0, status, 0, status, 1)
if (equali(name, arg, len) && (
status[0] == 'r' || /*running*/
status[0] == 'p' || /*paused*/
status[0] == 's' || /*stopped*/
status[0] == 'd' )) /*debug*/
{
len = copy(arg, 31, name)
return a
}
}
return -1
}
findPluginByTitle(name[], file[], len)
{
new title[32], status[2]
new inum = get_pluginsnum()
for (new a = 0; a < inum; ++a)
{
get_plugin(a, file, len, title, 31, status, 0, status, 0, status, 1)
if (equali(title, name))
return a
}
return -1
}
public cmdPlugin(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1, cmds, 31)
if (equal(cmds, "add") && read_argc() > 2)
{
read_argv(2, cmds, 31)
new file[2]
if ((g_system[g_systemNum] = findPluginByTitle(cmds, file, 0)) != -1)
{
if (g_systemNum < MAX_SYSTEM)
g_systemNum++
else
console_print(id, "%L", id, "CANT_MARK_MORE")
}
}
else if (equal(cmds, "off"))
{
pausePlugins(id)
}
else if (equal(cmds, "on"))
{
unpausePlugins(id)
}
else if (equal(cmds, "save"))
{
if (saveSettings(g_fileToSave))
{
g_Modified = 0
console_print(id, "%L", id, "PAUSE_CONF_SAVED")
}
else
console_print(id, "%L", id, "PAUSE_SAVE_FAILED")
}
else if (equal(cmds, "clear"))
{
if (file_exists(g_fileToSave))
{
delete_file(g_fileToSave)
console_print(id, "%L", id, "PAUSE_CONF_CLEARED")
}
else
console_print(id, "%L", id, "PAUSE_ALR_CLEARED")
}
else if (equal(cmds, "pause"))
{
new arg[32], a, len = read_argv(2, arg, 31)
if (len && ((a = findPluginByFile(arg, len)) != -1) && !isSystem(a) && pause("ac", arg))
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "PAUSED")
else
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
}
else if (equal(cmds, "enable"))
{
new arg[32], a, len = read_argv(2, arg, 31)
if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a))
{
if (unpause("ac", arg))
{
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "UNPAUSED")
}
else
{
console_print(id, "%L", id, "CANT_UNPAUSE_PLUGIN", arg)
}
}
else
{
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
}
}
else if (equal(cmds, "stop"))
{
new arg[32], a, len = read_argv(2, arg, 31)
if (len && (a = findPluginByFile(arg, len)) != -1 && !isSystem(a) && pause("dc", arg))
{
g_Modified = 1
console_print(id, "%L %L", id, "PAUSE_PLUGIN_MATCH", arg, id, "STOPPED")
}
else
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", arg)
}
else if (equal(cmds, "list"))
{
new lName[32], lVersion[32], lAuthor[32], lFile[32], lStatus[32]
format(lName, 31, "%L", id, "NAME")
format(lVersion, 31, "%L", id, "VERSION")
format(lAuthor, 31, "%L", id, "AUTHOR")
format(lFile, 31, "%L", id, "FILE")
format(lStatus, 31, "%L", id, "STATUS")
new arg1[8], running = 0
new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1
if (--start < 0)
start = 0
new plgnum = get_pluginsnum()
if (start >= plgnum)
start = plgnum - 1
console_print(id, "^n----- %L -----", id, "PAUSE_LOADED")
console_print(id, " %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", lName, lVersion, lAuthor, lFile, lStatus)
new plugin[32], title[32], version[16], author[32], status[16]
new end = start + 10
if (end > plgnum) end = plgnum
for (new a = start; a < end; ++a)
{
get_plugin(a, plugin, 31, title, 31, version, 15, author, 31, status, 15)
if (status[0] == 'r') ++running
console_print(id, " [%3d] %-18.17s %-8.7s %-17.16s %-16.15s %-9.8s", a + 1, title, version, author, plugin, status)
}
console_print(id, "----- %L -----", id, "PAUSE_ENTRIES", start + 1, end, plgnum, running)
if (end < plgnum)
console_print(id, "----- %L -----", id, "PAUSE_USE_MORE", end + 1)
else
console_print(id, "----- %L -----", id, "PAUSE_USE_BEGIN")
} else {
console_print(id, "%L", id, "PAUSE_USAGE")
console_print(id, "%L:", id, "PAUSE_COMMANDS")
console_print(id, "%L", id, "COM_PAUSE_OFF")
console_print(id, "%L", id, "COM_PAUSE_ON")
console_print(id, "%L", id, "COM_PAUSE_STOP")
console_print(id, "%L", id, "COM_PAUSE_PAUSE")
console_print(id, "%L", id, "COM_PAUSE_ENABLE")
console_print(id, "%L", id, "COM_PAUSE_SAVE_PAUSED")
console_print(id, "%L", id, "COM_PAUSE_CLEAR_PAUSED")
console_print(id, "%L", id, "COM_PAUSE_LIST")
console_print(id, "%L", id, "COM_PAUSE_ADD")
}
return PLUGIN_HANDLED
}
saveSettings(filename[])
{
if (file_exists(filename))
delete_file(filename)
new text[256], file[32], title[32], status[2]
new inum = get_pluginsnum()
if (!write_file(filename, ";Generated by Pause Plugins Plugin. Do not modify!^n;Title Filename"))
return 0
for (new a = 0; a < inum; ++a)
{
get_plugin(a, file, 31, title, 31, status, 0, status, 0, status, 1)
// "paused"
if (status[0] == 'p')
{
format(text, 255, "^"%s^" ;%s", title, file)
write_file(filename, text)
}
}
return 1
}
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new name[256], file[32], i, pos = 0
while (read_file(filename, pos++, name, 255, i))
{
if (name[0] != ';' && parse(name, name, 31) && (i = findPluginByTitle(name, file, 31) != -1))
pause("ac", file)
}
return 1
}

View File

@@ -0,0 +1,931 @@
/* AMX Mod X
* Players Menu Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
/** skip autoloading since it's optional */
#define AMXMODX_NOAUTOLOAD
#include <cstrike>
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33]
new g_menuSettings[33]
new g_menuSelect[33][64]
new g_menuSelectNum[33]
#define MAX_CLCMDS 24
new g_clcmdName[MAX_CLCMDS][32]
new g_clcmdCmd[MAX_CLCMDS][64]
new g_clcmdMisc[MAX_CLCMDS][2]
new g_clcmdNum
new g_coloredMenus
new g_cstrike = 0
new Array:g_bantimes;
new Array:g_slapsettings;
new g_CSTeamNames[3][] = {
"TERRORIST",
"CT",
"SPECTATOR"
}
new g_CSTeamNumbers[3][] = {
"1",
"2",
"6"
}
new g_CSTeamiNumbers[3] = {
1,
2,
6
}
public plugin_natives()
{
set_module_filter("module_filter")
set_native_filter("native_filter")
}
public plugin_init()
{
register_plugin("Players Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("common.txt")
register_dictionary("admincmd.txt")
register_dictionary("plmenu.txt")
register_clcmd("amx_kickmenu", "cmdKickMenu", ADMIN_KICK, "- displays kick menu")
register_clcmd("amx_banmenu", "cmdBanMenu", ADMIN_BAN, "- displays ban menu")
register_clcmd("amx_slapmenu", "cmdSlapMenu", ADMIN_SLAY, "- displays slap/slay menu")
register_clcmd("amx_teammenu", "cmdTeamMenu", ADMIN_LEVEL_A, "- displays team menu")
register_clcmd("amx_clcmdmenu", "cmdClcmdMenu", ADMIN_LEVEL_A, "- displays client cmds menu")
register_menucmd(register_menuid("Ban Menu"), 1023, "actionBanMenu")
register_menucmd(register_menuid("Kick Menu"), 1023, "actionKickMenu")
register_menucmd(register_menuid("Slap/Slay Menu"), 1023, "actionSlapMenu")
register_menucmd(register_menuid("Team Menu"), 1023, "actionTeamMenu")
register_menucmd(register_menuid("Client Cmds Menu"), 1023, "actionClcmdMenu")
g_bantimes = ArrayCreate();
// Load up the old default values
ArrayPushCell(g_bantimes, 0);
ArrayPushCell(g_bantimes, 5);
ArrayPushCell(g_bantimes, 10);
ArrayPushCell(g_bantimes, 15);
ArrayPushCell(g_bantimes, 30);
ArrayPushCell(g_bantimes, 45);
ArrayPushCell(g_bantimes, 60);
g_slapsettings = ArrayCreate();
// Old default values
ArrayPushCell(g_slapsettings, 0); // First option is ignored - it is slay
ArrayPushCell(g_slapsettings, 0); // slap 0 damage
ArrayPushCell(g_slapsettings, 1);
ArrayPushCell(g_slapsettings, 5);
register_srvcmd("amx_plmenu_bantimes", "plmenu_setbantimes");
register_srvcmd("amx_plmenu_slapdmg", "plmenu_setslapdmg");
g_coloredMenus = colored_menus()
new clcmds_ini_file[64]
get_configsdir(clcmds_ini_file, 63)
format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file)
load_settings(clcmds_ini_file)
if (module_exists("cstrike"))
g_cstrike = 1
}
public plmenu_setbantimes()
{
new buff[32];
new args = read_argc();
if (args <= 1)
{
server_print("usage: amx_plmenu_bantimes <time1> [time2] [time3] ...");
server_print(" use time of 0 for permanent.");
return;
}
ArrayClear(g_bantimes);
for (new i = 1; i < args; i++)
{
read_argv(i, buff, charsmax(buff));
ArrayPushCell(g_bantimes, str_to_num(buff));
}
}
public plmenu_setslapdmg()
{
new buff[32];
new args = read_argc();
if (args <= 1)
{
server_print("usage: amx_plmenu_slapdmg <dmg1> [dmg2] [dmg3] ...");
server_print(" slay is automatically set for the first value.");
return;
}
ArrayClear(g_slapsettings);
ArrayPushCell(g_slapsettings, 0); // compensate for slay
for (new i = 1; i < args; i++)
{
read_argv(i, buff, charsmax(buff));
ArrayPushCell(g_slapsettings, str_to_num(buff));
}
}
public module_filter(const module[])
{
if (equali(module, "cstrike"))
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public native_filter(const name[], index, trap)
{
if (!trap)
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
/* Ban menu */
public actionBanMenu(id, key)
{
switch (key)
{
case 7:
{
/* BEGIN OF CHANGES BY MISTAGEE ADDED A FEW MORE OPTIONS */
++g_menuOption[id]
g_menuOption[id] %= ArraySize(g_bantimes);
g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]);
displayBanMenu(id, g_menuPosition[id])
}
case 8: displayBanMenu(id, ++g_menuPosition[id])
case 9: displayBanMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name[32], name2[32], authid[32], authid2[32]
get_user_name(player, name2, 31)
get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
new userid2 = get_user_userid(player)
log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id])
if (g_menuSettings[id]==0) // permanent
{
new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++)
{
show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "PERM");
}
}
else
{
new tempTime[32];
formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]);
new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++)
{
show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "FOR_MIN", tempTime);
}
}
/* ---------- check for Steam ID added by MistaGee --------------------
IF AUTHID == 4294967295 OR VALVE_ID_LAN OR HLTV, BAN PER IP TO NOT BAN EVERYONE */
if (equal("4294967295", authid2)
|| equal("HLTV", authid2)
|| equal("STEAM_ID_LAN", authid2)
|| equali("VALVE_ID_LAN", authid2))
{
/* END OF MODIFICATIONS BY MISTAGEE */
new ipa[32]
get_user_ip(player, ipa, 31, 1)
server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa)
}
else
{
server_cmd("banid %d #%d kick;writeid", g_menuSettings[id], userid2)
}
server_exec()
displayBanMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayBanMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "BAN_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0)))
new end = start + 7
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (is_user_bot(i) || (access(i, ADMIN_IMMUNITY) && i != id))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
else
len += format(menuBody[len], 511-len, "#. %s^n", name)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if (g_menuSettings[id])
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_FOR_MIN", g_menuSettings[id])
else
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "BAN_PERM")
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Ban Menu")
}
public cmdBanMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
g_menuOption[id] = 0
if (ArraySize(g_bantimes) > 0)
{
g_menuSettings[id] = ArrayGetCell(g_bantimes, g_menuOption[id]);
}
else
{
// should never happen, but failsafe
g_menuSettings[id] = 0
}
displayBanMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Slap/Slay */
public actionSlapMenu(id, key)
{
switch (key)
{
case 7:
{
++g_menuOption[id]
g_menuOption[id] %= ArraySize(g_slapsettings);
g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]);
displaySlapMenu(id, g_menuPosition[id]);
}
case 8: displaySlapMenu(id, ++g_menuPosition[id])
case 9: displaySlapMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new name2[32]
get_user_name(player, name2, 31)
if (!is_user_alive(player))
{
client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2)
displaySlapMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
new authid[32], authid2[32], name[32]
get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
if (g_menuOption[id])
{
log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, g_menuSettings[id], name2, get_user_userid(player), authid2)
show_activity_key("ADMIN_SLAP_1", "ADMIN_SLAP_2", name, name2, g_menuSettings[id]);
} else {
log_amx("Cmd: ^"%s<%d><%s><>^" slay ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
show_activity_key("ADMIN_SLAY_1", "ADMIN_SLAY_2", name, name2);
}
if (g_menuOption[id])
user_slap(player, (get_user_health(player) > g_menuSettings[id]) ? g_menuSettings[id] : 0)
else
user_kill(player)
displaySlapMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displaySlapMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32], team[4]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "SLAP_SLAY_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0)))
new end = start + 7
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (g_cstrike)
{
if (cs_get_user_team(i) == CS_TEAM_T)
{
copy(team, 3, "TE")
}
else if (cs_get_user_team(i) == CS_TEAM_CT)
{
copy(team, 3, "CT")
} else {
get_user_team(i, team, 3)
}
} else {
get_user_team(i, team, 3)
}
if (!is_user_alive(i) || (access(i, ADMIN_IMMUNITY) && i != id))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
else
len += format(menuBody[len], 511-len, "#. %s %s^n", name, team)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team)
else
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team)
}
}
if (g_menuOption[id])
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAP_WITH_DMG", g_menuSettings[id])
else
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "SLAY")
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Slap/Slay Menu")
}
public cmdSlapMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
g_menuOption[id] = 0
if (ArraySize(g_slapsettings) > 0)
{
g_menuSettings[id] = ArrayGetCell(g_slapsettings, g_menuOption[id]);
}
else
{
// should never happen, but failsafe
g_menuSettings[id] = 0
}
displaySlapMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Kick */
public actionKickMenu(id, key)
{
switch (key)
{
case 8: displayKickMenu(id, ++g_menuPosition[id])
case 9: displayKickMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 8 + key]
new authid[32], authid2[32], name[32], name2[32]
get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
get_user_name(player, name2, 31)
new userid2 = get_user_userid(player)
log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, userid2, authid2)
show_activity_key("ADMIN_KICK_1", "ADMIN_KICK_2", name, name2);
server_cmd("kick #%d", userid2)
server_exec()
displayKickMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayKickMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 8
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0)))
new end = start + 8
new keys = MENU_KEY_0
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (access(i, ADMIN_IMMUNITY) && i != id)
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
else
len += format(menuBody[len], 511-len, "#. %s^n", name)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Kick Menu")
}
public cmdKickMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayKickMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Team menu */
public actionTeamMenu(id, key)
{
switch (key)
{
case 7:
{
g_menuOption[id] = (g_menuOption[id] + 1) % (g_cstrike ? 3 : 2);
displayTeamMenu(id, g_menuPosition[id])
}
case 8: displayTeamMenu(id, ++g_menuPosition[id])
case 9: displayTeamMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new authid[32], authid2[32], name[32], name2[32]
get_user_name(player, name2, 31)
get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
log_amx("Cmd: ^"%s<%d><%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2, g_menuOption[id] ? "TERRORIST" : "CT")
show_activity_key("ADMIN_TRANSF_1", "ADMIN_TRANSF_2", name, name2, g_CSTeamNames[g_menuOption[id] % 3]);
if (g_cstrike)
{
if (is_user_alive(player))
{
new deaths = cs_get_user_deaths(player)
user_kill(player, 1)
cs_set_user_deaths(player, deaths)
}
// This modulo math just aligns the option to the CsTeams-corresponding number
cs_set_user_team(player, (g_menuOption[id] % 3) + 1)
cs_reset_user_model(player)
} else {
new limit_setting = get_cvar_num("mp_limitteams")
set_cvar_num("mp_limitteams", 0)
engclient_cmd(player, "jointeam", g_CSTeamNumbers[g_menuOption[id] % 2])
engclient_cmd(player, "joinclass", "1")
set_cvar_num("mp_limitteams", limit_setting)
}
displayTeamMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayTeamMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i, iteam
new name[32], team[4]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0)))
new end = start + 7
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (g_cstrike)
{
iteam = _:cs_get_user_team(i)
if (iteam == 1)
{
copy(team, 3, "TE")
}
else if (iteam == 2)
{
copy(team, 3, "CT")
}
else if (iteam == 3)
{
copy(team, 3, "SPE");
iteam = 6;
} else {
iteam = get_user_team(i, team, 3)
}
} else {
iteam = get_user_team(i, team, 3)
}
if ((iteam == g_CSTeamiNumbers[g_menuOption[id] % (g_cstrike ? 3 : 2)]) || (access(i, ADMIN_IMMUNITY) && i != id))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team)
else
len += format(menuBody[len], 511-len, "#. %s %s^n", name, team)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team)
else
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team)
}
}
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_CSTeamNames[g_menuOption[id] % (g_cstrike ? 3 : 2)])
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Team Menu")
}
public cmdTeamMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
g_menuOption[id] = 0
displayTeamMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
/* Client cmds menu */
public actionClcmdMenu(id, key)
{
switch (key)
{
case 7:
{
++g_menuOption[id]
g_menuOption[id] %= g_menuSelectNum[id]
displayClcmdMenu(id, g_menuPosition[id])
}
case 8: displayClcmdMenu(id, ++g_menuPosition[id])
case 9: displayClcmdMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key]
new flags = g_clcmdMisc[g_menuSelect[id][g_menuOption[id]]][1]
if (is_user_connected(player))
{
new command[512], authid[32], name[32], userid[32]
copy(command, charsmax(command), g_clcmdCmd[g_menuSelect[id][g_menuOption[id]]])
get_user_authid(player, authid, 31)
get_user_name(player, name, 31)
num_to_str(get_user_userid(player), userid, 31)
replace(command, charsmax(command), "%userid%", userid)
replace(command, charsmax(command), "%authid%", authid)
replace(command, charsmax(command), "%name%", name)
if (flags & 1)
{
server_cmd("%s", command)
server_exec()
} else if (flags & 2)
client_cmd(id, "%s", command)
else if (flags & 4)
client_cmd(player, "%s", command)
}
if (flags & 8)
displayClcmdMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayClcmdMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 7
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0)))
new end = start + 7
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (!g_menuSelectNum[id] || (access(i, ADMIN_IMMUNITY) && i != id))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
else
len += format(menuBody[len], 511-len, "#. %s^n", name)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if (g_menuSelectNum[id])
len += format(menuBody[len], 511-len, "^n8. %s^n", g_clcmdName[g_menuSelect[id][g_menuOption[id]]])
else
len += format(menuBody[len], 511-len, "^n8. %L^n", id, "NO_CMDS")
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Client Cmds Menu")
}
public cmdClcmdMenu(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
g_menuSelectNum[id] = 0
for (new a = 0; a < g_clcmdNum; ++a)
if (access(id, g_clcmdMisc[a][0]))
g_menuSelect[id][g_menuSelectNum[id]++] = a
g_menuOption[id] = 0
displayClcmdMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
load_settings(szFilename[])
{
if (!file_exists(szFilename))
return 0
new text[256], szFlags[32], szAccess[32]
new a, pos = 0
while (g_clcmdNum < MAX_CLCMDS && read_file(szFilename, pos++, text, 255, a))
{
if (text[0] == ';') continue
if (parse(text, g_clcmdName[g_clcmdNum], 31, g_clcmdCmd[g_clcmdNum], 63, szFlags, 31, szAccess, 31) > 3)
{
while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^""))
{
// do nothing
}
g_clcmdMisc[g_clcmdNum][1] = read_flags(szFlags)
g_clcmdMisc[g_clcmdNum][0] = read_flags(szAccess)
g_clcmdNum++
}
}
return 1
}

View File

@@ -0,0 +1,957 @@
/* AMX Mod X
* Plugin Cvar and Command Menu
*
* 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 <amxmisc>
new DisabledCallback;
new EnabledCallback;
// pcvar that the client is currently modifying
new CurrentCvar[33];
// Name of the cvar being modified
new CurrentCvarName[33][32];
// Plugin ID that the client is modifying
new CurrentPlid[33];
// Page that the client is currently on
new CurrentPage[33];
// Menu function ID that the client is in
new CurrentMenuFunction[33] = { -1,... };
new CurrentCommand[33][32];
new cvarmenu_cmdid;
new cmdmenu_cmdid;
new ExplicitPlugin[33];
public plugin_init()
{
register_plugin("Plugin Menu",AMXX_VERSION_STR,"AMXX Dev Team");
register_dictionary("common.txt");
register_dictionary("pausecfg.txt"); // Needed for PAUSE_COULDNT_FIND
cvarmenu_cmdid=register_clcmd("amx_plugincvarmenu", "CvarMenuCommand", ADMIN_CVAR, " - displays the plugin cvar menu");
cmdmenu_cmdid=register_clcmd("amx_plugincmdmenu", "CommandMenuCommand", ADMIN_MENU, " - displays the plugin command menu");
register_clcmd("amx_changecvar","CommandChangeCvar");
register_clcmd("amx_executecmd","CommandExecuteCommand");
// Register global menu callbacks.
DisabledCallback=menu_makecallback("AlwaysDisableCallback");
EnabledCallback=menu_makecallback("AlwaysEnableCallback");
}
// Add these menus to the amxmodmenu
public plugin_cfg()
{
set_task(0.1, "addToMenuFront");
}
public addToMenuFront()
{
new PluginFileName[64];
get_plugin(-1, PluginFileName, charsmax(PluginFileName));
new cvarflags;
new cmdflags;
new garbage[1];
new cmd[32];
get_concmd(cmdmenu_cmdid, cmd, charsmax(cmd), cmdflags, garbage, charsmax(garbage), -1);
if (strcmp(cmd, "amx_plugincmdmenu") != 0)
{
// this should never happen, but just incase!
cmdflags = ADMIN_MENU;
}
get_concmd(cvarmenu_cmdid, cmd, charsmax(cmd), cvarflags, garbage, charsmax(garbage), -1);
if (strcmp(cmd, "amx_plugincvarmenu") != 0)
{
// this should never happen, but just incase!
cvarflags = ADMIN_CVAR;
}
AddMenuItem("Plugin Cvars", "amx_plugincvarmenu", cvarflags, PluginFileName);
AddMenuItem("Plugin Commands", "amx_plugincmdmenu", cmdflags, PluginFileName);
}
// Reset all fields for each client as they connect.
public client_connect(id)
{
CurrentCvar[id]=0;
CurrentPlid[id]=0;
CurrentMenuFunction[id]=-1;
CurrentCvarName[id][0]=0;
CurrentCommand[id][0]=0;
ExplicitPlugin[id]=-1;
}
/**
* Creates a plugin list menu.
*
* @param MenuText The text to display as the title.
* @param Handler The function to call when an item is selected.
* @param Command The function to pass to the handler. It will be passed as "PLID Command".
* @param Callback Function to call for each plugin to be listed. Displays a number next to it (how many cvars, etc.)
*/
stock DisplayPluginMenu(id,const MenuText[], const Handler[], const Command[], const Callback[])
{
new Menu=menu_create(MenuText,Handler);
new PluginState[32];
new PluginName[64];
new func=get_func_id(Callback);
new tally;
new PluginCmd[64];
new MenuText[64];
for (new i=0, max=get_pluginsnum();
i<max;
i++)
{
if (callfunc_begin_i(func,-1)==1)
{
callfunc_push_int(i); // push the plid
if ((tally=callfunc_end())>0)
{
get_plugin(i,"",0,PluginName,sizeof(PluginName)-1,"",0,"",0,PluginState,sizeof(PluginState)-1);
// Command syntax is: "# Function", # being plugin ID, function being public function to call.
formatex(PluginCmd,sizeof(PluginCmd)-1,"%d %s",i,Command);
formatex(MenuText,sizeof(MenuText)-1,"%s - %d",PluginName,tally);
// If the plugin is running, add this as an activated menu item.
if (strcmp(PluginState,"running",true)==0 ||
strcmp(PluginState,"debug", true)==0)
{
menu_additem(Menu,MenuText,PluginCmd,EnabledCallback);
}
else
{
menu_additem(Menu,MenuText,"",_,DisabledCallback);
}
}
}
}
menu_setprop(Menu,MPROP_NUMBER_COLOR,"\y");
menu_setprop(Menu,MPROP_EXIT,MEXIT_ALL);
menu_display(id,Menu,0);
}
/**
* Byrefs the plugin id of a target plugin (passed by argv(1)), but only if it's valid.
*
* @param id id of the display messages to upon failure.
* @param plid Variable to byref the plugin id.
* @return True on successful lookup, false on failure.
*/
stock bool:GetPlidForValidPlugins(id, &plid)
{
// If arguments have been passed, then we were given
// a specific plugin to examine.
if (read_argc()>1)
{
// Yes, we were provided a plugin.
new TargetPlugin[64];
read_argv(1,TargetPlugin,sizeof(TargetPlugin)-1);
new BufferName[64];
new BufferFile[64];
new BufferState[64];
// Scan for the plugin ID.
for (new i=0, max=get_pluginsnum();
i<max;
i++)
{
get_plugin(i,BufferFile,sizeof(BufferFile)-1,BufferName,sizeof(BufferName)-1,"",0,"",0,BufferState,sizeof(BufferState)-1);
if (strcmp(BufferFile,TargetPlugin,true) != 0||
strcmp(BufferName,TargetPlugin,true) != 0)
{
// We have a match.
// Check the status of the plugin. If it's anything other than "running" or "debug" fail.
if (strcmp(BufferState,"running") != 0 &&
strcmp(BufferState,"debug") != 0)
{
// TODO: ML This
console_print(id,"Plugin ^"%s^" is not running.",BufferFile);
// Return a failed state.
return false;
}
plid=i;
break;
}
}
// If the plugin was not found, then tell them there was an error.
if (plid==-1)
{
console_print(id, "%L", id, "PAUSE_COULDNT_FIND", TargetPlugin);
// return a failure state
return false;
}
}
return true;
}
/**
* Returns the number of cvars available for a plugin by plid. (Callback for the plugin menu.)
*
* @return number of cvars in the plugin.
*/
public GetNumberOfCvarsForPlid(plid)
{
new count=0;
new CvarPlid;
for (new i=0, max=get_plugins_cvarsnum();
i<max;
i++)
{
get_plugins_cvar(i, "", 0,_, CvarPlid, _);
if (CvarPlid==plid)
{
count++;
}
}
return count;
}
/**
* Returns the number of commands available for a plugin by plid. (Callback for the plugin menu.)
*
* @return Number of valid commands in the plugin.
*/
public GetNumberOfCmdsForPlid(plid)
{
new count=0;
for (new i=0, max=get_concmdsnum(-1,-1);
i<max;
i++)
{
if (get_concmd_plid(i,-1,-1)==plid)
{
count++;
}
}
return count;
}
/**
* Whether or not the client has access to modify this cvar.
*
* @param id The admin id.
* @param Cvar The name of the cvar to be checked.
* @return True if the client has access, false otherwise.
*/
stock bool:CanIModifyCvar(id, const Cvar[])
{
new UserFlags=get_user_flags(id);
// If the user has rcon access don't bother checking anything.
if (UserFlags & ADMIN_RCON)
{
return true;
}
// If the cvar is "sv_password" (somehow), then check access.
if (equali(Cvar,"sv_password") && UserFlags & ADMIN_PASSWORD)
{
return true;
}
// Check to see if the cvar is flagged as protected.
if (get_cvar_flags(Cvar) & FCVAR_PROTECTED)
{
// non-rcon user trying to modify a protected cvar.
return false;
}
// All known checks done, they can change this cvar if they
// were able to open the menu.
return true;
}
/**
* Simple function to ensure that a menu item is always disabled.
*
* All parameters are dummy, nothing is used.
*/
public AlwaysDisableCallback(playerid, menuid, itemid)
{
return ITEM_DISABLED;
}
/**
* Simple function to ensure that a menu item is always enabled.
*
* All parameters are dummy, nothing is used.
*/
public AlwaysEnableCallback(playerid, menuid, itemid)
{
return ITEM_ENABLED;
}
/**
* Handler for the plugin menu.
*
* @param id The client selecting an item.
* @param menu The menu handle.
* @param item The item number that was selected.
*/
public PluginMenuSelection(id, menu, item)
{
if (item==MENU_EXIT)
{
menu_destroy(menu);
}
if (item<0)
{
return PLUGIN_HANDLED;
}
new Command[64];
new Dummy[1];
// All of the commands set for each item is the public
// function that we want to call after the item is selected.
// The parameters are: function(idPlayer,itemnumber)
// Note the menu is destroyed BEFORE the command
// gets executed.
// The command retrieved is in the format: "PLID Command"
menu_item_getinfo(menu, item, Dummy[0], Command, sizeof(Command)-1,Dummy,0,Dummy[0]);
new plid=str_to_num(Command);
new Function[32];
for (new i=0;i<sizeof(Command)-1;i++)
{
if (Command[i]==' ')
{
// we're at the break. move up one space.
i++;
copy(Function,sizeof(Function)-1,Command[i]);
break;
}
}
menu_destroy(menu);
new funcid=get_func_id(Function);
if (funcid != -1 && callfunc_begin_i(funcid)==1)
{
CurrentPage[id]=0;
CurrentPlid[id]=plid;
CurrentMenuFunction[id]=funcid;
callfunc_push_int(id);
callfunc_push_int(plid);
callfunc_push_int(0);
callfunc_end();
}
return PLUGIN_HANDLED;
}
/**
* The command to change a cvar has been called.
*
* @param id The client who is changing the cvar.
*/
public CommandChangeCvar(id)
{
// All access checks are done before this command is called.
// So if the client has no pcvar pointer in his array slot
// then just ignore the command.
if (CurrentCvar[id]==0)
{
return PLUGIN_CONTINUE;
}
new Args[256];
read_args(Args,sizeof(Args)-1);
remove_quotes(Args);
if (equali(Args,"!cancel",7))
{
// The client didn't want to change this cvar.
client_print(id,print_chat,"[AMXX] Cvar not changed.");
}
else
{
// Changed to set_cvar_* for 1.76 tests
new pointer=CurrentCvar[id];
set_pcvar_string(CurrentCvar[id],Args);
client_print(id,print_chat,"[AMXX] Cvar ^"%s^" changed to ^"%s^"",CurrentCvarName[id],Args);
// Copy of admincmd's global output.
new Name[32];
new AuthID[40];
get_user_name(id,Name,sizeof(Name)-1);
get_user_authid(id,AuthID,sizeof(AuthID)-1);
log_amx("Cmd: ^"%s<%d><%s><>^" set cvar (name ^"%s^") (value ^"%s^")", Name, get_user_userid(id), AuthID, CurrentCvarName[id], Args);
new cvar_val[64];
new maxpl = get_maxplayers();
for (new i = 1; i <= maxpl; i++)
{
if (is_user_connected(i) && !is_user_bot(i))
{
if (get_pcvar_flags(pointer) & FCVAR_PROTECTED || equali(Args, "rcon_password"))
{
formatex(cvar_val, charsmax(cvar_val), "*** %L ***", i, "PROTECTED");
}
else
{
copy(cvar_val, charsmax(cvar_val), Args);
}
show_activity_id(i, id, Name, "%L", i, "SET_CVAR_TO", "", CurrentCvarName[id], cvar_val);
}
}
console_print(id, "[AMXX] %L", id, "CVAR_CHANGED", CurrentCvarName[id], Args);
}
// Now redraw the menu for the client
if (CurrentMenuFunction[id]!=-1 && callfunc_begin_i(CurrentMenuFunction[id])==1)
{
callfunc_push_int(id);
callfunc_push_int(CurrentPlid[id]);
callfunc_push_int(CurrentPage[id]);
callfunc_end();
}
return PLUGIN_HANDLED;
}
/**
* Process a selection from the cvar menu.
*
* @param id The client who chose an item.
* @param menu The menu handle.
* @param item The item that has been selected.
*/
public CvarMenuSelection(id, menu, item)
{
if (item==MENU_EXIT)
{
menu_destroy(menu);
if (ExplicitPlugin[id]==-1)
{
client_cmd(id,"amx_plugincvarmenu");
}
return PLUGIN_HANDLED;
}
else if (item==MENU_BACK)
{
--CurrentPage[id];
client_print(id,print_chat,"MENU_BACK");
return PLUGIN_HANDLED;
}
else if (item==MENU_MORE)
{
++CurrentPage[id];
client_print(id,print_chat,"MENU_MORE");
return PLUGIN_HANDLED;
}
else
{
new CvarName[64];
new Command[32];
new Dummy[1];
// pcvar pointer is stored in command, extract the name of the cvar from the name field.
menu_item_getinfo(menu, item, Dummy[0], Command, sizeof(Command)-1,CvarName,sizeof(CvarName)-1,Dummy[0]);
CurrentCvar[id]=str_to_num(Command);
if (CurrentCvar[id]==0) // This should never happen, but just incase..
{
client_print(id,print_chat,"[AMXX] There was an error extracting the cvar pointer. (Name=^"%s^")",CvarName);
return PLUGIN_HANDLED;
}
// TODO: ML this
// Scan up "CvarName" and stop at the first space
for (new i=0;i<sizeof(CvarName)-1;i++)
{
if (CvarName[i]==' ')
{
CvarName[i]='^0';
break;
}
}
copy(CurrentCvarName[id],sizeof(CurrentCvarName[])-1,CvarName);
client_print(id,print_chat,"[AMXX] Type in the new value for %s, or !cancel to cancel.",CvarName);
client_cmd(id,"messagemode amx_changecvar");
menu_destroy(menu);
return PLUGIN_HANDLED;
}
return 0;
}
/**
* Displays the cvar menu to a client.
*
* @param id id of the client.
* @param plid Plugin ID to display cvars from.
* @param page Page of the menu to start at.
*/
public DisplayCvarMenu(id, plid, page)
{
new PluginName[32];
new MenuTitle[64];
get_plugin(plid,"",0,PluginName,sizeof(PluginName)-1,"",0,"",0,"",0);
formatex(MenuTitle,sizeof(MenuTitle)-1,"%s Cvars:",PluginName);
new Menu=menu_create(MenuTitle,"CvarMenuSelection");
new Cvar[64];
new CvarPlid;
new CvarText[64];
new CvarData[32];
new CvarPtr;
for (new i=0, max=get_plugins_cvarsnum();
i<max;
i++)
{
get_plugins_cvar(i, Cvar, sizeof(Cvar),_, CvarPlid, CvarPtr);
if (CvarPlid==plid)
{
if (CanIModifyCvar(id,Cvar))
{
get_pcvar_string(CvarPtr,CvarData,sizeof(CvarData)-1);
formatex(CvarText,sizeof(CvarText)-1,"%s - %s",Cvar,CvarData);
// Now store the pcvar data in Cvar
num_to_str(CvarPtr,Cvar,sizeof(Cvar)-1);
menu_additem(Menu,CvarText,Cvar,_,EnabledCallback);
}
else
{
menu_additem(Menu,Cvar,"",_,DisabledCallback);
}
}
}
menu_setprop(Menu,MPROP_EXIT,MEXIT_ALL);
menu_setprop(Menu,MPROP_NUMBER_COLOR,"\y");
menu_display(id,Menu,page);
}
/**
* Process the "amx_plugincvarmenu" command.
*
* @param id id of the client that is calling the command.
* @param level Access level required by the command.
* @param cid Command ID.
*/
public CvarMenuCommand(id, level, cid)
{
if (!cmd_access(id,level,cid,0))
{
return PLUGIN_HANDLED;
}
// This is which plugin to display. -1 means display all plugins in a list.
new plid=-1;
if (GetPlidForValidPlugins(id,plid)!=true)
{
// If GetPlidForValidPlugins returns false then it failed to find the plugin.
return PLUGIN_HANDLED;
}
// Check if we were passed a specific plugin to display or not.
if (plid==-1)
{
ExplicitPlugin[id]=-1;
// We need to display a list of the plugins, instead of a specific plugin.
DisplayPluginMenu(id,"Plugin Cvar Menu:", "PluginMenuSelection","DisplayCvarMenu","GetNumberOfCvarsForPlid");
}
else
{
ExplicitPlugin[id]=plid;
CurrentPlid[id]=plid;
CurrentPage[id]=0;
DisplayCvarMenu(id,plid,0);
}
return PLUGIN_HANDLED;
}
/**
* Handler for the menu that displays a single command ("Execute with no params", etc).
*
* @param id Id of the client.
* @param menu Menu handle.
* @param item Item that was selected.
*/
public SpecificCommandHandler(id,menu,item)
{
// Exit was called, return to the previous menu.
if (item<0)
{
if (CurrentMenuFunction[id]!=-1 && callfunc_begin_i(CurrentMenuFunction[id])==1)
{
callfunc_push_int(id);
callfunc_push_int(CurrentPlid[id]);
callfunc_push_int(CurrentPage[id]);
callfunc_end();
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new Dummy[1];
if (item==0) // "With params"
{
menu_item_getinfo(menu, item, Dummy[0], CurrentCommand[id], sizeof(CurrentCommand[])-1,"",0,Dummy[0]);
if (CurrentCommand[id][0]==0) // This should never happen, but just incase..
{
client_print(id,print_chat,"[AMXX] There was an error extracting the command name.");
return PLUGIN_HANDLED;
}
// TODO: ML this
client_print(id,print_chat,"[AMXX] Type in the parameters for %s, or !cancel to cancel.",CurrentCommand[id]);
client_cmd(id,"messagemode amx_executecmd");
menu_destroy(menu);
return PLUGIN_HANDLED; // Don't return to original menu immediately!
}
else if (item==1) // "No params"
{
menu_item_getinfo(menu, item, Dummy[0], CurrentCommand[id], sizeof(CurrentCommand[])-1,"",0,Dummy[0]);
if (CurrentCommand[id][0]==0) // This should never happen, but just incase..
{
client_print(id,print_chat,"[AMXX] There was an error extracting the command name.");
return PLUGIN_HANDLED;
}
// TODO: ML this
// Now redraw the menu for the client BEFORE the command is executed, incase
// that menu brings up a menu of its own.
if (CurrentMenuFunction[id]!=-1 && callfunc_begin_i(CurrentMenuFunction[id])==1)
{
callfunc_push_int(id);
callfunc_push_int(CurrentPlid[id]);
callfunc_push_int(CurrentPage[id]);
callfunc_end();
}
menu_destroy(menu);
client_cmd(id,"%s",CurrentCommand[id]);
client_print(id,print_chat,"[AMXX] Command ^"%s^" executed with no parameters",CurrentCommand[id]);
return PLUGIN_HANDLED;
}
// We should never get here, but just incase..
menu_destroy(menu);
return PLUGIN_HANDLED;
}
/**
* Generates and displays a menu to the client for a specific command.
*
* @param id The client to display the menu to.
* @param cid The command id to display.
*/
stock DisplaySpecificCommand(id,cid)
{
new CommandName[64];
new CommandDesc[128];
new CommandTitle[256];
new CommandAccess;
new Menu;
get_concmd(cid,CommandName,sizeof(CommandName)-1,CommandAccess, CommandDesc,sizeof(CommandDesc)-1, -1, -1);
if (CommandDesc[0]!='^0')
{
formatex(CommandTitle,sizeof(CommandTitle)-1,"%s^n%s",CommandName,CommandDesc);
Menu=menu_create(CommandTitle,"SpecificCommandHandler");
}
else
{
Menu=menu_create(CommandName,"SpecificCommandHandler");
}
menu_additem(Menu,"Execute with parameters.",CommandName,_,EnabledCallback);
menu_additem(Menu,"Execute with no parameters.",CommandName,_,EnabledCallback);
menu_setprop(Menu,MPROP_NUMBER_COLOR,"\y");
menu_display(id,Menu,0);
}
/**
* Handles the executed command (via "amx_executecmd").
*
* @param id The id of the client who executed this.
*/
public CommandExecuteCommand(id)
{
// If they had no command stored, then just ignore it entirely.
if (CurrentCommand[id][0]=='^0')
{
return PLUGIN_CONTINUE;
}
new Args[256];
read_args(Args,sizeof(Args)-1);
remove_quotes(Args);
if (equali(Args,"!cancel",7))
{
// The client didn't want to execute this command.
client_print(id,print_chat,"[AMXX] Command not executed.");
// Now redraw the menu for the client
if (CurrentMenuFunction[id]!=-1 && callfunc_begin_i(CurrentMenuFunction[id])==1)
{
callfunc_push_int(id);
callfunc_push_int(CurrentPlid[id]);
callfunc_push_int(CurrentPage[id]);
callfunc_end();
}
}
else
{
// TODO: ML
client_print(id,print_chat,"[AMXX] Command ^"%s^" executed with ^"%s^"",CurrentCommand[id],Args);
// Now redraw the menu for the client
if (CurrentMenuFunction[id]!=-1 && callfunc_begin_i(CurrentMenuFunction[id])==1)
{
callfunc_push_int(id);
callfunc_push_int(CurrentPlid[id]);
callfunc_push_int(CurrentPage[id]);
callfunc_end();
}
// Execute the command on the client.
client_cmd(id,"%s %s",CurrentCommand[id],Args);
}
return PLUGIN_HANDLED;
}
/**
* Handle a specific selection from the command menu.
*
* @param id id of the client who made the selection.
* @param menu The menu handle.
* @param item The item that was selected.
*/
public CommandMenuSelection(id, menu, item)
{
if (item==MENU_EXIT)
{
menu_destroy(menu);
// If the player did not explicitly specify a plugin, return them to the
// plugin selection menu.
if (ExplicitPlugin[id]==-1)
{
client_cmd(id,"amx_plugincmdmenu");
}
return PLUGIN_HANDLED;
}
else if (item==MENU_BACK)
{
--CurrentPage[id];
client_print(id,print_chat,"MENU_BACK");
return PLUGIN_HANDLED;
}
else if (item==MENU_MORE)
{
++CurrentPage[id];
client_print(id,print_chat,"MENU_MORE");
return PLUGIN_HANDLED;
}
else
{
new Command[32];
new Dummy[1];
// pcvar pointer is stored in command, extract the name of the cvar from the name field.
menu_item_getinfo(menu, item, Dummy[0], Command, sizeof(Command)-1,"",0,Dummy[0]);
menu_destroy(menu);
DisplaySpecificCommand(id,str_to_num(Command));
return PLUGIN_HANDLED;
}
return 0;
}
/**
* This blocks "say" and "say_team" commands.
* Other commands that shouldn't be displayed (eg: amxauth<stuff>) should be filtered out already.
*
* @param Command The command that is being checked.
*/
stock bool:IsDisplayableCmd(const Command[])
{
// Block "say" and "say_team"
if (equal(Command,"say",3))
{
return false;
}
return true;
}
/**
* Displays a command list for the specified plugin.
*
* @param id Id of the client that's being displayed to.
* @param plid Plugin ID of the plugin that is to be displayed.
* @param page The page to start at.
*/
public DisplayCmdMenu(id, plid, page)
{
new PluginName[32];
new MenuTitle[64];
get_plugin(plid,"",0,PluginName,sizeof(PluginName)-1,"",0,"",0,"",0);
formatex(MenuTitle,sizeof(MenuTitle)-1,"%s Commands:",PluginName);
new Menu=menu_create(MenuTitle,"CommandMenuSelection");
new Command[64];
new CidString[32];
new CommandAccess;
new userflags=get_user_flags(id);
new bool:isadmin=bool:is_user_admin(id);
for (new i=0, max=get_concmdsnum(-1,-1);
i<max;
i++)
{
if (get_concmd_plid(i,-1,-1)==plid)
{
get_concmd(i,Command,sizeof(Command)-1,CommandAccess, "",0, -1, -1);
if (IsDisplayableCmd(Command))
{
if ( userflags & CommandAccess ||
(CommandAccess==ADMIN_ADMIN && isadmin) ||
CommandAccess==ADMIN_USER ||
CommandAccess==ADMIN_ALL)
{
num_to_str(i,CidString,sizeof(CidString)-1);
menu_additem(Menu,Command,CidString,0,EnabledCallback);
}
else
{
menu_additem(Menu,Command,"",0,DisabledCallback);
}
}
}
}
menu_setprop(Menu,MPROP_NUMBER_COLOR,"\y");
menu_display(id,Menu,page);
}
/**
* Handles the "amx_plugincmdmenu" command.
*
* @param id Id of the client that's being checked.
* @param level Access level of the command.
* @param cid Command ID of the command that was executed.
*/
public CommandMenuCommand(id, level, cid)
{
if (!cmd_access(id,level,cid,0))
{
return PLUGIN_HANDLED;
}
// This is which plugin to display. -1 means display all plugins in a list.
new plid=-1;
if (GetPlidForValidPlugins(id,plid)!=true)
{
// If GetPlidForValidPlugins returns false then it failed to find the plugin.
return PLUGIN_HANDLED;
}
// Check if we were passed a specific plugin to display or not.
if (plid==-1)
{
// We need to display a list of the plugins, instead of a specific plugin.
ExplicitPlugin[id]=-1;
DisplayPluginMenu(id,"Plugin Command Menu:", "PluginMenuSelection","DisplayCmdMenu","GetNumberOfCmdsForPlid");
}
else
{
ExplicitPlugin[id]=plid;
CurrentPlid[id]=plid;
CurrentPage[id]=0;
DisplayCmdMenu(id,plid,0);
}
return PLUGIN_HANDLED;
}

View File

@@ -0,0 +1,983 @@
/* AMX Mod X
* Restrict Weapons Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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.
*/
// Uncomment if you want to have seperate settings for each map
//#define MAPSETTINGS
#include <amxmodx>
#include <amxmisc>
#define MAXMENUPOS 34
new g_Position[33]
new g_Modified
new g_blockPos[112]
new g_saveFile[64]
new g_Restricted[] = "* This item is restricted *"
new g_szWeapRestr[27] = "00000000000000000000000000"
new g_szEquipAmmoRestr[10] = "000000000"
new g_InBuyMenu[33]
new g_RegisteredMenus[10]
new g_menuStrings[6][] =
{
"BuyPistol",
"BuyShotgun",
"BuySubMachineGun",
"BuyRifle",
"BuyMachineGun",
"BuyItem"
}
new g_menusNames[7][] =
{
"pistol",
"shotgun",
"sub",
"rifle",
"machine",
"equip",
"ammo"
}
new g_MenuTitle[7][] =
{
"Handguns",
"Shotguns",
"Sub-Machine Guns",
"Assault & Sniper Rifles",
"Machine Guns",
"Equipment",
"Ammunition"
}
new g_menusSets[7][2] =
{
{0, 6}, {6, 8}, {8, 13}, {13, 23}, {23, 24}, {24, 32}, {32, 34}
}
new g_AliasBlockNum
new g_AliasBlock[MAXMENUPOS]
// First position is a position of menu (0 for ammo, 1 for pistols, 6 for equipment etc.)
// Second is a key for TERRORIST (all is key are minus one, 1 is 0, 2 is 1 etc.)
// Third is a key for CT
// Position with -1 doesn't exist
new g_Keys[MAXMENUPOS][3] =
{
{1, 1, 1}, // H&K USP .45 Tactical
{1, 0, 0}, // Glock18 Select Fire
{1, 3, 3}, // Desert Eagle .50AE
{1, 2, 2}, // SIG P228
{1, 4, -1}, // Dual Beretta 96G Elite
{1, -1, 4}, // FN Five-Seven
{2, 0, 0}, // Benelli M3 Super90
{2, 1, 1}, // Benelli XM1014
{3, 1, 1}, // H&K MP5-Navy
{3, -1, 0}, // Steyr Tactical Machine Pistol
{3, 3, 3}, // FN P90
{3, 0, -1}, // Ingram MAC-10
{3, 2, 2}, // H&K UMP45
{4, 1, -1}, // AK-47
{4, 0, -1}, // Gali
{4, -1, 0}, // Famas
{4, 3, -1}, // Sig SG-552 Commando
{4, -1, 2}, // Colt M4A1 Carbine
{4, -1, 3}, // Steyr Aug
{4, 2, 1}, // Steyr Scout
{4, 4, 5}, // AI Arctic Warfare/Magnum
{4, 5, -1}, // H&K G3/SG-1 Sniper Rifle
{4, -1, 4}, // Sig SG-550 Sniper
{5, 0, 0}, // FN M249 Para
{6, 0, 0}, // Kevlar Vest
{6, 1, 1}, // Kevlar Vest & Helmet
{6, 2, 2}, // Flashbang
{6, 3, 3}, // HE Grenade
{6, 4, 4}, // Smoke Grenade
{6, -1, 6}, // Defuse Kit
{6, 5, 5}, // NightVision Goggles
{6, -1, 7}, // Tactical Shield
{0, 5, 5}, // Primary weapon ammo
{0, 6, 6} // Secondary weapon ammo
}
new g_WeaponNames[MAXMENUPOS][] =
{
"H&K USP .45 Tactical",
"Glock18 Select Fire",
"Desert Eagle .50AE",
"SIG P228",
"Dual Beretta 96G Elite",
"FN Five-Seven",
"Benelli M3 Super90",
"Benelli XM1014",
"H&K MP5-Navy",
"Steyr Tactical Machine Pistol",
"FN P90",
"Ingram MAC-10",
"H&K UMP45",
"AK-47",
"Gali",
"Famas",
"Sig SG-552 Commando",
"Colt M4A1 Carbine",
"Steyr Aug",
"Steyr Scout",
"AI Arctic Warfare/Magnum",
"H&K G3/SG-1 Sniper Rifle",
"Sig SG-550 Sniper",
"FN M249 Para",
"Kevlar Vest",
"Kevlar Vest & Helmet",
"Flashbang",
"HE Grenade",
"Smoke Grenade",
"Defuse Kit",
"NightVision Goggles",
"Tactical Shield",
"Primary weapon ammo",
"Secondary weapon ammo"
}
new g_MenuItem[MAXMENUPOS][] =
{
"\yHandguns^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w^n",
"\yShotguns^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w^n",
"\ySub-Machine Guns^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w^n",
"\yAssault Rifles^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w^n",
"\ySniper Rifles^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w^n",
"\yMachine Guns^n\w^n%d. %s\y\R%L^n\w^n",
"\yEquipment^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w^n",
"\yAmmunition^n\w^n%d. %s\y\R%L^n\w",
"%d. %s\y\R%L^n\w"
}
new g_Aliases[MAXMENUPOS][] =
{
"usp", //Pistols
"glock",
"deagle",
"p228",
"elites",
"fn57",
"m3", //Shotguns
"xm1014",
"mp5", //SMG
"tmp",
"p90",
"mac10",
"ump45",
"ak47", //Rifles
"galil",
"famas",
"sg552",
"m4a1",
"aug",
"scout",
"awp",
"g3sg1",
"sg550",
"m249", //Machine Gun
"vest", //Equipment
"vesthelm",
"flash",
"hegren",
"sgren",
"defuser",
"nvgs",
"shield",
"primammo", //Ammo
"secammo"
}
new g_Aliases2[MAXMENUPOS][] =
{
"km45", //Pistols
"9x19mm",
"nighthawk",
"228compact",
"elites",
"fiveseven",
"12gauge", //Shotguns
"autoshotgun",
"smg", //SMG
"mp",
"c90",
"mac10",
"ump45",
"cv47", //Rifles
"defender",
"clarion",
"krieg552",
"m4a1",
"bullpup",
"scout",
"magnum",
"d3au1",
"krieg550",
"m249", //Machine Gun
"vest", //Equipment
"vesthelm",
"flash",
"hegren",
"sgren",
"defuser",
"nvgs",
"shield",
"primammo", //Ammo
"secammo"
}
#define AUTOBUYLENGTH 511
new g_Autobuy[33][AUTOBUYLENGTH + 1]
//new g_Rebuy[33][AUTOBUYLENGTH + 1]
bool:IsOurMenuID(id)
{
for (new i=1; i<=g_RegisteredMenus[0]; i++)
{
if (g_RegisteredMenus[i] == id)
{
return true
}
}
return false
}
setWeapon(a, action)
{
new b, m = g_Keys[a][0] * 8
if (g_Keys[a][1] != -1)
{
b = m + g_Keys[a][1]
if (action == 2)
g_blockPos[b] = 1 - g_blockPos[b]
else
g_blockPos[b] = action
}
if (g_Keys[a][2] != -1)
{
b = m + g_Keys[a][2] + 56
if (action == 2)
g_blockPos[b] = 1 - g_blockPos[b]
else
g_blockPos[b] = action
}
for (new i = 0; i < g_AliasBlockNum; ++i)
if (g_AliasBlock[i] == a)
{
if (!action || action == 2)
{
--g_AliasBlockNum
for (new j = i; j < g_AliasBlockNum; ++j)
g_AliasBlock[j] = g_AliasBlock[j + 1]
}
return
}
if (action && g_AliasBlockNum < MAXMENUPOS)
g_AliasBlock[g_AliasBlockNum++] = a
}
findMenuId(name[])
{
for (new i = 0; i < 7 ; ++i)
if (equali(name, g_menusNames[i]))
return i
return -1
}
findAliasId(name[])
{
for (new i = 0; i < MAXMENUPOS ; ++i)
if (equali(name, g_Aliases[i]))
return i
return -1
}
switchCommand(id, action)
{
new c = read_argc()
if (c < 3)
{
for (new x = 0; x < MAXMENUPOS; x++)
setWeapon(x, action)
console_print(id, "%L", id, action ? "EQ_WE_RES" : "EQ_WE_UNRES")
g_Modified = true
} else {
new arg[32], a
new bool:found = false
for (new b = 2; b < c; ++b)
{
read_argv(b, arg, 31)
if ((a = findMenuId(arg)) != -1)
{
c = g_menusSets[a][1]
for (new i = g_menusSets[a][0]; i < c; ++i)
setWeapon(i, action)
console_print(id, "%s %L %L", g_MenuTitle[a], id, (a < 5) ? "HAVE_BEEN" : "HAS_BEEN", id, action ? "RESTRICTED" : "UNRESTRICTED")
g_Modified = found = true
}
else if ((a = findAliasId(arg)) != -1)
{
g_Modified = found = true
setWeapon(a, action)
console_print(id, "%s %L %L", g_WeaponNames[a], id, "HAS_BEEN", id, action ? "RESTRICTED" : "UNRESTRICTED")
}
}
if (!found)
console_print(id, "%L", id, "NO_EQ_WE")
}
}
positionBlocked(a)
{
new m = g_Keys[a][0] * 8
new d = (g_Keys[a][1] == -1) ? 0 : g_blockPos[m + g_Keys[a][1]]
d += (g_Keys[a][2] == -1) ? 0 : g_blockPos[m + g_Keys[a][2] + 56]
return d
}
public cmdRest(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new cmd[8]
read_argv(1, cmd, 7)
if (equali("on", cmd))
switchCommand(id, 1)
else if (equali("off", cmd))
switchCommand(id, 0)
else if (equali("list", cmd))
{
new arg1[8]
new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1
if (--start < 0)
start = 0
if (start >= MAXMENUPOS)
start = MAXMENUPOS - 1
new end = start + 10
if (end > MAXMENUPOS)
end = MAXMENUPOS
new lName[16], lValue[16], lStatus[16], lOnOff[16]
format(lName, 15, "%L", id, "NAME")
format(lValue, 15, "%L", id, "VALUE")
format(lStatus, 15, "%L", id, "STATUS")
console_print(id, "^n----- %L: -----", id, "WEAP_RES")
console_print(id, " %-32.31s %-10.9s %-9.8s", lName, lValue, lStatus)
if (start != -1)
{
for (new a = start; a < end; ++a)
{
format(lOnOff, 15, "%L", id, positionBlocked(a) ? "ON" : "OFF")
console_print(id, "%3d: %-32.31s %-10.9s %-9.8s", a + 1, g_WeaponNames[a], g_Aliases[a], lOnOff)
}
}
console_print(id, "----- %L -----", id, "REST_ENTRIES_OF", start + 1, end, MAXMENUPOS)
if (end < MAXMENUPOS)
console_print(id, "----- %L -----", id, "REST_USE_MORE", end + 1)
else
console_print(id, "----- %L -----", id, "REST_USE_BEGIN")
}
else if (equali("save", cmd))
{
if (saveSettings(g_saveFile))
{
console_print(id, "%L", id, "REST_CONF_SAVED", g_saveFile)
g_Modified = false
}
else
console_print(id, "%L", id, "REST_COULDNT_SAVE", g_saveFile)
}
else if (equali("load", cmd))
{
setc(g_blockPos, 112, 0) // Clear current settings
new arg1[64]
if (read_argv(2, arg1, 63))
{
new configsdir[32]
get_configsdir(configsdir, 31)
format(arg1, 63, "%s/%s", configsdir, arg1)
}
if (loadSettings(arg1))
{
console_print(id, "%L", id, "REST_CONF_LOADED", arg1)
g_Modified = true
}
else
console_print(id, "%L", id, "REST_COULDNT_LOAD", arg1)
} else {
console_print(id, "%L", id, "COM_REST_USAGE")
console_print(id, "%L", id, "COM_REST_COMMANDS")
console_print(id, "%L", id, "COM_REST_ON")
console_print(id, "%L", id, "COM_REST_OFF")
console_print(id, "%L", id, "COM_REST_ONV")
console_print(id, "%L", id, "COM_REST_OFFV")
console_print(id, "%L", id, "COM_REST_LIST")
console_print(id, "%L", id, "COM_REST_SAVE")
console_print(id, "%L", id, "COM_REST_LOAD")
console_print(id, "%L", id, "COM_REST_VALUES")
console_print(id, "%L", id, "COM_REST_TYPE")
}
return PLUGIN_HANDLED
}
displayMenu(id, pos)
{
if (pos < 0)
return
new menubody[512], start = pos * 7
if (start >= MAXMENUPOS)
start = pos = g_Position[id] = 0
new len = format(menubody, 511, "\y%L\R%d/5^n^n\w", id, "REST_WEAP", pos + 1)
new end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0
if (end > MAXMENUPOS)
end = MAXMENUPOS
for (new a = start; a < end; ++a)
{
keys |= (1<<k)
len += format(menubody[len], 511 - len, g_MenuItem[a], ++k, g_WeaponNames[a], id, positionBlocked(a) ? "ON" : "OFF")
}
len += format(menubody[len], 511 - len, "^n8. %L \y\R%s^n\w", id, "SAVE_SET", g_Modified ? "*" : "")
if (end != MAXMENUPOS)
{
format(menubody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menubody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menubody, -1, "Restrict Weapons")
}
public actionMenu(id, key)
{
switch (key)
{
case 7:
{
if (saveSettings(g_saveFile))
{
g_Modified = false
client_print(id, print_chat, "* %L", id, "CONF_SAV_SUC")
}
else
client_print(id, print_chat, "* %L", id, "CONF_SAV_FAIL")
displayMenu(id, g_Position[id])
}
case 8: displayMenu(id, ++g_Position[id])
case 9: displayMenu(id, --g_Position[id])
default:
{
setWeapon(g_Position[id] * 7 + key, 2)
g_Modified = true
displayMenu(id, g_Position[id])
new a = g_Position[id] * 7 + key
new sz[1]
if (a < 24)
{
sz[0] = g_szWeapRestr[a + 1]
g_szWeapRestr[a + 1] = (sz[0] == '0') ? '1' : '0' // primary and secondary weapons
}
else if ((a >= 24) && (a < 31))
{
sz[0] = g_szEquipAmmoRestr[a - 24]
g_szEquipAmmoRestr[a - 24] = (sz[0] == '0') ? '1' : '0' // equipments
}
else if (a == 31)
{
sz[0] = g_szWeapRestr[25]
g_szWeapRestr[25] = (sz[0] == '0') ? '1' : '0' // shield
}
else if ((a > 31) && (a < 34))
{
sz[0] = g_szEquipAmmoRestr[a - 25]
g_szEquipAmmoRestr[a - 25] = (sz[0] == '0') ? '1' : '0' // primary and secondary ammo
}
set_cvar_string("amx_restrweapons", g_szWeapRestr)
set_cvar_string("amx_restrequipammo", g_szEquipAmmoRestr)
}
}
return PLUGIN_HANDLED
}
public CS_InternalCommand(id, const cmd[])
{
new a = 0
do
{
if (equali(g_Aliases[g_AliasBlock[a]], cmd) || equali(g_Aliases2[g_AliasBlock[a]], cmd))
{
client_print(id, print_center, "%s", g_Restricted)
return PLUGIN_HANDLED
}
} while (++a < g_AliasBlockNum)
return PLUGIN_CONTINUE
}
public client_command(id)
{
if (g_AliasBlockNum)
{
new arg[13]
if (read_argv(0, arg, 12) > 11) /* Longest buy command has 11 chars so if command is longer then don't care */
{
return PLUGIN_CONTINUE
}
if (equali(arg, "menuselect") && is_user_connected(id))
{
new menu, newmenu
new inMenu = player_menu_info(id, menu, newmenu)
if (!inMenu && g_InBuyMenu[id])
{
new key[12], num
read_argv(1, key, 11)
num = str_to_num(key) - 1
return checkRest(id, g_InBuyMenu[id], num)
} else if ((!menu || newmenu != -1)
|| !IsOurMenuID(menu)) {
g_InBuyMenu[id] = 0
}
return PLUGIN_CONTINUE
}
new a = 0
do
{
if (equali(g_Aliases[g_AliasBlock[a]], arg) || equali(g_Aliases2[g_AliasBlock[a]], arg))
{
client_print(id, print_center, "%s", g_Restricted)
return PLUGIN_HANDLED
}
} while (++a < g_AliasBlockNum)
}
return PLUGIN_CONTINUE
}
public blockcommand(id)
{
client_print(id, print_center, "%s", g_Restricted)
return PLUGIN_HANDLED
}
public cmdMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
{
displayMenu(id, g_Position[id] = 0)
}
return PLUGIN_HANDLED
}
checkRest(id, menu, key)
{
new team = get_user_team(id)
if (team != 1 && team != 2)
{
return PLUGIN_HANDLED
}
new pos = (menu * 8 + key) + (get_user_team(id) - 1) * 56
if (pos < 0 || pos >= 112)
{
return PLUGIN_CONTINUE
}
if (g_blockPos[pos])
{
engclient_cmd(id, "menuselect", "10")
client_print(id, print_center, "%s", g_Restricted)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public ammoRest1(id) return checkRest(id, 0, 5)
public ammoRest2(id) return checkRest(id, 0, 6)
public menuBuy(id, key) return checkRest(id, 0, key)
public menuPistol(id, key) return checkRest(id, 1, key)
public menuShotgun(id, key) return checkRest(id, 2, key)
public menuSub(id, key) return checkRest(id, 3, key)
public menuRifle(id, key) return checkRest(id, 4, key)
public menuMachine(id, key) return checkRest(id, 5, key)
public menuItem(id, key) return checkRest(id, 6, key)
saveSettings(filename[])
{
if (file_exists(filename))
delete_file(filename)
if (!write_file(filename, "; Generated by Restrict Weapons Plugin. Do not modify!^n; value name"))
return 0
new text[64]
for (new a = 0; a < MAXMENUPOS; ++a)
{
if (positionBlocked(a))
{
format(text, 63, "%-16.15s ; %s", g_Aliases[a], g_WeaponNames[a])
write_file(filename, text)
}
}
return 1
}
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new text[16]
new a, pos = 0
format(g_szEquipAmmoRestr, 9, "000000000")
format(g_szWeapRestr, 26, "00000000000000000000000000")
while (read_file(filename, pos++, text, 15, a))
{
if (text[0] == ';' || !a)
continue // line is a comment
parse(text, text, 15)
if ((a = findAliasId(text)) != -1)
{
setWeapon(a, 1)
if (a < 24) g_szWeapRestr[a + 1] = '1' // primary and secondary weapons
else if ((a >= 24) && (a < 31)) g_szEquipAmmoRestr[a - 24] = '1' // equipments
else if (a == 31) g_szWeapRestr[25] = '1' // shield
else if ((a > 31) && (a < 34)) g_szEquipAmmoRestr[a - 25] = '1' // primary and secondary ammo
}
}
set_cvar_string("amx_restrweapons", g_szWeapRestr)
set_cvar_string("amx_restrequipammo", g_szEquipAmmoRestr)
return 1
}
// JGHG
public fn_setautobuy(id)
{
// Empty user's autobuy prefs. (unnecessary?)
g_Autobuy[id][0] = '^0'
new argCount = read_argc()
new arg[128]
new autobuyLen = 0
for (new i = 1; i < argCount; i++) // Start at parameter 1; parameter 0 is just "cl_setautobuy"
{
read_argv(i, arg, 127)
// Add this parameter to user's autobuy prefs
autobuyLen += format(g_Autobuy[id][autobuyLen], AUTOBUYLENGTH - autobuyLen, "%s", arg)
// If we detect more parameters, add a space
if (i + 1 < argCount)
autobuyLen += format(g_Autobuy[id][autobuyLen], AUTOBUYLENGTH - autobuyLen, " ")
}
if (g_AliasBlockNum)
{
// Strip any blocked items
new strippedItems[AUTOBUYLENGTH + 1]
if (!StripBlockedItems(g_Autobuy[id], strippedItems))
return PLUGIN_CONTINUE // don't touch anything if we didn't strip anything...
//server_print("Stripped items: ^"%s^"", strippedItems)
engclient_cmd(id, "cl_setautobuy", strippedItems)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Returns true if this strips any items, else false.
StripBlockedItems(inString[AUTOBUYLENGTH + 1], outString[AUTOBUYLENGTH + 1])
{
// First copy string
format(outString, AUTOBUYLENGTH, inString)
// After that convert all chars in string to lower case (fix by VEN)
strtolower(outString)
// Then strip those that are blocked.
for (new i = 0; i < g_AliasBlockNum; i++)
{
while (containi(outString, g_Aliases[g_AliasBlock[i]]) != -1)
replace(outString, AUTOBUYLENGTH, g_Aliases[g_AliasBlock[i]], "")
while (containi(outString, g_Aliases2[g_AliasBlock[i]]) != -1)
replace(outString, AUTOBUYLENGTH, g_Aliases2[g_AliasBlock[i]], "")
}
// We COULD trim white space from outString here, but I don't think it really is necessary currently...
if (strlen(outString) < strlen(inString))
return true // outstring is shorter: we stripped items, return true
return false // else end here, return false, no items were stripped
}
public fn_autobuy(id)
{
// Don't do anything if no items are blocked.
if (!g_AliasBlockNum)
return PLUGIN_CONTINUE
// Strip any blocked items
new strippedItems[AUTOBUYLENGTH + 1]
if (!StripBlockedItems(g_Autobuy[id], strippedItems))
return PLUGIN_CONTINUE // don't touch anything if we didn't strip anything...
engclient_cmd(id, "cl_setautobuy", strippedItems)
return PLUGIN_HANDLED
}
public HookEvent_ShowMenu(id)
{
new menustring[24]
read_data(4, menustring, 23)
/* Early breakouts */
new curidx
if (menustring[curidx++] != '#')
{
g_InBuyMenu[id] = 0
return
}
/* Strip D */
if (menustring[curidx] == 'D')
{
curidx++
}
/* Strip AS_ */
if (menustring[curidx] == 'A'
&& menustring[curidx+1] == 'S'
&& menustring[curidx+2] == '_')
{
curidx += 3
}
/* Strip any team tags */
if (menustring[curidx] == 'C'
&& menustring[curidx+1] == 'T'
&& menustring[curidx+2] == '_')
{
curidx += 3
} else if (menustring[curidx] == 'T'
&& menustring[curidx+1] == '_') {
curidx += 2
}
if (menustring[curidx] != 'B')
{
g_InBuyMenu[id] = 0
return
}
for (new i=0; i<6; i++)
{
if (equali(menustring[curidx], g_menuStrings[i]))
{
g_InBuyMenu[id] = i+1
return
}
}
g_InBuyMenu[id] = 0
}
RegisterMenuID(const menuname[])
{
new id = register_menuid(menuname, 1)
g_RegisteredMenus[++g_RegisteredMenus[0]] = id
return id
}
public plugin_init()
{
register_plugin("Restrict Weapons", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("restmenu.txt")
register_dictionary("common.txt")
register_clcmd("buyammo1", "ammoRest1")
register_clcmd("buyammo2", "ammoRest2")
register_clcmd("cl_setautobuy", "fn_setautobuy")
register_clcmd("cl_autobuy", "fn_autobuy")
register_clcmd("amx_restmenu", "cmdMenu", ADMIN_CFG, "- displays weapons restriction menu")
register_menucmd(register_menuid("#Buy", 1), 511, "menuBuy")
register_menucmd(register_menuid("Restrict Weapons"), 1023, "actionMenu")
register_menucmd(RegisterMenuID("BuyPistol"), 511, "menuPistol")
register_menucmd(RegisterMenuID("BuyShotgun"), 511, "menuShotgun")
register_menucmd(RegisterMenuID("BuySub"), 511, "menuSub")
register_menucmd(RegisterMenuID("BuyRifle"), 511, "menuRifle")
register_menucmd(RegisterMenuID("BuyMachine"), 511, "menuMachine")
register_menucmd(RegisterMenuID("BuyItem"), 511, "menuItem")
register_menucmd(-28, 511, "menuBuy")
register_menucmd(-29, 511, "menuPistol")
register_menucmd(-30, 511, "menuShotgun")
register_menucmd(-32, 511, "menuSub")
register_menucmd(-31, 511, "menuRifle")
register_menucmd(-33, 511, "menuMachine")
register_menucmd(-34, 511, "menuItem")
register_concmd("amx_restrict", "cmdRest", ADMIN_CFG, "- displays help for weapons restriction")
register_cvar("amx_restrweapons", "00000000000000000000000000")
register_cvar("amx_restrequipammo", "000000000")
register_event("ShowMenu", "HookEvent_ShowMenu", "b")
new configsDir[64];
get_configsdir(configsDir, 63);
#if defined MAPSETTINGS
new mapname[32]
get_mapname(mapname, 31)
format(g_saveFile, 63, "%s/weaprest_%s.ini", configsDir, mapname)
#else
format(g_saveFile, 63, "%s/weaprest.ini", configsDir)
#endif
loadSettings(g_saveFile)
}

View File

@@ -0,0 +1,128 @@
/* AMX Mod X
* Scrolling Message Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
#define SPEED 0.3
#define SCROLLMSG_SIZE 512
new g_startPos
new g_endPos
new g_scrollMsg[SCROLLMSG_SIZE]
new g_displayMsg[SCROLLMSG_SIZE]
new Float:g_xPos
new g_Length
new g_Frequency
public plugin_init()
{
register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("scrollmsg.txt")
register_dictionary("common.txt")
register_srvcmd("amx_scrollmsg", "setMessage")
}
public showMsg()
{
new a = g_startPos, i = 0
while (a < g_endPos)
g_displayMsg[i++] = g_scrollMsg[a++]
g_displayMsg[i] = 0
if (g_endPos < g_Length)
g_endPos++
if (g_xPos > 0.35)
g_xPos -= 0.0063
else
{
g_startPos++
g_xPos = 0.35
}
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
show_hudmessage(0, "%s", g_displayMsg)
}
public msgInit()
{
g_endPos = 1
g_startPos = 0
g_xPos = 0.65
new hostname[64]
get_cvar_string("hostname", hostname, 63)
replace(g_scrollMsg, SCROLLMSG_SIZE-1, "%hostname%", hostname)
g_Length = strlen(g_scrollMsg)
set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48)
client_print(0, print_console, "%s", g_scrollMsg)
}
public setMessage()
{
remove_task(123) /* remove current messaging */
read_argv(1, g_scrollMsg, SCROLLMSG_SIZE-1)
g_Length = strlen(g_scrollMsg)
new mytime[32]
read_argv(2, mytime, 31)
g_Frequency = str_to_num(mytime)
if (g_Frequency > 0)
{
new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
if (g_Frequency < minimal)
{
server_print("%L", LANG_SERVER, "MIN_FREQ", minimal)
g_Frequency = minimal
}
server_print("%L", LANG_SERVER, "MSG_FREQ", g_Frequency / 60, g_Frequency % 60)
set_task(float(g_Frequency), "msgInit", 123, "", 0, "b")
}
else
server_print("%L", LANG_SERVER, "MSG_DISABLED")
return PLUGIN_HANDLED
}

View File

@@ -0,0 +1,112 @@
/* AMX Mod X
* Stats Logging Plugin
*
* by the AMX Mod X Development Team
* originally developed by JustinHoMi
*
* 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 <csx>
new g_pingSum[33]
new g_pingCount[33]
new g_inGame[33]
public plugin_init()
{
register_plugin("CS Stats Logging", AMXX_VERSION_STR, "AMXX Dev Team")
}
public client_disconnect(id)
{
if (!g_inGame[id])
return
g_inGame[id] = 0
if (is_user_bot(id))
{
return
}
remove_task(id)
new szTeam[16], szName[32], szAuthid[32], iStats[8], iHits[8], szWeapon[24]
new iUserid = get_user_userid(id)
new _max = xmod_get_maxweapons()
get_user_team(id, szTeam, 15)
get_user_name(id, szName, 31)
get_user_authid(id, szAuthid, 31)
for (new i = 1 ; i < _max ; ++i)
{
if (get_user_wstats(id, i, iStats, iHits))
{
xmod_get_wpnname(i, szWeapon, 23)
log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^")",
szName, iUserid, szAuthid, szTeam, szWeapon, iStats[4], iStats[5], iStats[0], iStats[2], iStats[3], iStats[6], iStats[1])
log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats2^" (weapon ^"%s^") (head ^"%d^") (chest ^"%d^") (stomach ^"%d^") (leftarm ^"%d^") (rightarm ^"%d^") (leftleg ^"%d^") (rightleg ^"%d^")",
szName, iUserid, szAuthid, szTeam, szWeapon, iHits[1], iHits[2], iHits[3], iHits[4], iHits[5], iHits[6], iHits[7])
}
}
new iTime = get_user_time(id, 1)
log_message("^"%s<%d><%s><%s>^" triggered ^"time^" (time ^"%d:%02d^")", szName, iUserid, szAuthid, szTeam, (iTime / 60), (iTime % 60))
log_message("^"%s<%d><%s><%s>^" triggered ^"latency^" (ping ^"%d^")", szName, iUserid, szAuthid, szTeam, (g_pingSum[id] / (g_pingCount[id] ? g_pingCount[id] : 1)))
}
public client_connect(id)
{
g_inGame[id] = 0
}
public client_putinserver(id)
{
g_inGame[id] = 1
if (!is_user_bot(id))
{
g_pingSum[id] = g_pingCount[id] = 0
if (task_exists(id))
remove_task(id)
set_task(19.5, "getPing", id, "", 0, "b")
}
}
public getPing(id)
{
new iPing, iLoss
get_user_ping(id, iPing, iLoss)
g_pingSum[id] += iPing
++g_pingCount[id]
}

View File

@@ -0,0 +1,325 @@
/* AMX Mod X
* Stats Configuration Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
#define MAX_MENU_DATA 72
new g_menuData[MAX_MENU_DATA][32]
new g_menuDataVar[MAX_MENU_DATA][32]
new g_menuDataId[MAX_MENU_DATA]
new g_menuDataNum
new g_menuPosition[33]
new g_fileToSave[64]
new bool:g_modified
new g_coloredMenus
public plugin_precache()
{
register_clcmd("amx_statscfgmenu", "cmdCfgMenu", ADMIN_CFG, "- displays stats configuration menu")
register_dictionary("statscfg.txt")
register_dictionary("common.txt")
register_concmd("amx_statscfg", "cmdCfg", ADMIN_CFG, "- displays help for stats configuration")
}
public plugin_init()
{
register_plugin("Stats Configuration", AMXX_VERSION_STR, "AMXX Dev Team")
register_menucmd(register_menuid("Stats Configuration"), 1023, "actionCfgMenu")
get_configsdir(g_fileToSave, 63)
format(g_fileToSave, 63, "%s/stats.ini", g_fileToSave)
loadSettings(g_fileToSave)
g_coloredMenus = colored_menus()
}
public cmdCfg(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new cmds[32]
read_argv(1, cmds, 31)
new option = equali(cmds, "on") ? 1 : 0
if (!option)
option = equali(cmds, "off") ? 2 : 0
if (read_argc() > 2 && option)
{
new var[32], enabled = 0
read_argv(2, var, 31)
for (new a = 0; a < g_menuDataNum; ++a)
{
if (containi(g_menuDataVar[a], var) != -1)
{
g_modified = true
++enabled
if (option == 1)
{
set_xvar_num(g_menuDataId[a], 1)
console_print(id, "%L: %s", id, "STATS_ENABLED", g_menuData[a])
} else {
set_xvar_num(g_menuDataId[a], 0)
console_print(id, "%L: %s", id, "STATS_DISABLED", g_menuData[a])
}
}
}
if (enabled)
console_print(id, "%L", id, "TOTAL_NUM", enabled)
else
console_print(id, "%L", id, "NO_OPTION", var)
}
else if (equali(cmds, "save"))
{
if (saveSettings(g_fileToSave))
{
g_modified = false
console_print(id, "%L", id, "STATS_CONF_SAVED")
}
else
console_print(id, "%L", id, "STATS_CONF_FAILED")
}
else if (equali(cmds, "load"))
{
if (loadSettings(g_fileToSave))
{
g_modified = false
console_print(id, "%L", id, "STATS_CONF_LOADED")
}
else
console_print(id, "%L", id, "STATS_CONF_FAIL_LOAD")
}
else if (equali(cmds, "list"))
{
new arg1[8]
new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1
if (--start < 0) start = 0
if (start >= g_menuDataNum)
start = g_menuDataNum - 1
new end = start + 10
if (end > g_menuDataNum)
end = g_menuDataNum
new lName[16], lVariable[16], lStatus[16]
format(lName, 15, "%L", id, "NAME")
format(lVariable, 15, "%L", id, "VARIABLE")
format(lStatus, 15, "%L", id, "STATUS")
console_print(id, "^n----- %L: -----", id, "STATS_CONF")
console_print(id, " %-29.28s %-24.23s %-9.8s", lName, lVariable, lStatus)
if (start != -1)
{
new lOnOff[16]
for (new a = start; a < end; ++a)
{
format(lOnOff, 15, "%L", id, get_xvar_num(g_menuDataId[a]) ? "ON" : "OFF")
console_print(id, "%3d: %-29.28s %-24.23s %-9.8s", a + 1, g_menuData[a], g_menuDataVar[a], lOnOff)
}
}
console_print(id, "----- %L -----", id, "STATS_ENTRIES_OF", start + 1, end, g_menuDataNum)
if (end < g_menuDataNum)
console_print(id, "----- %L -----", id, "STATS_USE_MORE", end + 1)
else
console_print(id, "----- %L -----", id, "STATS_USE_BEGIN")
}
else if (equali(cmds, "add") && read_argc() > 3)
{
if (g_menuDataNum < MAX_MENU_DATA)
{
read_argv(2, g_menuData[g_menuDataNum], 31)
read_argv(3, g_menuDataVar[g_menuDataNum], 31)
g_menuDataId[g_menuDataNum] = get_xvar_id(g_menuDataVar[g_menuDataNum])
++g_menuDataNum
}
else
console_print(id, "%L", id, "CANT_ADD_STATS")
} else {
console_print(id, "%L", id, "COM_STATS_USAGE")
console_print(id, "%L", id, "COM_STATS_COM")
console_print(id, "%L", id, "COM_STATS_ON")
console_print(id, "%L", id, "COM_STATS_OFF")
console_print(id, "%L", id, "COM_STATS_SAVE")
console_print(id, "%L", id, "COM_STATS_LOAD")
console_print(id, "%L", id, "COM_STATS_LIST")
console_print(id, "%L", id, "COM_STATS_ADD")
}
return PLUGIN_HANDLED
}
public cmdCfgMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayCfgMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}
displayCfgMenu(id, pos)
{
if (pos < 0)
return
new menu_body[512], start = pos * 7
if (start >= g_menuDataNum)
start = pos = g_menuPosition[id] = 0
new len = format(menu_body, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "STATS_CONF", pos + 1, ((g_menuDataNum / 7)+((g_menuDataNum % 7) ? 1 : 0)))
new end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0
if (end > g_menuDataNum)
end = g_menuDataNum
for (new a = start; a < end; ++a)
{
keys |= (1<<k)
/* Backwards compatibility hack - if the name starts with ST_, assume it is translation safe! */
if (equal(g_menuData[a], "ST_", 3))
{
len += format(menu_body[len], 511-len, g_coloredMenus ? "%d. %L\y\R%L^n\w" : "%d. %L %L^n", ++k, id, g_menuData[a], id, get_xvar_num(g_menuDataId[a]) ? "ON" : "OFF")
} else {
len += format(menu_body[len], 511-len, g_coloredMenus ? "%d. %s\y\R%L^n\w" : "%d. %s %L^n", ++k, g_menuData[a], id, get_xvar_num(g_menuDataId[a]) ? "ON" : "OFF")
}
}
if (g_menuDataNum == 0)
len += format(menu_body[len], 511-len, g_coloredMenus ? "\d%L\w" : "%L", id, "NO_STATS")
len += format(menu_body[len], 511-len, g_coloredMenus ? "^n8. %L\y\R%s^n\w" : "^n8. %L %s^n", id, "SAVE_CONF", g_modified ? "*" : "")
if (end != g_menuDataNum)
{
format(menu_body[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menu_body[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menu_body, -1, "Stats Configuration")
}
public actionCfgMenu(id, key)
{
switch (key)
{
case 7:
{
if (saveSettings(g_fileToSave))
{
g_modified = false
client_print(id, print_chat, "* %L", id, "STATS_CONF_SAVED")
}
else
client_print(id, print_chat, "* %L", id, "STATS_CONF_FAILED")
displayCfgMenu(id, g_menuPosition[id])
}
case 8: displayCfgMenu(id, ++g_menuPosition[id])
case 9: displayCfgMenu(id, --g_menuPosition[id])
default:
{
g_modified = true
new a = g_menuPosition[id] * 7 + key
set_xvar_num(g_menuDataId[a], 1 - get_xvar_num(g_menuDataId[a]))
displayCfgMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
saveSettings(filename[])
{
if (file_exists(filename))
delete_file(filename)
if (!write_file(filename, ";Generated by Stats Configuration Plugin. Do not modify!^n;Variable Description"))
return 0
new text[256]
for (new a = 0; a < g_menuDataNum; ++a)
{
if (get_xvar_num(g_menuDataId[a]))
{
if (equal(g_menuData[a], "ST_", 3))
{
format(text, 255, "%-24.23s ;%L", g_menuDataVar[a], LANG_SERVER, g_menuData[a])
}
else
{
format(text, 255, "%-24.23s ;%s", g_menuDataVar[a], g_menuData[a])
}
write_file(filename, text)
}
}
return 1
}
loadSettings(filename[])
{
if (!file_exists(filename))
return 0
new text[256], name[32]
new len, pos = 0, xid
while (read_file(filename, pos++, text, 255, len))
{
if (text[0] == ';') continue // line is a comment
parse(text, name, 31)
if ((xid = get_xvar_id(name)) != -1)
set_xvar_num(xid, 1)
}
return 1
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,199 @@
/* AMX Mod X
* Teleport Menu Plugin
*
* by the AMX Mod X Development Team
* originally developed by OLO
*
* 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 <amxmisc>
#include <fun>
new g_menuPosition[33]
new g_menuPlayers[33][32]
new g_menuPlayersNum[33]
new g_menuOption[33] = {-1, ...}
new g_menuOrgin[33][3]
new g_coloredMenus
public plugin_init()
{
register_plugin("Teleport Menu", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("telemenu.txt")
register_dictionary("common.txt")
register_clcmd("amx_teleportmenu", "cmdTelMenu", ADMIN_CFG, "- displays teleport menu")
register_menucmd(register_menuid("Teleport Menu"), 1023, "actionTelMenu")
g_coloredMenus = colored_menus()
}
public actionTelMenu(id, key)
{
switch (key)
{
case 6:
{
g_menuOption[id] = 1 - g_menuOption[id]
displayTelMenu(id, g_menuPosition[id])
}
case 7:
{
if (g_menuOption[id] < 0) /* unlocking position for the first time */
g_menuOption[id] = 0
get_user_origin(id, g_menuOrgin[id])
displayTelMenu(id, g_menuPosition[id])
}
case 8: displayTelMenu(id, ++g_menuPosition[id])
case 9: displayTelMenu(id, --g_menuPosition[id])
default:
{
new player = g_menuPlayers[id][g_menuPosition[id] * 6 + key]
new name2[32]
get_user_name(player, name2, 31)
if (!is_user_alive(player))
{
client_print(id, print_chat, "%L", id, "CANT_PERF_DEAD", name2)
displayTelMenu(id, g_menuPosition[id])
return PLUGIN_HANDLED
}
if (g_menuOption[id] > 0)
{
set_user_origin(player, g_menuOrgin[id])
} else {
new origin[3]
get_user_origin(id, origin)
set_user_origin(player, origin)
}
new authid[32], authid2[32], name[32]
get_user_authid(id, authid, 31)
get_user_authid(player, authid2, 31)
get_user_name(id, name, 31)
log_amx("Cmd: ^"%s<%d><%s><>^" teleport ^"%s<%d><%s><>^"", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2)
show_activity_key("ADMIN_TELEPORT_1", "ADMIN_TELEPORT_2", name, name2);
displayTelMenu(id, g_menuPosition[id])
}
}
return PLUGIN_HANDLED
}
displayTelMenu(id, pos)
{
if (pos < 0)
return
get_players(g_menuPlayers[id], g_menuPlayersNum[id])
new menuBody[512]
new b = 0
new i
new name[32]
new start = pos * 6
new bool:blockMenu = (is_user_alive(id) && g_menuOption[id] < 1) ? true : false
if (start >= g_menuPlayersNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TELE_MENU", pos + 1, (g_menuPlayersNum[id] / 6 + ((g_menuPlayersNum[id] % 6) ? 1 : 0)))
new end = start + 6
new keys = MENU_KEY_0|MENU_KEY_8
if (end > g_menuPlayersNum[id])
end = g_menuPlayersNum[id]
for (new a = start; a < end; ++a)
{
i = g_menuPlayers[id][a]
get_user_name(i, name, 31)
if (blockMenu || !is_user_alive(i) || (id != i && get_user_flags(i) & ADMIN_IMMUNITY))
{
++b
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name)
else
len += format(menuBody[len], 511-len, "#. %s^n", name)
} else {
keys |= (1<<b)
if (is_user_admin(i))
len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*^n\w" : "%d. %s *^n", ++b, name)
else
len += format(menuBody[len], 511-len, "%d. %s^n", ++b, name)
}
}
if (g_menuOption[id] > 0) // 1
{
keys |= MENU_KEY_7
len += format(menuBody[len], 511-len, "^n7. To location: %d %d %d^n", g_menuOrgin[id][0], g_menuOrgin[id][1], g_menuOrgin[id][2])
}
else if (g_menuOption[id]) // -1
{
if (g_coloredMenus)
len += format(menuBody[len], 511-len, "^n\d7. %L^n\w", id, "CUR_LOC")
else
len += format(menuBody[len], 511-len, "^n#. %L^n", id, "CUR_LOC")
} else { // 0
keys |= MENU_KEY_7
len += format(menuBody[len], 511-len, "^n7. %L^n", id, "CUR_LOC")
}
len += format(menuBody[len], 511-len, "8. %L^n", id, "SAVE_LOC")
if (end != g_menuPlayersNum[id])
{
format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else
format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id, keys, menuBody, -1, "Teleport Menu")
}
public cmdTelMenu(id, level, cid)
{
if (cmd_access(id, level, cid, 1))
displayTelMenu(id, g_menuPosition[id] = 0)
return PLUGIN_HANDLED
}

View File

@@ -0,0 +1,123 @@
#include <amxmodx>
new __testnumber;
new errcount;
enum TestType
{
TT_Equal = 0,
TT_LessThan,
TT_GreaterThan,
TT_LessThanEqual,
TT_GreaterThanEqual,
TT_NotEqual
};
new TestWords[6][] = {
"==",
"<",
">",
"<=",
">=",
"!="
};
stock test(A,B=0,TestType:Type=TT_Equal)
{
++__testnumber;
new passed=0;
switch (Type)
{
case TT_Equal: if (A==B) passed=1;
case TT_LessThan: if (A<B) passed=1;
case TT_GreaterThan: if (A>B) passed=1;
case TT_LessThanEqual: if (A<=B) passed=1;
case TT_GreaterThanEqual: if (A>=B) passed=1;
case TT_NotEqual: if (A!=B) passed=1;
}
if (!passed)
{
log_amx("Failed test #%d (%d %s %d)",__testnumber,A,TestWords[_:Type],B);
errcount++;
}
}
public plugin_init()
{
register_srvcmd("testadmins","testadmins");
}
public testadmins()
{
new AuthData[44];
new Password[32];
new Access;
new Flags;
new id;
__testnumber=0;
errcount=0;
test(admins_num(),0);
admins_push("STEAM_0:1:23456","",read_flags("abcdefghijklmnopqrstu"),read_flags("ce"));
test(admins_num(),1);
admins_push("ABCDEFGHIJKLMNOP","abcdefghijklmnop",read_flags("z"),read_flags("a"));
test(admins_num(),2);
admins_push("ZYXWVUTSRQPONMLKJIHGFEDCBA","plop",read_flags("a"),read_flags("b"));
test(admins_num(),3);
id=0;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"STEAM_0:1:23456"),0);
test(strcmp(Password,""),0);
test(Access,read_flags("abcdefghijklmnopqrstu"));
test(Flags,read_flags("ce"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ABCDEFGHIJKLMNOP"),0);
test(strcmp(Password,"abcdefghijklmnop"),0);
test(Access,read_flags("z"));
test(Flags,read_flags("a"));
id++;
admins_lookup(id,AdminProp_Auth,AuthData,sizeof(AuthData)-1);
admins_lookup(id,AdminProp_Password,Password,sizeof(Password)-1);
Access=admins_lookup(id,AdminProp_Access);
Flags=admins_lookup(id,AdminProp_Flags);
test(strcmp(AuthData,"ZYXWVUTSRQPONMLKJIHGFEDCBA"),0);
test(strcmp(Password,"plop"),0);
test(Access,read_flags("a"));
test(Flags,read_flags("b"));
admins_flush();
test(admins_num(),0);
server_print("test complete, %d errors",errcount);
}

View File

@@ -0,0 +1,459 @@
#include <amxmodx>
new __testnumber;
new errcount;
new __testfunc[32];
new __testfuncnum;
enum TestType
{
TT_Equal = 0,
TT_LessThan,
TT_GreaterThan,
TT_LessThanEqual,
TT_GreaterThanEqual,
TT_NotEqual
};
new TestWords[6][] = {
"==",
"<",
">",
"<=",
">=",
"!="
};
stock test(A,B=0,TestType:Type=TT_Equal)
{
++__testnumber;
new passed=0;
switch (Type)
{
case TT_Equal: if (A==B) passed=1;
case TT_LessThan: if (A<B) passed=1;
case TT_GreaterThan: if (A>B) passed=1;
case TT_LessThanEqual: if (A<=B) passed=1;
case TT_GreaterThanEqual: if (A>=B) passed=1;
case TT_NotEqual: if (A!=B) passed=1;
}
if (!passed)
{
log_amx("Failed test #%d (%d %s %d)",__testnumber,A,TestWords[_:Type],B);
errcount++;
}
}
stock starttests(const startfunc[])
{
__testnumber=0;
errcount=0;
__testfuncnum=1;
server_print("Starting tests...");
formatex(__testfunc,sizeof(__testfunc)-1,"%s",startfunc);
new func[32];
formatex(func,sizeof(func)-1,"%s%d",__testfunc,__testfuncnum++);
set_task(0.1,func);
}
stock showres()
{
if (errcount==0)
{
new func[32];
formatex(func,sizeof(func)-1,"%s%d",__testfunc,__testfuncnum++);
if (get_func_id(func)==-1)
{
server_print("All tests ok!");
}
else
{
server_print("Test ok, moving on...");
set_task(0.1,func);
}
}
else
{
server_print("Test failed, aborting.");
}
}
public plugin_init()
{
register_srvcmd("arraytest","arraytest");
}
public arraytest()
{
starttests("arraytest");
}
public arraytest1()
{
server_print("Testing 1000 iterations of 1-cell arrays...");
new Float:f;
new Array:a=ArrayCreate(1);
if (a == Invalid_Array)
{
}
for (new i=0; i<1000; i++)
{
f=float(i);
ArrayPushCell(a,f);
}
new Float:r;
for (new i=0; i<1000; i++)
{
f=float(i);
r=Float:ArrayGetCell(a, i);
// This is normally bad for float "casting", but in this case it should be fine.
test(_:f, _:r);
// Reset with inversed values
new g=_:f;
g=~g;
ArraySetCell(a, i, g);
r=Float:ArrayGetCell(a,i);
test(g, _:r);
}
ArrayDestroy(a);
showres();
}
stock bool:checkarray(const a[], const b[], size)
{
while (size--)
{
if (a[size]!=b[size])
{
return false;
}
}
return true;
}
stock invarray(a[],size)
{
while (size--)
{
a[size] = ~a[size];
}
}
public arraytest2()
{
server_print("Testing 1000 iterations of 40-cell arrays...");
new Array:a=ArrayCreate(40);
new buff[40];
new buffb[40];
for (new i=0; i<1000; i++)
{
arrayset(buff,i,sizeof(buff));
ArrayPushArray(a, buff);
}
for (new i=0; i<1000; i++)
{
arrayset(buff, i, sizeof(buff));
ArrayGetArray(a, i, buffb);
test(_:checkarray(buff,buffb,sizeof(buff)),1);
// Now overwrite the array with inversed value
invarray(buff,sizeof(buff));
ArraySetArray(a, i, buff);
ArrayGetArray(a, i, buffb);
test(_:checkarray(buff,buffb,sizeof(buff)),1);
}
ArrayDestroy(a);
showres();
}
public arraytest3()
{
server_print("Testing 1000 iterations of strings...");
// The string is 10 long, the string we're trying to pass is 20 long.
new Array:a=ArrayCreate(10);
new buff[20]="1234567890abcdefghi";
new buffb[20];
for (new i=0; i<1000; i++)
{
ArrayPushString(a, buff);
}
for (new i=0; i<1000; i++)
{
ArrayGetString(a, i, buffb, sizeof(buffb)-1);
test(strcmp(buffb,"123456789"),0);
ArraySetString(a, i, "9876543210");
ArrayGetString(a, i, buffb, sizeof(buffb)-1);
test(strcmp(buffb,"987654321"),0);
buffb[0]=0;
formatex(buffb,sizeof(buffb)-1,"%S", ArrayGetStringHandle(a, i));
test(strcmp(buffb, "987654321"),0);
}
ArrayDestroy(a);
showres();
}
public sortcallback(Array:a, b, c)
{
static stra[40];
static strb[40];
ArrayGetString(a, b, stra, sizeof(stra)-1);
ArrayGetString(a, c, strb, sizeof(strb)-1);
return strcmp(stra,strb);
}
public arraytest4()
{
server_print("Testing sorting function...");
new Array:a=ArrayCreate(40);
ArrayPushString(a, "z");
ArrayPushString(a, "yz");
ArrayPushString(a, "xyz");
ArrayPushString(a, "wxyz");
ArrayPushString(a, "vwxyz");
ArrayPushString(a, "uvwxyz");
ArrayPushString(a, "tuvwxyz");
ArrayPushString(a, "stuvwxyz");
ArrayPushString(a, "rstuvwxyz");
ArrayPushString(a, "qrstuvwxyz");
ArrayPushString(a, "pqrstuvwxyz");
ArrayPushString(a, "opqrstuvwxyz");
ArrayPushString(a, "nopqrstuvwxyz");
ArrayPushString(a, "mnopqrstuvwxyz");
ArrayPushString(a, "lmnopqrstuvwxyz");
ArrayPushString(a, "klmnopqrstuvwxyz");
ArrayPushString(a, "jklmnopqrstuvwxyz");
ArrayPushString(a, "ijklmnopqrstuvwxyz");
ArrayPushString(a, "hijklmnopqrstuvwxyz");
ArrayPushString(a, "ghijklmnopqrstuvwxyz");
ArrayPushString(a, "fghijklmnopqrstuvwxyz");
ArrayPushString(a, "efghijklmnopqrstuvwxyz");
ArrayPushString(a, "defghijklmnopqrstuvwxyz");
ArrayPushString(a, "cdefghijklmnopqrstuvwxyz");
ArrayPushString(a, "bcdefghijklmnopqrstuvwxyz");
ArrayPushString(a, "abcdefghijklmnopqrstuvwxyz");
new OldSize=ArraySize(a);
ArraySort(a, "sortcallback");
test(ArraySize(a),OldSize);
new buff[40];
ArrayGetString(a,0,buff,sizeof(buff)-1);
test(strcmp(buff,"abcdefghijklmnopqrstuvwxyz"),0);
ArrayGetString(a,25,buff,sizeof(buff)-1);
test(strcmp(buff,"z"),0);
new start='a';
for (new i=0;i<OldSize;i++)
{
ArrayGetString(a,i,buff,sizeof(buff)-1)
test(buff[0],start++);
}
showres();
}
public arraytest5()
{
server_print("Testing ArrayDeleteItem()...");
new Array:a=ArrayCreate(1);
new v;
for (new i=0; i<1000; i++)
{
ArrayPushCell(a, i);
}
for (new i=ArraySize(a) - 1; i>=0 ; i--)
{
if (i % 2 == 0)
{
ArrayDeleteItem(a, i);
}
}
test(ArraySize(a), 500);
for (new i=0; i< 500; i++)
{
v=ArrayGetCell(a, i);
// All items should be incrementing odd numbers
test(((i + 1) * 2) - 1, v);
// All remaining entries should be odd
test((v & 1), 1);
}
ArrayDestroy(a);
a=ArrayCreate(1);
// Repeat the same test, but check even numbers
for (new i=0; i<1000; i++)
{
ArrayPushCell(a, i);
}
for (new i=ArraySize(a) - 1; i>=0 ; i--)
{
if (i % 2 == 1)
{
ArrayDeleteItem(a, i);
}
}
test(ArraySize(a), 500);
for (new i=0; i< 500; i++)
{
v=ArrayGetCell(a, i);
// All items should be incrementing even numbers
test(((i + 1) * 2) - 2, v);
// All remaining entries should be even
test((v & 1), 0);
}
ArrayDestroy(a);
showres();
}
public arraytest6()
{
server_print("Testing ArrayInsertCellAfter()...");
new Array:a=ArrayCreate(1);
for (new i=0; i<10;i++)
{
ArrayPushCell(a, i);
new item=ArraySize(a)-1;
for (new j=0; j<10; j++)
{
ArrayInsertCellAfter(a, item + j, j);
}
}
test(ArraySize(a), 110);
new v;
for (new i=0; i<110; i++)
{
v=ArrayGetCell(a, i);
test(v, i / 10);
for (new j=0; j<10; j++)
{
v=ArrayGetCell(a, ++i);
test(v, j);
}
}
ArrayDestroy(a);
showres();
}
public arraytest7()
{
server_print("Testing ArrayInsertCellBefore()...");
new Array:a=ArrayCreate(1);
for (new i=0; i<10;i++)
{
ArrayPushCell(a, i);
new item=ArraySize(a)-1;
for (new j=0; j<10; j++)
{
ArrayInsertCellBefore(a, item, j);
}
}
test(ArraySize(a), 110);
new v;
for (new i=0; i<110; i++)
{
for (new j=9; j>=0; j--)
{
v=ArrayGetCell(a, i++);
test(v, j);
}
v=ArrayGetCell(a, i);
test(v, (i - 10) / 10);
}
ArrayDestroy(a);
showres();
}
public arraytest8()
{
server_print("Testing ArraySwap()...");
new Array:a=ArrayCreate(1);
for (new i=0; i<10; i++)
{
ArrayPushCell(a, i);
}
for (new i=0; i<5; i++)
{
ArraySwap(a, i, (10 - (i + 1)));
}
new v;
for (new i=0; i<5; i++)
{
v=ArrayGetCell(a, i);
test(v, (10 - (i + 1)));
}
ArrayDestroy(a);
showres();
}

Some files were not shown because too many files have changed in this diff Show More