Code: Select all
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <zombie_escape>
#define MESSAGE_PREFIX "ZE"
#define VIP_FLAGS_TYPE "ce" // Dont Change This
#define VIP_PASSWORD "" // Dont Change This
#define VIP_FLAGS_ACESS "t" // VIP Flags (You Can Use More Then 1 BUT You Should Use Only One)
public plugin_init() {
register_plugin("Add VIP", "1.0", "The GaminG DeviL")
register_clcmd("say /addvip", "cmdVIPAdd", ADMIN_RCON)
register_clcmd("say_team /addvip", "cmdVIPAdd", ADMIN_RCON);
}
// Add VIP Via Chat Command
public cmdVIPAdd(id, lvl, cid)
{
if( !(cmd_access(id, lvl, cid, 0)) )
return PLUGIN_HANDLED
else
{
new iMenu = menu_create("\yAdd VIP:", "cmdVIPAddHandler")
new iPlayers[32], iNum, iPlayer, szPlayerName[32], szUserId[32]
get_players(iPlayers, iNum)
for(--iNum; iNum>=0; iNum--)
{
iPlayer = iPlayers[iNum]
get_user_name(iPlayer, szPlayerName, charsmax(szPlayerName))
formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(iPlayer))
menu_additem(iMenu, szPlayerName, szUserId, 0)
}
menu_setprop(iMenu, MPROP_NUMBER_COLOR, "\y")
menu_display(id, iMenu)
}
return PLUGIN_HANDLED
}
public cmdVIPAddHandler(id, iMenu, iItem)
{
if( iItem == MENU_EXIT )
{
menu_destroy(iMenu)
return PLUGIN_HANDLED
}
new szUserId[32], szPlayerName[32], iPlayer, iCRAP
menu_item_getinfo(iMenu, iItem, iCRAP, szUserId, charsmax(szUserId), szPlayerName, charsmax(szPlayerName), iPlayer)
if( (iPlayer = find_player("k", str_to_num(szUserId))) )
{
if(is_user_admin(iPlayer))
client_print(id, print_chat, "[%s] %s is already on users.ini! Go on it and edit him flags..", MESSAGE_PREFIX, szPlayerName)
else
{
new szAuthid[32], szAdminName[32]
get_user_authid(iPlayer, szAuthid, charsmax(szAuthid))
get_user_name(id, szAdminName, charsmax(szAdminName))
AddVIP(id, szAuthid, VIP_FLAGS_ACESS, VIP_PASSWORD, VIP_FLAGS_TYPE, szPlayerName)
ze_colored_print(iPlayer, "!g[%s]!t %s !yadded you as !gVIP!y. Next map you are !gVIP.", MESSAGE_PREFIX, szAdminName)
ze_colored_print(id, "!g[%s]!t You added !g%s <%s>!t as !gVIP!t. Next map he will be !gVIP", MESSAGE_PREFIX, szPlayerName, szAuthid)
}
}
else
ze_colored_print(id, "!g[%s]!t %s!y seems to be disconnected.", MESSAGE_PREFIX, szPlayerName)
menu_destroy(iMenu)
return PLUGIN_HANDLED
}
// CREDITS TO AMX MOD X DEVELOPMENT TEAM
AddVIP(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/ze_vips.ini", configsDir)
if (!file_exists(configsDir))
{
console_print(id, "[%s] File ^"%s^" doesn't exist.", MESSAGE_PREFIX, 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!", MESSAGE_PREFIX, 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!", MESSAGE_PREFIX, 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!", MESSAGE_PREFIX, 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
}