Member
|
01-21-2017
, 04:26
Re: zm_vip ORIGINAL file compiling problems
|
#10
|
I want to make #define VIP_SYSTEM_FILE OFF
Quote:
/* Plugin generated by AMXX-Studio */
/* -------------------------------------------------------------------------------------------------
_____ __ ___ _ __ ____ ____ ___ ____ ____
/__ / / |/ / | | / // _// __ \ |__ \ / __ \ / __ \
/ / / /|_/ / | | / / / / / /_/ / __/ / / / / / / / / /
/ /__ / / / / | |/ /_/ / / ____/ / __/ _ / /_/ /_ / /_/ /
/____//_/ /_/ |___//___//_/ /____/(_)\____/(_)\____/
BETA VERSION!!!
Zombie Plague 4.3/5.0 Addon
ZM VIP - Zombie Plague VIP addon that enables special abilities for players
and adds VIP system, status and API to server.
Official thread: https://forums.alliedmods.net/showthread.php?t=119719
Author: aaarnas
--------------------------------------------------------------------------------------------------*/
// Ignore thease. Just values for settings.
#define OFF 0
#define ON 1
#define FORCED 2
#define NEW 1
#define OLD 2
#define VAULT 1
#define VERSION "1.9.1 BETA"
// --------------- USER CONFIGURATION START --------------- USER CONFIGURATION START ---------------
// --------------- USER CONFIGURATION START --------------- USER CONFIGURATION START ---------------
// --------------- USER CONFIGURATION START --------------- USER CONFIGURATION START ---------------
// --------------- USER CONFIGURATION START --------------- USER CONFIGURATION START ---------------
// -------------------------------------------------------------------------------------------------
// Choose your using zombie plague version:
// NEW - Zombie Plague 5.0 or later. (zp_plugin_50.zip | zp508a.zip and later ... )
// OLD - Zombie Plague 4.3 or earlier. (zp_plugin_43.zip)
// Zombie Plague Advanced - Not supported.
// Daugiau pluginu https://forums.alliedmods.net/showth...42196?t=242196
#define MODIFICATION NEW
// -------------------------------------------------------------------------------------------------
// Set wich system to use loading privileges:
// FORCED - Just vips.ini file. Ignores amxmodx.
// ON - vips.ini and amxmodx (users.ini/database (flag t))
// OFF - Disables vips.ini file and reads only from amxmodx (users.ini/database (flag t))
#define VIPS_FILE_SYSTEM OFF
// -------------------------------------------------------------------------------------------------
// Set if you want to enable extra items menu system (/vm)
// ON - Enabled
// OFF - Dissabled
#define EXTRA_ITEMS ON
// -------------------------------------------------------------------------------------------------
// Vip privileges flag in users.ini file (t) if NOT using VIPS_FILE_SYSTEM [FORCED] mode.
#define VIP_SYS_FLAG ADMIN_LEVEL_H
// -------------------------------------------------------------------------------------------------
// Admin flag (from users.ini). Allow access to VIP admin panel, zm_vip_freevip_hour cvar(cmd).
#define ADMIN_SYS_FLAG ADMIN_LEVEL_E //(ADMIN_LEVEL_E flag is "q")
// -------------------------------------------------------------------------------------------------
// Name of configs/vips.ini|zm_cip.cfg file. In fact, no reason to change.
#define VIPS_FILE "vips.ini"
#define CONFIGS_FILE "zm_vip.cfg"
// -------------------------------------------------------------------------------------------------
//--------------- USER CONFIGURATION END --------------- USER CONFIGURATION END ---------------
//--------------- USER CONFIGURATION END --------------- USER CONFIGURATION END ---------------
//--------------- USER CONFIGURATION END --------------- USER CONFIGURATION END ---------------
//--------------- USER CONFIGURATION END --------------- USER CONFIGURATION END ---------------
//--------------- USER CONFIGURATION END --------------- USER CONFIGURATION END ---------------
//////////////////////////// Editing anyting further - taking own risk /////////////////////////////
////////// This means - no support. Using/stealing anything without credits - not allowed //////////
#define EMPTY(%1) (%1[0]==EOS)
#define BIT(%1) (1<<%1)
#define FLAG_A (1<<0)
#define FLAG_B (1<<1)
#define FLAG_C (1<<2)
#define FLAG_D (1<<3)
#define FLAG_E (1<<4)
#define FLAG_F (1<<4)
#define FLAG_K (1<<10)
#define FLAG_N (1<<13)
#define LOAD_FROM_INI (1<<31)
#define LOAD_FROM_DAT (1<<30)
#define LOAD_FROM_AMX (1<<29)
#define LOAD_FROM_NAMES (1<<2
#define LOAD_FROM_MAIN (1<<27)
#define LOAD_MASK 0xFC000000
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <fun>
#include <regex>
#if MODIFICATION == NEW
#include <cstrike>
#define ZP_ITEM_AVAILABLE 0
#define ZP_ITEM_NOT_AVAILABLE 1
#define ZP_ITEM_DONT_SHOW 2
#define ZP_CLASS_AVAILABLE 0
#define ZP_CLASS_NOT_AVAILABLE 1
#define ZP_CLASS_DONT_SHOW 2
native zp_core_is_zombie(id)
forward zp_fw_core_spawn_post(id)
forward zp_fw_core_infect_pre(id, attacker)
forward zp_fw_core_infect_post(id, attacker)
forward zp_fw_core_cure_post(id, attacker)
native zp_ammopacks_get(id)
native zp_ammopacks_set(id, amount)
native zp_class_human_menu_text_add(const text[])
forward zp_fw_class_human_select_pre(id, classid)
native zp_class_human_register(const name[], const description[], health, Float:speed, Float:gravity)
native zp_class_zombie_menu_text_add(const text[])
forward zp_fw_class_zombie_select_pre(id, classid)
native zp_class_zombie_register(const name[], const description[], health, Float:speed, Float:gravity)
native zp_items_register(const name[], cost)
forward zp_fw_items_select_pre(id, itemid, ignorecost)
forward zp_fw_items_select_post(id, itemid, ignorecost)
native zp_items_show_menu(id)
native zp_items_menu_text_add(const text[])
native cs_set_player_model(id, const model[])
forward zp_fw_grenade_fire_pre(id)
forward zp_fw_grenade_frost_pre(id)
#else
native zp_get_user_bombardier(id)
#define ZP_TEAM_ANY 0
native zp_get_user_zombie(id)
native zp_get_user_next_class(id)
native zp_set_user_zombie_class(id, classid)
native zp_register_zombie_class(const name[], const info[], const model[], const clawmodel[], hp, speed, Float:gravity, Float:knockback)
native zp_override_user_model(id, const newmodel[], modelindex = 0)
native zp_get_user_nemesis(id)
native zp_get_user_survivor(id)
forward zp_user_infect_attempt(id, infector, nemesis)
forward zp_user_infected_post(id, infector, nemesis)
forward zp_user_humanized_post(id, survivor)
forward zp_user_infected_pre(id, infector, nemesis)
forward zp_extra_item_selected(id, itemid)
forward zp_round_started(gamemode, id)
native zp_register_extra_item(const name[], cost, teams)
native zp_force_buy_extra_item(id, itemid, ignorecost = 0)
native zp_get_extra_item_id(const name[])
native zp_get_user_ammo_packs(id)
native zp_set_user_ammo_packs(id, amount)
#define ZP_PLUGIN_HANDLED 97
#endif
new cvar_multijump, cvar_multijump_allow, cvar_armor, cvar_extra_hp_human, cvar_extra_hp_zombie,
cvar_extra_gravity_human, cvar_extra_gravity_zombie ,cvar_unlimited_clip, cvar_no_fall_dmg,
cvar_extra_dmg, cvar_extra_frags, cvar_extra_kill_ammo, cvar_extra_armor, cvar_extra_infect_ammo,
cvar_extra_infect_health, cvar_extra_ignore_for_special, cvar_damage_reward, cvar_viponly_class,
cvar_chat_viptag, cvar_vip_connected_to_server, cvar_freevip_flags, cvar_vipniscoretable,
cvar_grenades_immunity, cvar_gamemode_disable_flags
#if VIPS_FILE_SYSTEM != FORCED
new cvar_amx_auth_flags
#endif
#if VIPS_FILE_SYSTEM != OFF
new cvar_vip_store_ini
#endif
new cvar_amxmodx_flags, cvar_vip_price, cvar_vip_buy_duration, cvar_vip_buy_flags,
cvar_vip_buy_in_extra_items
#if EXTRA_ITEMS == ON
new cvar_buys_per_round
#if MODIFICATION == OLD
new chached_show_vip_items
#else
new cvar_vip_show_vip_items
#endif
#endif
enum _:player_attributes
{
AT_MULTIJUMP, //a(0)
AT_ARMOR, //b(1)
AT_UNLIMITED_CLIP, //c(2)
AT_NO_FALL_DMG, //d(3)
AT_DAMAGE_REWARD, //e(4)
AT_EXTRA_DMG, //f(5)
AT_EXTRA_HP, //g(6)
AT_EXTRA_GRAVITY, //h(7)
AT_EXTRA_FRAGS, //i(
AT_EXTRA_KILL_AMMO, //j(9)
AT_EXTRA_ARMOR, //k(10)
AT_EXTRA_INFECT_AMMO, //l(11)
AT_EXTRA_INFECT_HEALTH, //m(12)
AT_EXTRA_ITEMS, //n(13)
AT_VIP_MODEL, //o(14)
AT_VIP_CLASS, //p(15)
AT_CHATTAG, //q(16)
AT_VIPINSCORE, //r(17)
AT_GRENADE_IMMUNITY //s(1
}
new p_attribs[33][player_attributes]
#define AT_NONE (1<<25) // z
#define ZV_DURATION_IGNORE -1
#define ZV_DURATION_PERMANENT 0
#define ZV_DURATION_TILL_DISCONNECT ~'t'
#define ZV_DURATION_TILL_MAP ~('t'|'m')
enum ClassType:cltypes {
EXTRA_ITEM = 1,
CLASS_ZOMBIE,
CLASS_HUMAN
}
#define VipsItemHandle trie_vip_items
new Trie:trie_vip_items
new p_bought_per_round[33]
new bool:p_zombie[33]
new p_jumpsnum[33]
new Float:p_damage[33]
new Float:p_grenade_time[33]
new p_vip_model_zombie[15]
new p_vip_model_human[15]
new is_amxmodx_new_version
#if MODIFICATION == NEW
new is_module_ammopacks_loaded
#endif
new Trie:trie_vips_database
new Array:array_vips_database
new Array:array_vips_database_nick
new amx_password_field_string[30]
enum _:VipCnt {
INI,
DAT,
MAIN,
NAMES,
AMX
}
new total_vips_count[VipCnt] //0 - main, 1 - names, 2 - amx
#define VIPCNT(%1) total_vips_count[%1]
#define VIPINC(%1) total_vips_count[%1]++
#define VIPDEC(%1) total_vips_count[%1]--
enum _:vips_database_type
{
AUTH[40],
PASS[30],
SETTINGS,
FLAGS,
TIMESTAMP,
INDEX
}
new p_data[33][vips_database_type]
#if EXTRA_ITEMS == ON
new registered_extra_items_num
#if MODIFICATION == NEW
new bool:p_views_extra_items_menu[33]
#else
enum _:item_struct {
item_plid,
item_name[100],
item_cost,
item_team
}
#define ZP_TEAM_ZOMBIE (1<<0)
#define ZP_TEAM_HUMAN (1<<1)
#define ZP_TEAM_NEMESIS (1<<2)
#define ZP_TEAM_SURVIVOR (1<<3)
new Array:array_vip_extra_items
new fw_extraitemselected
#endif
#endif
new vip_buy_extra_item = -1
new current_gamemode
new bool:freevip_enabled
new bool:freevip_inform[33]
new bool:first_spawn[33]
new freevip_hours[4]
new maxplayers
new msg_saytext
new msg_scoreattrib
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20, 10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 }
#define IS_PLAYER(%1) (1<=%1<=maxplayers)
#define ATTRIB(%1,%2) p_attribs[%1][%2]
#define CURRENCY_MONEY 0
#define CURRENCY_AMMO_PACKS 1
public plugin_init() {
register_plugin("ZM VIP", VERSION, "aaarnas")
register_dictionary("zm_vip.txt")
new amxmodx_version[20], amxmodx_version_num
get_amxx_verstring(amxmodx_version, charsmax(amxmodx_version))
replace_all(amxmodx_version, charsmax(amxmodx_version), ".", "")
amxmodx_version_num = str_to_num(amxmodx_version)
is_amxmodx_new_version = amxmodx_version_num>=183
/////////////////////// CVARS REGISTRATION ///////////////////////
cvar_multijump = register_cvar("zm_vip_mutijump", "1")
cvar_multijump_allow = register_cvar("zm_vip_multijump_allow", "ab")
cvar_armor = register_cvar("zm_vip_armor", "65")
cvar_unlimited_clip = register_cvar("zm_vip_unlimited_clip", "0")
cvar_no_fall_dmg = register_cvar("zm_vip_no_fall_dmg", "1")
cvar_extra_dmg = register_cvar("zm_vip_extra_dmg", "1.2")
cvar_extra_hp_human = register_cvar("zm_vip_extra_hp_human", "50")
cvar_extra_hp_zombie = register_cvar("zm_vip_extra_hp_zombie", "500")
cvar_extra_gravity_human = register_cvar("zm_vip_extra_gravity_human", "0")
cvar_extra_gravity_zombie = register_cvar("zm_vip_extra_gravity_zombie", "0")
cvar_extra_frags = register_cvar("zm_vip_extra_frags", "0")
cvar_extra_kill_ammo = register_cvar("zm_vip_extra_kill_ammo", "1")
cvar_extra_armor = register_cvar("zm_vip_extra_armor", "0")
cvar_extra_infect_ammo = register_cvar("zm_vip_extra_infect_ammo", "1")
cvar_extra_infect_health = register_cvar("zm_vip_extra_infect_health", "100")
cvar_extra_ignore_for_special = register_cvar("zm_vip_extra_ignore_for_specia l", "1")
cvar_damage_reward = register_cvar("zm_vip_damage_reward", "1000")
cvar_viponly_class = register_cvar("zm_viponly_class", "1")
cvar_chat_viptag = register_cvar("zm_vip_chattag", "1")
cvar_vip_connected_to_server = register_cvar("zm_vip_connected_to_server", "1") // 1-chat/2-hud/3-dhud
cvar_vipniscoretable = register_cvar("zm_vipinscoretable", "1")
#if VIPS_FILE_SYSTEM != FORCED
cvar_amx_auth_flags = register_cvar("zm_vip_amx_auth_flags", "0")
#endif
cvar_amxmodx_flags = register_cvar("zm_vip_amxmodx_flags", "t")
cvar_grenades_immunity = register_cvar("zm_vip_grenades_immunity", "0")
cvar_gamemode_disable_flags = register_cvar("zm_vip_gamemode_disable_flags" , "0")
register_concmd("zm_vip_freevip_hour", "set_freevip_hour", ADMIN_CVAR)
cvar_freevip_flags = register_cvar("zm_vip_freevip_flags", "0")
#if VIPS_FILE_SYSTEM != OFF
cvar_vip_store_ini = register_cvar("zm_vip_store_ini", "0")
#endif
cvar_vip_price = register_cvar("zm_vip_price", "0")
cvar_vip_buy_duration = register_cvar("zm_vip_buy_duration", "1d") // 1h - val, 1d - day// t - tepm/ tm - temp till map
cvar_vip_buy_flags = register_cvar("zm_vip_buy_flags", "0")
cvar_vip_buy_in_extra_items = register_cvar("zm_vip_buy_in_extra_items", "1")
#if EXTRA_ITEMS == ON
cvar_buys_per_round = register_cvar("zm_vip_buys_per_round", "0")
#if MODIFICATION == NEW
cvar_vip_show_vip_items = register_cvar("zm_vip_show_vip_items", "2")
#endif
#if MODIFICATION != NEW
fw_extraitemselected = CreateMultiForward("zv_extra_item_selected", ET_CONTINUE, FP_CELL, FP_CELL)
#endif
#endif
maxplayers = get_maxplayers()
msg_saytext = get_user_msgid("SayText")
msg_scoreattrib = get_user_msgid("ScoreAttrib")
register_clcmd("say /vm", "show_vip_menu")
register_clcmd("open_vip_menu", "show_vip_menu_console")
register_clcmd("say /vip", "show_vip_info")
register_clcmd("say /vips", "show_vips_online")
register_concmd("zm_vip_list", "cmd_list_vips", ADMIN_SYS_FLAG)
register_concmd("amx_reloadvips", "cmd_vips_reload", ADMIN_SYS_FLAG)
register_concmd("zm_vip_reload", "cmd_vips_reload", ADMIN_SYS_FLAG)
register_concmd("zm_vip_remove", "cmd_vips_remove", ADMIN_SYS_FLAG)
register_menu("Menu Buy", MENU_KEY_0|MENU_KEY_1, "forward_buy_menu_handler")
register_event("HLTV", "forward_event_round_start", "a", "1=0", "2=0")
register_event("DeathMsg", "forward_event_deathmsg", "a")
register_event("ResetHUD", "forward_event_reset_hud", "be")
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
register_message(msg_saytext, "message_say_text")
register_forward(FM_CmdStart, "forward_cmdstart")
#if MODIFICATION != NEW
RegisterHam(Ham_Spawn, "player", "forward_player_spawn", 1)
#endif
RegisterHam(Ham_TakeDamage, "player", "forward_player_takedamage_pre")
RegisterHam(Ham_TakeDamage, "player", "forward_player_takedamage_post", 1)
RegisterHam(Ham_Think, "grenade", "forward_grenade_think")
trie_vips_database = TrieCreate()
array_vips_database = ArrayCreate(45, 15)
register_cvar("zp_vip_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY)
set_cvar_string("zp_vip_version", VERSION)
}
public plugin_natives() {
register_library("zm_vip")
set_native_filter("native_filter")
register_native("zv_get_user_flags", "native_zv_get_user_flags")
register_native("zv_set_user_flags", "native_zv_set_user_flags")
register_native("zv_remove_user_flags", "native_zv_remove_user_flags")
#if MODIFICATION == NEW
#if EXTRA_ITEMS == ON
register_native("zv_items_register", "native_zv_items_register", 1)
#endif
register_native("zv_class_human_register", "native_zv_class_human_register", 1)
register_native("zv_class_zombie_register", "native_zv_class_zombie_register", 1)
#else
register_native("zv_register_zombie_class", "native_zv_register_zombie_class", 1)
#if EXTRA_ITEMS == ON
register_native("zv_register_extra_item", "native_zv_register_extra_item", 1)
register_native("zv_register_extra_item2", "native_zv_register_extra_item2", 1)
register_native("zv_force_buy_extra_item", "native_zv_force_buy_extra_item", 1)
register_native("zv_get_extra_item_id", "native_zv_get_extra_item_id", 1)
#endif
#endif
}
#if MODIFICATION == NEW
native zp_class_nemesis_get(id)
native zp_class_survivor_get(id)
native zp_class_assassin_get(id)
native zp_class_sniper_get(id)
#endif
new natives_filter_out
enum {
NATIVE_ZP_CLASS_NEMESIS_GET,
NATIVE_ZP_CLASS_SURVIVOR_GET,
NATIVE_ZP_CLASS_ASSASSIN_GET,
NATIVE_ZP_CLASS_SNIPER_GET,
NATIVE_ZP_CLASS_BOMBARDIER_GET,
NATIVE_OVERRIDE_USER_MODEL
}
public native_filter(const name[], index, trap) {
if (!trap) {
#if MODIFICATION == NEW
if (equal(name, "zp_class_nemesis_get")) natives_filter_out |= BIT(NATIVE_ZP_CLASS_NEMESIS_GET)
else if(equal(name, "zp_class_survivor_get")) natives_filter_out |= BIT(NATIVE_ZP_CLASS_SURVIVOR_GET)
else if(equal(name, "zp_class_assassin_get")) natives_filter_out |= BIT(NATIVE_ZP_CLASS_ASSASSIN_GET)
else if(equal(name, "zp_class_sniper_get")) natives_filter_out |= BIT(NATIVE_ZP_CLASS_SNIPER_GET)
#else
if (equal(name, "zp_get_user_bombardier")) natives_filter_out |= BIT(NATIVE_ZP_CLASS_BOMBARDIER_GET)
#endif
#if MODIFICATION == OLD
else if (equal(name, "zp_override_user_model")) {
p_vip_model_zombie[0] = EOS
p_vip_model_human[0] = EOS
log_amx("ERROR: Vip models are not compatible with old Zombie Plague 4.3 version. Use Zombie Plague 4.3 patched or 5.0 to enable this feature.")
log_amx("Download: https://forums.alliedmods.net/showthread.php?t=72505")
natives_filter_out |= BIT(NATIVE_OVERRIDE_USER_MODEL)
}
else if (equal(name, "zp_get_user_zombie")) {
set_fail_state("ERROR: This plugin compiled with MODIFICATION - OLD setting. \
This supports only Zombie plague 4.3 versions.^nPlugin was unable to\
detect this version, so probably, modification is incorrect.")
}
#endif
else {
return PLUGIN_CONTINUE;
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public plugin_precache() {
#if EXTRA_ITEMS == ON && MODIFICATION == OLD
new value_str[5]
read_config("zm_vip_show_vip_items", value_str, charsmax(value_str))
chached_show_vip_items = str_to_num(value_str)
#endif
#if MODIFICATION == NEW
read_config("zm_vip_model_zombie", p_vip_model_zombie, charsmax(p_vip_model_zombie))
read_config("zm_vip_model_human", p_vip_model_human, charsmax(p_vip_model_human))
if (!EMPTY(p_vip_model_zombie)) {
new model_path[128]
formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", p_vip_model_zombie, p_vip_model_zombie)
precache_model(model_path)
formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", p_vip_model_zombie, p_vip_model_zombie)
if (file_exists(model_path)) precache_model(model_path)
}
if (!EMPTY(p_vip_model_human)) {
new model_path[128]
formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", p_vip_model_human, p_vip_model_human)
precache_model(model_path)
formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", p_vip_model_human, p_vip_model_human)
if (file_exists(model_path)) precache_model(model_path)
}
#endif
}
public plugin_cfg() {
#if MODIFICATION == NEW
if (!LibraryExists("zp50_core", LibType_Library))
set_fail_state("ERROR: This plugin compiled with MODIFICATION - NEW setting. \
This supports only Zombie plague 5 version and higher.^nPlugin was unable to\
detect main Zombie Plague Core plugin.")
is_module_ammopacks_loaded = LibraryExists("zp50_ammopacks", LibType_Library)
#endif
new file_link[45]
get_configsdir(file_link, charsmax(file_link))
format(file_link, charsmax(file_link), "%s/%s", file_link, CONFIGS_FILE)
if (file_exists(file_link)) {
server_cmd("exec %s", file_link)
server_exec()
}
else {
log_amx("WARNING: Missing ^"%s^" file in configs folder. Can't load cvars values.", CONFIGS_FILE)
}
get_cvar_string("amx_password_field", amx_password_field_string, charsmax(amx_password_field_string))
#if VIPS_FILE_SYSTEM != OFF
load_ini_file()
#endif
load_datafile()
#if VIPS_FILE_SYSTEM != FORCED
new num = admins_num()
for (new i=0; i<num; i++) {
if (admins_lookup(i, AdminProp_Access)&VIP_SYS_FLAG) {
VIPINC(AMX)
}
}
#endif
if (!VIPCNT(DAT) && !VIPCNT(INI) && !VIPCNT(AMX))
log_amx("WARNING: No VIPs loaded from zm_vip system. Maybe there aren't any.")
if (get_pcvar_num(cvar_vip_price) > 0 && get_pcvar_num(cvar_vip_buy_in_extra_items)) {
new buy_vip_text[30], langid = LANG_SERVER
LookupLangKey(buy_vip_text, charsmax(buy_vip_text), "BUY_VIP", langid)
#if MODIFICATION == NEW
vip_buy_extra_item = zp_items_register(buy_vip_text, get_pcvar_num(cvar_vip_price))
#else
vip_buy_extra_item = zp_register_extra_item(buy_vip_text, get_pcvar_num(cvar_vip_price), ZP_TEAM_ANY)
#endif
}
#if EXTRA_ITEMS == ON
if (!registered_extra_items_num)
log_amx("WARRNING: No vip extra item plugins loaded.")
#endif
set_task(1.0, "vip_time_check", 0, _, _, "b")
server_print("-------------------------------------------------------------------------------")
server_print("This server using ZM VIP %s by aaarnas", VERSION)
server_print("Successfully loaded %d VIPs", VIPCNT(DAT)+VIPCNT(INI)+VIPCNT(AMX))
server_print("-------------------------------------------------------------------------------")
}
_get_pcvar_flags(pcvar) {
new flags[30]
get_pcvar_string(pcvar, flags, charsmax(flags))
if (flags[0] == '0')
return 0;
return read_flags(flags);
}
set_user_atribs(id, double_attrib_update = false) {
if (id == 0) return;
new hour_flags = 0
new gamemode_disable_flags = 0
if (current_gamemode != 0) {
gamemode_disable_flags = _get_pcvar_flags(cvar_gamemode_disable_flags)
}
if(freevip_enabled && freevip_hour_check()) {
hour_flags = _get_pcvar_flags(cvar_freevip_flags)
if (hour_flags == 0)
hour_flags = -1
if (!freevip_inform[id]) {
freevip_inform[id] = true
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L!", id, "FREE_VIP_GOT")
else _client_print_color(id, "^4[ZMVIP] ^1%L!", id, "FREE_VIP_GOT")
client_cmd(id, "spk /sound/buttons/bell1.wav")
}
}
else if (freevip_inform[id]) {
freevip_inform[id] = false
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L...", id, "FREE_VIP_EXPIRED")
else _client_print_color(id, "^4[ZMVIP] ^1%L...", id, "FREE_VIP_EXPIRED")
client_cmd(id, "spk /sound/buttons/blip1.wav")
}
static i, d, value
static const double_attribs[] = {
AT_MULTIJUMP,
AT_EXTRA_HP,
AT_EXTRA_GRAVITY
}
d = 0
for(i=0; i<player_attributes;) {
if (double_attrib_update) {
if (d >= sizeof(double_attribs))
break;
i = double_attribs[d++];
}
if (p_data[id][FLAGS] == 0 && hour_flags == 0)
break;
if (!(BIT(i) & p_data[id][FLAGS]) && !(BIT(i) & hour_flags) || (BIT(i) & gamemode_disable_flags)) {
i++
continue;
}
value = 0
switch(i) {
case AT_MULTIJUMP: {
new jnum = get_pcvar_num(cvar_multijump)
if(jnum) {
static nflags, isspecial
nflags = _get_pcvar_flags(cvar_multijump_allow)
isspecial = is_special_character(id)
if((nflags & FLAG_A && !p_zombie[id]) || (nflags & FLAG_B && p_zombie[id]) && !isspecial) value = jnum
else if((nflags & FLAG_C && !p_zombie[id]) || (nflags & FLAG_D && p_zombie[id]) && isspecial) value = jnum
}
}
case AT_ARMOR: value = get_pcvar_num(cvar_armor)
case AT_UNLIMITED_CLIP: value = get_pcvar_num(cvar_unlimited_clip)
case AT_NO_FALL_DMG: value = get_pcvar_num(cvar_no_fall_dmg)
case AT_EXTRA_DMG: value = ((get_pcvar_float(cvar_extra_dmg)>0)?1:0)
case AT_EXTRA_HP: value = get_pcvar_num(p_zombie[id]?cvar_extra_hp_zombie:cvar_extra_hp_human)
case AT_EXTRA_GRAVITY: value = (get_pcvar_float(p_zombie[id]?cvar_extra_gravity_zombie:cvar_extra_gravity _human)>0.0)?1:0
case AT_EXTRA_FRAGS: value = get_pcvar_num(cvar_extra_frags)
case AT_EXTRA_KILL_AMMO: value = get_pcvar_num(cvar_extra_kill_ammo)
case AT_EXTRA_ARMOR: value = get_pcvar_num(cvar_extra_armor)
case AT_EXTRA_INFECT_AMMO: value = get_pcvar_num(cvar_extra_infect_ammo)
case AT_EXTRA_INFECT_HEALTH: value = get_pcvar_num(cvar_extra_infect_health)
#if EXTRA_ITEMS == ON
case AT_EXTRA_ITEMS: value = p_data[id][FLAGS]?1:0
#endif
case AT_DAMAGE_REWARD: value = get_pcvar_num(cvar_damage_reward)
#if MODIFICATION != OLD
case AT_VIP_MODEL: value = (p_vip_model_zombie[0]!=EOS||p_vip_model_human[0]!=EOS)
#endif
case AT_VIP_CLASS: value = get_pcvar_num(cvar_viponly_class)
case AT_CHATTAG: value = get_pcvar_num(cvar_chat_viptag)
case AT_VIPINSCORE: value = get_pcvar_num(cvar_vipniscoretable)
case AT_GRENADE_IMMUNITY: value = _get_pcvar_flags(cvar_grenades_immunity)
}
ATTRIB(id, i) = value
if (!double_attrib_update)
i++
}
}
public forward_event_round_start() {
arrayset(p_bought_per_round, 0, sizeof(p_bought_per_round))
current_gamemode = 0
}
public forward_event_deathmsg() {
static attacker, victim
attacker = read_data(1)
victim = read_data(2)
if (attacker == victim)
return;
if(IS_PLAYER(attacker)) {
if (get_pcvar_num(cvar_extra_ignore_for_special) && is_special_character(attacker))
return;
if (ATTRIB(attacker, AT_EXTRA_ARMOR) && !p_zombie[attacker] && p_zombie[victim])
set_user_armor(attacker, get_user_armor(attacker)+ATTRIB(attacker, AT_EXTRA_ARMOR))
if(ATTRIB(attacker, AT_EXTRA_KILL_AMMO))
zv_currency_give(attacker, p_attribs[attacker][AT_EXTRA_KILL_AMMO])
if(ATTRIB(attacker, AT_EXTRA_FRAGS))
set_user_frags(attacker, get_user_frags(attacker)+ATTRIB(attacker, AT_EXTRA_FRAGS))
}
}
public forward_event_reset_hud(id) {
if (ATTRIB(id, AT_VIPINSCORE)) {
if(is_user_alive(id)) {
message_begin(MSG_ALL, msg_scoreattrib)
write_byte(id)
write_byte(4)
message_end()
}
}
}
#if MODIFICATION == NEW
public zp_fw_core_spawn_post(id) {
#else
public forward_player_spawn(id) {
#endif
#if MODIFICATION == NEW
p_zombie[id] = zp_core_is_zombie(id)?true:false
#else
p_zombie[id] = zp_get_user_zombie(id)?true:false
#endif
set_user_atribs(id)
if (first_spawn[id]) {
set_task(1.0, "show_vip_timeleft", id, _, _, "a", 6)
first_spawn[id] = false
}
}
public forward_player_takedamage_pre(victim, inflictor, attacker, Float:damage, damage_type) {
if(damage_type & DMG_FALL && ATTRIB(victim, AT_NO_FALL_DMG)) return HAM_SUPERCEDE;
else if(IS_PLAYER(attacker) && ATTRIB(attacker, AT_EXTRA_DMG)) {
if (get_pcvar_num(cvar_extra_ignore_for_special) && is_special_character(attacker))
return HAM_IGNORED;
SetHamParamFloat(4, damage*get_pcvar_float(cvar_extra_dmg))
return HAM_HANDLED;
}
return HAM_IGNORED;
}
public forward_player_takedamage_post(victim, inflictor, attacker, Float:damage, damage_type) {
if(IS_PLAYER(attacker) && ATTRIB(attacker, AT_DAMAGE_REWARD)) {
if(p_damage[attacker] > ATTRIB(attacker, AT_DAMAGE_REWARD)) {
zv_currency_give(attacker, 1)
p_damage[attacker] = 0.0
}
else
p_damage[attacker] += damage
}
}
public forward_cmdstart(id, uc_handle) {
static button, flags
button = get_uc(uc_handle, UC_Buttons)
flags = entity_get_int(id, EV_INT_flags)
if(flags & FL_ONGROUND)
p_jumpsnum[id] = 0
if(button & IN_JUMP && !(get_user_oldbutton(id) & IN_JUMP)) {
if(!(flags & FL_ONGROUND) && ++p_jumpsnum[id] <= ATTRIB(id, AT_MULTIJUMP)) {
static Float:velocity[3]
entity_get_vector(id, EV_VEC_velocity, velocity)
velocity[2] = random_float(265.0,285.0)
entity_set_vector(id,EV_VEC_velocity,velocity )
}
}
}
#define EV_NADE_TYPE EV_INT_flTimeStepSound
#define NADE_TYPE_INFECTION 1111
public forward_grenade_think(ent) {
if (is_valid_ent(ent) && entity_get_int(ent, EV_NADE_TYPE) == NADE_TYPE_INFECTION) {
p_grenade_time[entity_get_edict(ent, EV_ENT_owner)] = get_gametime()
}
}
// Credits: MeRcyLeZZ
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1) return;
static weapon, clip
weapon = get_msg_arg_int(2)
clip = get_msg_arg_int(3)
if (MAXCLIP[weapon] > 2 && ATTRIB(msg_entity, AT_UNLIMITED_CLIP)) {
set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon])
if (clip < 2) {
static wname[32], weapon_ent
get_weaponname(weapon, wname, sizeof wname - 1)
weapon_ent = find_ent_by_owner(-1, wname, msg_entity)
// OFFSET_CLIPAMMO OFFSET_LINUX_WEAPONS
set_pdata_int(weapon_ent, 51, MAXCLIP[weapon], 4)
}
}
}
enum _:ChanellsStruct {
channel[8],
translation[42]
}
new const chat_channels[][ChanellsStruct] = {
{"CT", "^1(Humans) ^4[VIP] ^3%s^1 : %s"},
{"T", "^1(Zombies) ^4[VIP] ^3%s^1 : %s"},
{"CT_Dead", "^1*DEAD*(Humans) ^4[VIP] ^3%s^1 : %s"},
{"T_Dead", "^1*DEAD*(Zombies) ^4[VIP] ^3%s^1 : %s"},
{"Spec", "^1(Spectator) ^4[VIP] ^3%s^1 : %s"},
{"All", "^4[VIP] ^3%s : ^1%s"},
{"AllDead", "^1*DEAD* ^4[VIP] ^3%s^1 : %s"},
{"AllSpec", "^1*SPEC* ^4[VIP] ^3%s^1 : %s"}
}
public message_say_text(msg_id, msg_dest, msg_entity) {
if (!ATTRIB(msg_dest, AT_CHATTAG))
return;
static message[250]
get_msg_arg_string(2, message, charsmax(message))
if (ATTRIB(msg_dest, AT_CHATTAG) == 1) {
if (message[0] == '#' && message[9] == 'C' && equali(message, "#Cstrike_Chat_", 14)) {
new i
for (i=0; i<sizeof(chat_channels); i++) {
if (equal(message[14], chat_channels[i][channel])) {
set_msg_arg_string(2, chat_channels[i][translation])
get_user_name(msg_dest, message, charsmax(message))
set_msg_arg_string(3, message)
return;
}
}
}
else {
format(message, charsmax(message), "^4[VIP]%s", message)
set_msg_arg_string(2, message)
}
}
else if (ATTRIB(msg_dest, AT_CHATTAG) == 2) {
if (message[9] == 'C' && equali(message, "#Cstrike_Chat_", 14)) {
get_msg_arg_string(4, message, charsmax(message))
static tag_index
do {
tag_index = findtag(message, "<VIP>")
if (tag_index != -1) {
while (message[tag_index+5] != EOS) {
message[tag_index] = message[tag_index+5]; tag_index++
}
message[tag_index] = EOS
}
}
while (tag_index != -1)
;
if (ATTRIB(msg_dest, AT_CHATTAG))
format(message, charsmax(message), "<VIP> %s", message)
set_msg_arg_string(4, message)
}
}
}
public client_infochanged(id) {
new info[5]
read_argv(1, info, charsmax(info))
if (equal(info, "name"))
VipsDBGet(id)
}
public client_putinserver(id) {
p_data[id][FLAGS] = 0
p_data[id][SETTINGS] = 0
p_data[id][TIMESTAMP] = 0
first_spawn[id] = true
arrayset(p_attribs[id], 0, player_attributes)
freevip_inform[id] = false
p_grenade_time[id] = 0.0
p_damage[id] = 0.0
p_jumpsnum[id] = 0
if (!VipsDBGet(id))
return;
if (p_data[id][TIMESTAMP] > 0 && p_data[id][TIMESTAMP] < get_systime()) {
VipsDBRemove(id)
return;
}
if (p_data[id][FLAGS]) {
new authid[30], ip[30], name[45]
get_user_name(id, name, charsmax(name))
get_user_authid(id, authid, charsmax(authid))
get_user_ip(id, ip, charsmax(ip), 1)
log_amx("[ZMVIP] VIP Connected: %s (%s) [%s].", name, authid, ip)
}
if (ATTRIB(id, AT_CHATTAG) && get_pcvar_num(cvar_vip_connected_to_server)) {
new name[35]
get_user_name(id, name, charsmax(name))
switch (get_pcvar_num(cvar_vip_connected_to_server)) {
case 1:
if (is_amxmodx_new_version) client_print_color(0, 0, "^4[VIP] %s ^1%L.", name, LANG_PLAYER, "CONNECTED_TO_SERVER")
else _client_print_color(0, "^4[VIP] %s ^1%L.", name, LANG_PLAYER, "CONNECTED_TO_SERVER")
case 2: {
set_hudmessage(255, 170, 0, 0.02, 0.71, 0, 6.0, 6.0)
show_hudmessage(0, "[VIP] %s %L", name, LANG_PLAYER, "CONNECTED_TO_SERVER")
}
case 3: {
if (is_amxmodx_new_version) {
set_dhudmessage(255, 170, 0, 0.02, 0.71, 0, 6.0, 6.0)
show_dhudmessage(0, "[VIP] %s %L", name, LANG_PLAYER, "CONNECTED_TO_SERVER")
}
else {
_set_dhudmessage(255, 170, 0, 0.02, 0.71, 0, 6.0, 6.0)
_show_dhudmessage(0, "[VIP] %s %L", name, LANG_PLAYER, "CONNECTED_TO_SERVER")
}
}
}
}
}
public client_disconnect(id) {
p_data[id][FLAGS] = 0
p_damage[id] = 0.0
p_jumpsnum[id] = 0
p_data[id][SETTINGS] = 0
if (p_data[id][TIMESTAMP] == ZV_DURATION_TILL_DISCONNECT) {
VipsDBRemove(id)
return;
}
if (p_data[id][TIMESTAMP] == ZV_DURATION_TILL_MAP) {
p_data[id][PASS][charsmax(p_data[][PASS])] = floatround(get_gametime()*100, floatround_floor)
VipsDBSet(id)
}
}
public show_vip_info(id) {
if (file_exists("vip.txt")) {
show_motd(id, "vip.txt")
}
else {
log_amx("WARNING: Missing vip.txt file in cstrike directory. It's used by /vip command to show information about privileges on server.")
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "NO_VIP_TXT")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "NO_VIP_TXT")
print_admin_contacts(id)
}
}
public show_vips_online(id) {
new bool:first = true, message[256], len
for (new i=0; i<maxplayers; i++) {
if (p_data[i][FLAGS]) {
if (!first) {
message[len++] = ','
message[len++] = ' '
}
message[len++] = '^4'
message[len] = EOS
len += get_user_name(i, message[len], charsmax(message)-len)
message[len++] = '^1'
message[len] = EOS
first = false
}
}
if (first) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L...", id, "NO_VIP_ONLINE")
else _client_print_color(id, "^4[ZMVIP] ^1%L...", id, "NO_VIP_ONLINE")
}
else {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L: %s.", id, "ONLINE_VIPS", message)
else _client_print_color(id, "^4[ZMVIP] ^1%L: %s.", id, "ONLINE_VIPS", message)
}
print_admin_contacts(id)
return PLUGIN_CONTINUE;
}
show_buy_menu(id) {
new duration = get_cvar_duration(cvar_vip_buy_duration)
if (duration == -1) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "SERVER_CONFIG_ERROR")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "SERVER_CONFIG_ERROR")
return;
}
new timeleft[100]
convert_duration_to_string(id, duration, timeleft, charsmax(timeleft))
new menu[250]
formatex(menu, charsmax(menu),\
"\r%L^n^n\
%L: \y%d %L^n\
\r%L: \y%s^n^n\
\r1. \w%L^n^n\
\r0. \w%L", id, "BUY_VIP_PRIVILEGE",
id, "PRICE", get_pcvar_num(cvar_vip_price), id, zv_get_currency()==CURRENCY_AMMO_PACKS?"AMMO_ PACKS":"MONEY",
id, "TIME", timeleft,
id, "BUY", id, "EXIT")
show_menu(id, MENU_KEY_0|MENU_KEY_1, menu, -1, "Menu Buy")
}
public forward_buy_menu_handler(id, key) {
if (key == 0) {
new player_has = zv_currency_get(id)
if (player_has >= get_pcvar_num(cvar_vip_price)) {
new duration
duration = get_cvar_duration(cvar_vip_buy_duration)
if (duration == -1) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "SERVER_CONFIG_ERROR")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "SERVER_CONFIG_ERROR")
print_admin_contacts(id)
return;
}
zv_currency_set(id, player_has-get_pcvar_num(cvar_vip_price))
native_zv_set_user_flags(id, duration, _get_pcvar_flags(cvar_vip_buy_flags))
if (duration >= 0) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "PURCHASED_VIP")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "PURCHASED_VIP")
}
else {
if (duration == ZV_DURATION_TILL_MAP) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "PURCHASED_VIP_TILL_MD")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "PURCHASED_VIP_TILL_MD")
}
else if (duration == ZV_DURATION_TILL_DISCONNECT) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "PURCHASED_VIP_TILL_D")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "PURCHASED_VIP_TILL_D")
}
}
client_cmd(id, "spk /sound/buttons/bell1.wav")
}
else {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L %L!", id, "NOT_ENOUGHT", id,\
zv_get_currency()==CURRENCY_AMMO_PACKS?"AMMO_ PACKS":"MONEY")
else _client_print_color(id, "^4[ZMVIP] ^1%L %L!", id, "NOT_ENOUGHT", id,\
zv_get_currency()==CURRENCY_AMMO_PACKS?"AMMO_ PACKS":"MONEY")
client_cmd(id, "spk /sound/buttons/blip1.wav")
}
}
}
//////////////////////// VIP MENU FUNCTIONS //////////////////////
public show_vip_menu_console(id) {
show_vip_menu(id)
return PLUGIN_HANDLED;
}
public show_vip_menu(id) {
#if EXTRA_ITEMS == OFF
if (p_data[id][FLAGS]) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "ALREADY_VIP_INFO")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "ALREADY_VIP_INFO")
}
else if (get_pcvar_num(cvar_vip_price) > 0) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "YOU_ARE_NOT_VIP")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "YOU_ARE_NOT_VIP")
show_buy_menu(id)
return PLUGIN_CONTINUE;
}
else {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "YOU_ARE_NOT_VIP_INFO")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "YOU_ARE_NOT_VIP_INFO")
return PLUGIN_CONTINUE;
}
#else
if (!ATTRIB(id, AT_EXTRA_ITEMS)) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "YOU_ARE_NOT_VIP_MENU")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "YOU_ARE_NOT_VIP_MENU")
show_buy_menu(id)
return PLUGIN_CONTINUE;
}
new maximum = get_pcvar_num(cvar_buys_per_round)
if (maximum && p_bought_per_round[id] > maximum) {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L", id, "EXCEEDED_BUY_LIMIT", maximum)
else _client_print_color(id, "^4[ZMVIP] ^1%L", id, "EXCEEDED_BUY_LIMIT", maximum)
return PLUGIN_CONTINUE;
}
#if MODIFICATION == NEW
if (is_user_alive(id)) {
p_views_extra_items_menu[id] = true
zp_items_show_menu(id)
p_views_extra_items_menu[id] = false
}
else {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "NOT_ALIVE")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "NOT_ALIVE")
}
#else
if(registered_extra_items_num) {
new item_data[item_struct], item_string[250], menu_header[40]
formatex(menu_header, charsmax(menu_header), "\r%L:", id, "VIP_MENU_TOP")
new menu = menu_create(menu_header, "show_vip_menu_handler")
new bool:special = is_special_character(id)?true:false;
new info[5]
for(new i=0; i<registered_extra_items_num; i++) {
ArrayGetArray(array_vip_extra_items, i, item_data)
if (item_data[item_team] > 0
&& (item_data[item_team]&ZP_TEAM_ZOMBIE && !p_zombie[id])
|| (item_data[item_team]&ZP_TEAM_HUMAN && p_zombie[id])
|| (item_data[item_team]&(ZP_TEAM_NEMESIS|ZP_TEAM_SURVIVOR) && !special)
)
continue;
formatex(item_string, charsmax(item_string), "%s \y%d %L", \
item_data[item_name], item_data[item_cost], id, zv_get_currency()==CURRENCY_AMMO_PACKS?"AMMO_ PACKS":"MONEY")
num_to_str(i, info, charsmax(info))
menu_additem(menu, item_string, info)
}
if(menu_items(menu)) menu_display(id, menu, 0)
else {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "NO_ITEMS_FOR_TEAM")
else _client_print_color(id, "^4[ZMVIP] ^3%L.", id, "NO_ITEMS_FOR_TEAM")
}
}
else {
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L.", id, "NO_PLUGINS_LOADED")
else _client_print_color(id, "^4[ZMVIP] ^1%L.", id, "NO_PLUGINS_LOADED")
}
#endif
#endif
static timeleft[100]
convert_duration_to_string(id, max(p_data[id][TIMESTAMP]-get_systime(), 0), timeleft, charsmax(timeleft))
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1VIP %L: ^3%s", id, "TIMELEFT", timeleft)
else _client_print_color(id, "^4[ZMVIP] ^1VIP %L: ^3%s", id, "TIMELEFT", timeleft)
return PLUGIN_CONTINUE
}
#if MODIFICATION != NEW && EXTRA_ITEMS == ON
public show_vip_menu_handler(id, menu, item)
{
if(item == MENU_EXIT )
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new item_id, _blank, info[5]
menu_item_getinfo(menu, item, _blank, info, charsmax(info), "", _blank, _blank)
item_id = str_to_num(info)
new retval, item_data[item_struct]
ArrayGetArray(array_vip_extra_items, item_id, item_data)
if (chached_show_vip_items)
ExecuteForward(fw_extraitemselected, retval, id, item_data[item_plid])
else
ExecuteForward(fw_extraitemselected, retval, id, item_id)
if (retval < ZP_PLUGIN_HANDLED) {
zv_currency_set(id, zv_currency_get(id)-item_data[item_cost])
if (is_amxmodx_new_version) client_print_color(id, id, "^4[ZMVIP] ^1%L '^4%s^1'", id, "PURCHASED", item_data[item_name])
else _client_print_color(id, "^4[ZMVIP] ^1%L '^4%s^1'", id, "PURCHASED", item_data[item_name])
p_bought_per_round[id]++
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
#endif
public vip_time_check() {
static id, timestamp
timestamp = get_systime()
for (id=1; id<33; id++) {
if (p_data[id][TIMESTAMP] > 0 && p_data[id][TIMESTAMP] < timestamp) {
native_zv_remove_user_flags(id)
}
}
}
is_special_character(id) {
if(p_zombie[id]) {
#if MODIFICATION == NEW
if(!(natives_filter_out & BIT(NATIVE_ZP_CLASS_NEMESIS_GET)) && zp_class_nemesis_get(id)
|| !(natives_filter_out & BIT(NATIVE_ZP_CLASS_ASSASSIN_GET)) && zp_class_assassin_get(id)
)
return true;
#else
if(zp_get_user_nemesis(id)
|| !(natives_filter_out & BIT(NATIVE_ZP_CLASS_BOMBARDIER_GET)) && zp_get_user_bombardier(id)
)
return true;
#endif
}
else {
#if MODIFICATION == NEW
if(!(natives_filter_out & BIT(NATIVE_ZP_CLASS_SURVIVOR_GET)) && zp_class_survivor_get(id)
|| !(natives_filter_out & BIT(NATIVE_ZP_CLASS_SNIPER_GET)) && zp_class_sniper_get(id)
)
return true;
#else
return zp_get_user_survivor(id)
#endif
}
return false;
}
check_named_privileges(id, nick[], pass[]) {
new num
if (!array_vips_database_nick || !(num = VIPCNT(NAMES))) {
p_data[id][SETTINGS] = 0
p_data[id][FLAGS] = 0
return false;
}
for (new index=0; index<num; index++) {
ArrayGetArray(array_vips_database_nick, index, p_data[id])
if (p_data[id][SETTINGS] & FLAG_C) {
if (((p_data[id][SETTINGS]&FLAG_N)?contain(nick, p_data[id][AUTH]):containi(nick, p_data[id][AUTH])) == -1)
continue;
}
else {
if (!((p_data[id][SETTINGS]&FLAG_N)?equal(nick, p_data[id][AUTH]):equali(nick, p_data[id][AUTH])))
continue;
}
if (!EMPTY(p_data[id][PASS])) {
p_data[id][PASS][charsmax(p_data[][PASS])] = EOS
if (!equal(p_data[id][PASS], pass)) {
if (p_data[id][SETTINGS] & FLAG_K) {
return false;
}
else {
client_print(id, print_console, "[ZMVIP] %L.", id, "PASS_NOT_MATCH")
continue;
}
}
}
p_data[id][INDEX] = index
return true;
}
p_data[id][SETTINGS] = 0
p_data[id][FLAGS] = 0
return false;
}
public cmd_vips_remove(id, level, cid) {
if(id != 0 && !(get_user_flags(id) & level))
return PLUGIN_HANDLED;
if (read_argc() < 1) {
console_print(id, "[ZM VIP] %L: zm_vip_remove <NICK/AUTH/IP>.", id, "USAGE")
return PLUGIN_HANDLED;
}
new argument[40]
read_argv(1, argument, charsmax(argument))
new player = cmd_target(id, argument, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF| CMDTARGET_NO_BOTS)
if (!player)
return PLUGIN_HANDLED;
new name[40]
get_user_name(player, name, charsmax(name))
if (!p_data[player][FLAGS]) {
console_print(id, "[ZM VIP] %L", id, "DOES_NOT_HAVE_VIP", name)
return PLUGIN_HANDLED;
}
if (native_zv_remove_user_flags(player))
console_print(id, "[ZM VIP] %L.", id, "PRIVILEGE_REMOVED", name)
else
console_print(id, "[ZM VIP] %L.", id, "PLUGIN_ERROR_REMOVING", name)
return PLUGIN_HANDLED;
}
public cmd_vips_reload(id, level, cid) {
if(id != 0 && !(get_user_flags(id) & level))
return PLUGIN_HANDLED;
server_cmd("amx_reloadadmins")
server_exec()
TrieClear(trie_vips_database)
ArrayClear(array_vips_database)
if (array_vips_database_nick)
ArrayClear(array_vips_database_nick)
arrayset(total_vips_count, 0, sizeof(total_vips_count))
#if VIPS_FILE_SYSTEM != OFF
load_ini_file()
#endif
load_datafile()
#if VIPS_FILE_SYSTEM != FORCED
new num_admins = admins_num()
for (new i=0; i<num_admins; i++) {
if (admins_lookup(i, AdminProp_Access)&VIP_SYS_FLAG) {
VIPINC(AMX)
}
}
#endif
new players[32], num_players, i
get_players(players, num_players, "ch")
for (i=0; i<num_players; i++) {
VipsDBGet(players[i])
}
if (id) {
static authid[30], ip[30], name[45]
get_user_name(id, name, charsmax(name))
get_user_authid(id, authid, charsmax(authid))
get_user_ip(id, ip, charsmax(ip), 1)
log_amx("Cmd exec: zm_vip_reload. By: %s (%s) (%s)", name, authid, ip)
}
else
log_amx("Cmd exec: zm_vip_reload. From server console")
console_print(id, "[ZM VIP] Reloaded %d vips", VIPCNT(DAT)+VIPCNT(INI)+VIPCNT(AMX))
return PLUGIN_HANDLED;
}
public cmd_list_vips(id, level, cid) {
if(id != 0 && !(get_user_flags(id) & level))
return PLUGIN_HANDLED;
new key[40], i, size = ArraySize(array_vips_database)
new data[vips_database_type]
console_print(id, "Main VIPs: %d", VIPCNT(MAIN)+VIPCNT(NAMES))
new load_types[][] = {"DAT", "INI", "AMX"}
new load_type, flags_str[30], time_str[25]
for (i=0; i<size; i++) {
ArrayGetString(array_vips_database, i, key, sizeof(key))
if (EMPTY(key))
continue;
if (!TrieGetArray(trie_vips_database, key, data, vips_database_type))
continue;
if (data[SETTINGS] & LOAD_FROM_DAT)
load_type = 0
#if VIPS_FILE_SYSTEM != OFF
if (data[SETTINGS] & LOAD_FROM_INI)
load_type = 1
#endif
#if VIPS_FILE_SYSTEM != FORCED
if (data[SETTINGS] & LOAD_FROM_AMX)
load_type = 2
#endif
flags_str[0] = EOS
time_str[0] = EOS
if (data[FLAGS] == -1)
add(flags_str, charsmax(flags_str), "All")
else
get_flags(data[FLAGS], flags_str, charsmax(flags_str))
if (data[TIMESTAMP] == ZV_DURATION_PERMANENT)
add(time_str, charsmax(time_str), "Permanent")
else if (data[TIMESTAMP] == ZV_DURATION_TILL_DISCONNECT)
add(time_str, charsmax(time_str), "Disconnect")
else if (data[TIMESTAMP] == ZV_DURATION_TILL_MAP)
add(time_str, charsmax(time_str), "Map change")
else
format_time(time_str, charsmax(time_str), "%Y/%m/%d-%H:%M", data[TIMESTAMP])
console_print(id, "%s| ^"%s^" ^"%s^" ^"%s^"", load_types[load_type],
data[AUTH], flags_str, time_str)
}
if (array_vips_database_nick) {
size = ArraySize(array_vips_database_nick)
for (i=0; i<size; i++) {
ArrayGetArray(array_vips_database_nick, i, data)
if (data[SETTINGS] & LOAD_FROM_DAT)
load_type = 0
#if VIPS_FILE_SYSTEM != OFF
if (data[SETTINGS] & LOAD_FROM_INI)
load_type = 1
#endif
#if VIPS_FILE_SYSTEM != FORCED
if (data[SETTINGS] & LOAD_FROM_AMX)
load_type = 2
#endif
if (data[FLAGS] == -1)
add(flags_str, charsmax(flags_str), "All")
else
get_flags(data[FLAGS], flags_str, charsmax(flags_str))
if (data[TIMESTAMP] == ZV_DURATION_PERMANENT)
add(time_str, charsmax(time_str), "Permanent")
else if (data[TIMESTAMP] == ZV_DURATION_TILL_DISCONNECT)
add(time_str, charsmax(time_str), "Disconnect")
else if (data[TIMESTAMP] == ZV_DURATION_TILL_MAP)
add(time_str, charsmax(time_str), "Map change")
else
format_time(time_str, charsmax(time_str), "%Y/%m/%d-%H:%M", data[TIMESTAMP])
console_print(id, "%s| ^"%s^" ^"%s^" ^"%s^"", load_types[load_type],
data[AUTH], flags_str, time_str)
}
}
#if VIPS_FILE_SYSTEM != FORCED
console_print(id, "Amx VIPs: %d", VIPCNT(AMX))
new num_admins = admins_num()
for (new i=0; i<num_admins; i++) {
if (admins_lookup(i, AdminProp_Access)&VIP_SYS_FLAG) {
new auth[40]
admins_lookup(i, AdminProp_Auth, auth, charsmax(auth))
console_print(id, "AMX| ^"%s^"", auth)
}
}
#endif
return PLUGIN_HANDLED;
}
public set_freevip_hour(id, level, cid) {
if(id != 0 && !(get_user_flags(id) & level))
return PLUGIN_HANDLED;
if (read_argc() < 2) {
if (freevip_enabled)
console_print(id, "^"zm_vip_freevip_hour^" is ^"%d:%d-%d:%d^"", \
freevip_hours[0], freevip_hours[1], freevip_hours[2], freevip_hours[3])
else
console_print(id, "^"zm_vip_freevip_hour^" is ^"off^"")
return PLUGIN_HANDLED;
}
new string[12], index
read_argv(1, string, charsmax(string))
if(string[0] == 'o' || (string[0] == '0' && string[1] == EOS)) {
freevip_enabled = false
return PLUGIN_HANDLED;
}
if (string[2] == ':') {
freevip_hours[0] = (string[0]-'0')*10+(string[1]-'0')
freevip_hours[1] = (string[3]-'0')*10+(string[4]-'0')
index = 5
}
else if (string[1] == ':') {
freevip_hours[0] = (string[0]-'0')
freevip_hours[1] = (string[2]-'0')*10+(string[3]-'0')
index = 4
}
else {
log_amx("ERROR: Inccorect zm_freevip_hour cvar value! Set correctly, or turn off by typing ^"off^".")
return PLUGIN_HANDLED;
}
if (freevip_hours[0] >= 24 || freevip_hours[1] >= 60) {
log_amx("ERROR: Inccorect zm_freevip_hour cvar value! Set correctly, or turn off by typing ^"off^".")
return PLUGIN_HANDLED;
}
if (string[index++] != '-') {
log_amx("ERROR: Inccorect zm_freevip_hour cvar value! Set correctly, or turn off by typing ^"off^".")
return PLUGIN_HANDLED;
}
if (string[index+2] == ':') {
freevip_hours[2] = (string[index]-'0')*10+(string[index+1]-'0')
freevip_hours[3] = (string[index+3]-'0')*10+(string[index+4]-'0')
}
else if (string[index+1] == ':') {
freevip_hours[2] = (string[index]-'0')
freevip_hours[3] = (string[index+2]-'0')*10+(string[index+3]-'0')
}
else {
log_amx("ERROR: Inccorect zm_freevip_hour cvar value! Set correctly, or turn off by typing ^"off^".")
return PLUGIN_HANDLED;
}
if (freevip_hours[2] >= 24 || freevip_hours[3] >= 60) {
log_amx("ERROR: Inccorect zm_freevip_hour cvar value! Set correctly, or turn off by typing ^"off^".")
return PLUGIN_HANDLED;
}
freevip_enabled = true
return PLUGIN_HANDLED;
}
freevip_hour_check() {
if (freevip_hours[0] == freevip_hours[2] && freevip_hours[1] == freevip_hours[3]) {
return true;
}
new h, m, s
time(h, m, s)
new hour_low, hour_high
hour_low = freevip_hours[0]*100+freevip_hours[1]
hour_high = freevip_hours[2]*100+freevip_hours[3]
if ((hour_low <= (h*100+m) < hour_high) || (hour_high <= (h*100+m) < hour_low))
|
Last edited by MaXs; 01-21-2017 at 04:28.
|
|