Knife :-viewtopic.php?t=141
Knife Menu Code:-
- #include <zombie_escape>
- // Models
- new const Compat_Models[][] =
- {
- "models/zombie_escape/v_combat_knife.mdl",
- "models/zombie_escape/p_combat_knife.mdl"
- }
- new const Strong_Models[][] =
- {
- "models/zombie_escape/v_strong_knife.mdl",
- "models/zombie_escape/p_strong_knife.mdl"
- }
- new const Katana_Models[][] =
- {
- "models/zombie_escape/v_katana_knife.mdl",
- "models/zombie_escape/p_katana_knife.mdl"
- }
- new const Hammer_Models[][] =
- {
- "models/zombie_escape/v_hammer_knife.mdl",
- "models/zombie_escape/p_hammer_knife.mdl"
- }
- // Sounds
- new const g_sound_knife[] = "items/gunpickup2.wav"
- new const combat_sounds[][] =
- {
- "zombie_escape/knife_menu/combat_deploy.wav",
- "zombie_escape/knife_menu/combat_hit.wav",
- "zombie_escape/knife_menu/combat_hit.wav",
- "zombie_escape/knife_menu/combat_hit.wav",
- "zombie_escape/knife_menu/combat_hit.wav",
- "zombie_escape/knife_menu/combat_hitwall.wav",
- "zombie_escape/knife_menu/combat_slash.wav",
- "zombie_escape/knife_menu/combat_slash.wav",
- "zombie_escape/knife_menu/combat_stab.wav"
- }
- new const strong_sounds[][] =
- {
- "zombie_escape/knife_menu/strong_deploy.wav",
- "zombie_escape/knife_menu/strong_hit.wav",
- "zombie_escape/knife_menu/strong_hit.wav",
- "zombie_escape/knife_menu/strong_hit.wav",
- "zombie_escape/knife_menu/strong_hit.wav",
- "zombie_escape/knife_menu/strong_hitwall.wav",
- "zombie_escape/knife_menu/strong_slash.wav",
- "zombie_escape/knife_menu/strong_slash.wav",
- "zombie_escape/knife_menu/strong_stab.wav"
- }
- new const katana_sounds[][] =
- {
- "zombie_escape/knife_menu/katana_deploy.wav",
- "zombie_escape/knife_menu/katana_hit.wav",
- "zombie_escape/knife_menu/katana_hit.wav",
- "zombie_escape/knife_menu/katana_hit.wav",
- "zombie_escape/knife_menu/katana_hit.wav",
- "zombie_escape/knife_menu/katana_hitwall.wav",
- "zombie_escape/knife_menu/katana_slash.wav",
- "zombie_escape/knife_menu/katana_slash.wav",
- "zombie_escape/knife_menu/katana_stab.wav"
- }
- new const hammer_sounds[][] =
- {
- "zombie_escape/knife_menu/hammer_deploy.wav",
- "zombie_escape/knife_menu/hammer_hit.wav",
- "zombie_escape/knife_menu/hammer_hit.wav",
- "zombie_escape/knife_menu/hammer_hit.wav",
- "zombie_escape/knife_menu/hammer_hit.wav",
- "zombie_escape/knife_menu/hammer_hitwall.wav",
- "zombie_escape/knife_menu/hammer_slash.wav",
- "zombie_escape/knife_menu/hammer_slash.wav",
- "zombie_escape/knife_menu/hammer_stab.wav"
- }
- new const oldknife_sounds[][] =
- {
- "weapons/knife_deploy1.wav",
- "weapons/knife_hit1.wav",
- "weapons/knife_hit2.wav",
- "weapons/knife_hit3.wav",
- "weapons/knife_hit4.wav",
- "weapons/knife_hitwall1.wav",
- "weapons/knife_slash1.wav",
- "weapons/knife_slash2.wav",
- "weapons/knife_stab.wav"
- }
- new bool:g_bCompat[33], bool:g_bStrong[33], bool:g_bKatana[33], bool:g_bHammer[33],
- g_iUsedTimes[33], g_pCvarUseTimes
- public plugin_precache()
- {
- new i
- for (i = 0; i <= charsmax(Compat_Models); i++)
- precache_model(Compat_Models[i])
- for (i = 0; i <= charsmax(Hammer_Models); i++)
- precache_model(Hammer_Models[i])
- for (i = 0; i <= charsmax(Katana_Models); i++)
- precache_model(Katana_Models[i])
- for (i = 0; i <= charsmax(Strong_Models); i++)
- precache_model(Strong_Models[i])
- for (i = 0; i <= charsmax(combat_sounds); i++)
- precache_sound(combat_sounds[i])
- for (i = 0; i <= charsmax(strong_sounds); i++)
- precache_sound(strong_sounds[i])
- for (i = 0; i <= charsmax(katana_sounds); i++)
- precache_sound(katana_sounds[i])
- for (i = 0; i <= charsmax(hammer_sounds); i++)
- precache_sound(hammer_sounds[i])
- precache_sound(g_sound_knife)
- }
- public plugin_natives()
- {
- register_native("ze_open_knife_menu", "native_ze_open_knife_menu", 1)
- }
- public plugin_init()
- {
- register_plugin("[ZE] Addon: Knife Menu", "1.2", "Jack GamePlay")
- register_forward(FM_EmitSound, "fw_EmitSound")
- register_event("CurWeapon", "CurrentWeapon", "be", "1=1")
- g_pCvarUseTimes = register_cvar("ze_knife_menu_use_times", "4")
- register_message(get_user_msgid("DeathMsg"), "DeathMsg")
- register_clcmd("say /knife", "Show_Knife_Menu")
- }
- public ze_user_humanized(id)
- {
- g_iUsedTimes[id] = 0
- }
- public ze_user_infected(Victim)
- {
- g_bCompat[Victim] = false
- g_bStrong[Victim] = false
- g_bKatana[Victim] = false
- g_bHammer[Victim] = false
- g_iUsedTimes[Victim] = 0
- }
- public client_putinserver(id)
- {
- g_bCompat[id] = false
- g_bStrong[id] = false
- g_bKatana[id] = false
- g_bHammer[id] = false
- g_iUsedTimes[id] = 0
- }
- public client_disconnected(id)
- {
- g_bCompat[id] = false
- g_bStrong[id] = false
- g_bKatana[id] = false
- g_bHammer[id] = false
- g_iUsedTimes[id] = 0
- }
- public Show_Knife_Menu(id)
- {
- if (!is_user_connected(id))
- return PLUGIN_CONTINUE
- if (ze_is_user_zombie(id))
- {
- ze_colored_print(id, "!tZombies can't open knife menu!y.")
- return PLUGIN_HANDLED
- }
- if (g_iUsedTimes[id] >= get_pcvar_num(g_pCvarUseTimes))
- {
- ze_colored_print(id, "!tMaximum have been reached !y[!g%d!y]!", get_pcvar_num(g_pCvarUseTimes))
- return PLUGIN_HANDLED
- }
- if (!is_user_alive(id))
- {
- ze_colored_print(id, "!tDead can't open knife menu!y.")
- return PLUGIN_HANDLED
- }
- Knife_Menu(id)
- return PLUGIN_CONTINUE
- }
- public Knife_Menu(id)
- {
- new iMenu = menu_create("\rChoose Your Knife\w:", "Menu_Handler")
- menu_additem(iMenu, "\yCombat", "", 0)
- menu_additem(iMenu, "\yStrong", "", 0)
- menu_additem(iMenu, "\yKatana", "", 0)
- menu_additem(iMenu, "\yHammer", "", 0)
- menu_setprop(iMenu, MPROP_EXIT, MEXIT_ALL)
- menu_display(id, iMenu, 0)
- }
- public Menu_Handler(id, iMenu, iKey)
- {
- if(!is_user_alive(id) || ze_is_user_zombie(id))
- return PLUGIN_HANDLED
- switch(iKey)
- {
- case 0: // Compat
- {
- g_bCompat[id] = true
- g_bStrong[id] = false
- g_bKatana[id] = false
- g_bHammer[id] = false
- /*rg_remove_item(id, "weapon_knife")
- rg_give_item(id, "weapon_knife", GT_APPEND)
- engclient_cmd(id, "weapon_knife")
- g_iUsedTimes[id]++
- emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
- }
- case 1: // Strong
- {
- g_bCompat[id] = false
- g_bStrong[id] = true
- g_bKatana[id] = false
- g_bHammer[id] = false
- /*rg_remove_item(id, "weapon_knife")
- rg_give_item(id, "weapon_knife", GT_APPEND)
- engclient_cmd(id, "weapon_knife")
- g_iUsedTimes[id]++
- emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
- }
- case 2: // Katana
- {
- g_bCompat[id] = false
- g_bStrong[id] = false
- g_bKatana[id] = true
- g_bHammer[id] = false
- /*rg_remove_item(id, "weapon_knife")
- rg_give_item(id, "weapon_knife", GT_APPEND)
- engclient_cmd(id, "weapon_knife")
- g_iUsedTimes[id]++
- emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
- }
- case 3: // Hammer
- {
- g_bCompat[id] = false
- g_bStrong[id] = false
- g_bKatana[id] = false
- g_bHammer[id] = true
- g_iUsedTimes[id]++
- /*rg_remove_item(id, "weapon_knife")
- rg_give_item(id, "weapon_knife", GT_APPEND)
- engclient_cmd(id, "weapon_knife")
- g_iUsedTimes[id]++
- emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)*/
- }
- }
- rg_remove_item(id, "weapon_knife")
- rg_give_item(id, "weapon_knife", GT_APPEND)
- engclient_cmd(id, "weapon_knife")
- g_iUsedTimes[id]++
- emit_sound(id, CHAN_BODY, g_sound_knife, 1.0, ATTN_NORM, 0, PITCH_NORM)
- menu_destroy(iMenu)
- return PLUGIN_HANDLED
- }
- public fw_EmitSound(id, channel, const sound[])
- {
- if(!is_user_alive(id) || ze_is_user_zombie(id))
- return FMRES_IGNORED
- new i
- for (i = 0; i <= charsmax(combat_sounds); i++)
- for (i = 0; i <= charsmax(strong_sounds); i++)
- for (i = 0; i <= charsmax(katana_sounds); i++)
- for (i = 0; i <= charsmax(hammer_sounds); i++)
- {
- if(equal(sound, oldknife_sounds[i]))
- {
- if (g_bCompat[id])
- {
- emit_sound(id, channel, combat_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
- return FMRES_SUPERCEDE
- }
- else if (g_bStrong[id])
- {
- emit_sound(id, channel, strong_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
- return FMRES_SUPERCEDE
- }
- else if (g_bKatana[id])
- {
- emit_sound(id, channel, katana_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
- return FMRES_SUPERCEDE
- }
- else if (g_bHammer[id])
- {
- emit_sound(id, channel, hammer_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
- return FMRES_SUPERCEDE
- }
- else if (!g_bCompat[id] || !g_bStrong[id] || !g_bKatana[id] || !g_bHammer[id])
- {
- emit_sound(id, channel, oldknife_sounds[i], 1.0, ATTN_NORM, 0, PITCH_NORM)
- return FMRES_SUPERCEDE
- }
- }
- }
- return FMRES_IGNORED
- }
- public CurrentWeapon(id)
- {
- if(!is_user_alive(id) || ze_is_user_zombie(id))
- return
- if(get_user_weapon(id) & CSW_KNIFE)
- {
- if(g_bCompat[id])
- {
- cs_set_player_view_model(id, CSW_KNIFE, Compat_Models[0])
- cs_set_player_weap_model(id, CSW_KNIFE, Compat_Models[1])
- }
- else if(g_bStrong[id])
- {
- cs_set_player_view_model(id, CSW_KNIFE, Strong_Models[0])
- cs_set_player_weap_model(id, CSW_KNIFE, Strong_Models[1])
- }
- else if(g_bKatana[id])
- {
- cs_set_player_view_model(id, CSW_KNIFE, Katana_Models[0])
- cs_set_player_weap_model(id, CSW_KNIFE, Katana_Models[1])
- }
- else if(g_bHammer[id])
- {
- cs_set_player_view_model(id, CSW_KNIFE, Hammer_Models[0])
- cs_set_player_weap_model(id, CSW_KNIFE, Hammer_Models[1])
- }
- else
- {
- cs_reset_player_view_model(id, CSW_KNIFE)
- cs_reset_player_weap_model(id, CSW_KNIFE)
- }
- }
- }
- public DeathMsg(msg_id, msg_dest, id)
- {
- static szTruncatedWeapon[33], iAttacker
- get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
- iAttacker = get_msg_arg_int(1)
- if(!is_user_alive(iAttacker) || iAttacker == get_msg_arg_int(2) || !is_user_alive(get_msg_arg_int(2))) // get_msg_arg_int(2) = iVictim
- return
- if(equal(szTruncatedWeapon, "knife") && get_user_weapon(iAttacker) & CSW_KNIFE)
- {
- if(g_bCompat[id])
- {
- set_msg_arg_string(4, "Combat knife")
- }
- else if(g_bStrong[id])
- {
- set_msg_arg_string(4, "Strong knife")
- }
- else if(g_bKatana[id])
- {
- set_msg_arg_string(4, "Katana knife")
- }
- else if(g_bHammer[id])
- {
- set_msg_arg_string(4, "Ice knife")
- }
- }
- }
- public native_ze_open_knife_menu(id)
- {
- Show_Knife_Menu(id)
- }
- #include <zombie_escape>
- #include <ze_vip>
- // Defines - Comment MULTIJUMP or PARACHUTE, so you don't need to run multijump/parachute plugin.
- #define VIP_MESSAGES VIP_A
- #define MULTIJUMP VIP_B
- #define PARACHUTE VIP_C
- #define SCOREBOARD VIP_D
- #define DAMAGE VIP_E
- #define NON_VIP VIP_Z
- #if defined PARACHUTE
- #include <ze_parachute>
- #endif
- #if defined MULTIJUMP
- #include <ze_multijump>
- #endif
- // Variables
- new g_szPasswordKey[65],
- g_szPassword[65],
- bool:g_bIsUserVIP[33],
- bool:g_bSetVIP[33],
- g_iFlags[33],
- bool:g_bIsHappyHour,
- g_iMaxPlayers
- // Const.
- static const g_szLocalFile[] = "addons/amxmodx/configs/ze_vips.ini"
- new const szCommands[][] =
- {
- "say /vip",
- "say /vips",
- "say_team /vip",
- "say_team /vips"
- }
- // Cvars
- new g_pCvarVIPScoreboard,
- g_pCvarConnectMessage,
- g_pCvarAdminContact,
- g_pCvarEnableHappyHours,
- g_pCvarHappyHours,
- g_pCvarHappyHoursFlags,
- g_pCvarDamage
- #if defined PARACHUTE
- new g_pCvarParachute
- #endif
- #if defined MULTIJUMP
- new g_pCvarMultijump
- #endif
- public plugin_natives()
- {
- register_native("ze_get_vip_flags", "native_ze_get_vip_flags", 1)
- register_native("ze_set_vip_flags", "native_ze_set_vip_flags", 1)
- register_native("ze_is_user_vip", "native_ze_is_user_vip", 1)
- }
- public plugin_init()
- {
- register_plugin("[ZE] Zombie Escape VIP", VIP_VERSION, AUTHORS)
- // Hookchain
- RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Pre", 0)
- // Cvars
- g_pCvarConnectMessage = register_cvar("ze_connect_message", "1")
- g_pCvarAdminContact = register_cvar("ze_admin_contact", "Admin Name")
- g_pCvarVIPScoreboard = register_cvar("ze_show_vip_scoreboard", "1")
- g_pCvarEnableHappyHours = register_cvar("ze_enable_happy_hours", "1")
- g_pCvarHappyHours = register_cvar("ze_vip_happy_hours", "9-12")
- g_pCvarHappyHoursFlags = register_cvar("ze_happy_hours_vip_flags", "abcd")
- g_pCvarDamage = register_cvar("ze_vip_multiply_damage", "1.2")
- #if defined MULTIJUMP
- g_pCvarMultijump = register_cvar("ze_give_vip_multijump", "1")
- #endif
- #if defined PARACHUTE
- g_pCvarParachute = register_cvar("ze_give_vip_parachute", "1")
- #endif
- register_cvar("ze_vip_version", VIP_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
- set_cvar_string("ze_vip_version", VIP_VERSION)
- // Commands
- for (new i = 0; i < charsmax(szCommands); i++)
- register_clcmd(szCommands[i], "CmdVIP")
- register_clcmd("say /getvip", "CmdMotd")
- register_clcmd("say_team /getvip", "CmdMotd")
- // Get Password Key
- get_cvar_string("amx_password_field", g_szPasswordKey, charsmax(g_szPasswordKey))
- // Initialize Arrays
- arrayset(g_bIsUserVIP, false, 32)
- arrayset(g_bSetVIP, false, 32)
- // Get max players
- g_iMaxPlayers = get_member_game(m_nMaxPlayers)
- }
- public plugin_cfg()
- {
- // Get our configiration file and Execute it
- new szCfgDir[64]
- get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir))
- server_cmd("exec %s/ze_vip.cfg", szCfgDir)
- }
- public Fw_TakeDamage_Pre(iVictim, iInflictor, iAttacker, Float:flDamage, bitsDamageType)
- {
- if (!is_user_alive(iVictim) || !is_user_alive(iAttacker))
- return HC_CONTINUE
- if (!(ze_get_vip_flags(iAttacker) & DAMAGE) || get_pcvar_num(g_pCvarDamage) == 0)
- return HC_CONTINUE
- SetHookChainArg(4, ATYPE_FLOAT, flDamage * get_pcvar_float(g_pCvarDamage))
- return HC_CONTINUE
- }
- public client_authorized(id)
- {
- // Get password from Setinfo
- new szPassword[65]
- get_user_info(id, g_szPasswordKey, szPassword, charsmax(szPassword))
- // Player VIP?
- ze_get_vip_flags(id)
- if (g_bIsUserVIP[id])
- {
- if (!equal(szPassword, g_szPassword))
- {
- // VIP and wrong Password? Kick him
- client_cmd(id, "echo ^"* VIP Invalid Password!^"")
- server_cmd("kick #%d ^"You have no entry to the server...^"", get_user_userid(id))
- }
- else
- {
- client_cmd(id, "echo ^"* VIP Password Accepted!^"")
- }
- }
- }
- public client_putinserver(id)
- {
- if (ze_get_vip_flags(id) & VIP_MESSAGES)
- {
- if (get_pcvar_num(g_pCvarConnectMessage) != 0)
- {
- new szName[32]
- get_user_name(id, szName, charsmax(szName))
- ze_colored_print(0, "!tVIP !g%s !thas connected to the server!y.", szName)
- }
- }
- }
- public CmdMotd(id)
- {
- show_motd(id, "ze_vip.txt", "Zombie Escape VIP")
- }
- public CmdVIP(id)
- {
- set_task(0.1, "Print_List")
- }
- public Print_List()
- {
- Print_VIP_List()
- }
- public Print_VIP_List()
- {
- new szVIPName[33][32], szMessage[700], szContact[256]
- new iPlayer, i, iVIPCount = 0, iLen = 0;
- for (iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++)
- {
- if (!is_user_connected(iPlayer))
- continue
- if (ze_get_vip_flags(iPlayer) & VIP_MESSAGES)
- {
- get_user_name(iPlayer, szVIPName[iVIPCount], charsmax(szVIPName))
- iVIPCount++
- }
- }
- iLen = formatex(szMessage, charsmax(szMessage), "^4VIPs ONLINE^1: ")
- if (iVIPCount > 0)
- {
- for (i = 0; i <= iVIPCount; i++)
- {
- iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "^3%s^1%s^3", szVIPName[i], (i < (iVIPCount - 1)) ? ", " : "")
- }
- }
- else
- {
- szMessage = "^4No VIPs online^1."
- }
- client_print_color(0, print_team_default, szMessage)
- get_pcvar_string(g_pCvarAdminContact, szContact, charsmax(szContact))
- if (szContact[0])
- {
- client_print_color(0, print_team_default, "^1- ^4Contact Server Admin ^1-- ^3%s", szContact)
- }
- }
- public ze_user_humanized(id)
- {
- if (!is_user_alive(id))
- return
- Happy_Hours()
- if (g_bIsHappyHour == true && get_pcvar_num(g_pCvarEnableHappyHours) != 0)
- {
- new szFlags[VIP_MAX_FLAGS]
- get_pcvar_string(g_pCvarHappyHoursFlags, szFlags, charsmax(szFlags))
- ze_set_vip_flags(id, read_flags(szFlags))
- }
- // Get password from Setinfo
- new szPassword[65]
- get_user_info(id, g_szPasswordKey, szPassword, charsmax(szPassword))
- ze_get_vip_flags(id)
- if (g_bIsUserVIP[id])
- {
- if (!equal(szPassword, g_szPassword))
- {
- // VIP and wrong Password? Kick him
- client_cmd(id, "echo ^"* VIP Invalid Password!^"")
- server_cmd("kick #%d ^"You have no entry to the server...^"", get_user_userid(id))
- }
- else
- {
- client_cmd(id, "echo ^"* VIP Password Accepted!^"")
- }
- }
- #if defined MULTIJUMP
- if (ze_get_vip_flags(id) & MULTIJUMP)
- {
- if (get_pcvar_num(g_pCvarMultijump) != 0)
- {
- ze_give_user_multijump(id)
- }
- }
- #endif
- #if defined PARACHUTE
- if (ze_get_vip_flags(id) & PARACHUTE)
- {
- if (get_pcvar_num(g_pCvarParachute) != 0)
- {
- ze_give_user_parachute(id)
- }
- }
- #endif
- set_task(0.1, "Update_Attribute", id, _, _, "a", 10)
- }
- public ze_roundend(WinTeam)
- {
- for (new i = 0; i < get_member_game(m_nMaxPlayers); i++)
- {
- g_bSetVIP[i] = false
- }
- }
- public Update_Attribute(id)
- {
- if ((ze_get_vip_flags(id) & SCOREBOARD) && get_pcvar_num(g_pCvarVIPScoreboard) != 0)
- {
- message_begin(MSG_ALL, get_user_msgid("ScoreAttrib"), {0, 0, 0}, id)
- write_byte(id)
- write_byte(4)
- message_end()
- }
- }
- public native_ze_get_vip_flags(id)
- {
- // Our file exists?
- if (file_exists(g_szLocalFile))
- {
- /*
- * We can't use new file system here, because if file opened it can not be deleted.
- * Old system provide the suitable way for doing it simply. That's a reason.
- */
- // Declare some useful variables
- new iMaxLines, szLineToRead[129], szParse[4][65], szName[32], szSteamID[36], iTextLen
- // Get max lines number in the file
- iMaxLines = file_size(g_szLocalFile, FSOPT_LINES_COUNT)
- // Get our player name and steamid
- get_user_authid(id, szSteamID, charsmax(szSteamID))
- get_user_name(id, szName, charsmax(szName))
- // Loop through the whole file
- for (new iLine = 0; iLine < iMaxLines; iLine++)
- {
- // Read line by line
- read_file(g_szLocalFile, iLine, szLineToRead, charsmax(szLineToRead), iTextLen)
- // Remove any space, useful to remove blank lines which only contain spaces
- trim(szLineToRead)
- // Check if string empty or starting with ; or // ignore the line
- if (strlen(szLineToRead) == 0 || szLineToRead[0] == ';' || (szLineToRead[0] == '/' && szLineToRead[1] == '/'))
- continue
- // Split our line by spaces to 4 parts: name or steam, password, flags, expire date
- parse(szLineToRead, szParse[0], charsmax(szParse[]), szParse[1], charsmax(szParse[]), szParse[2], charsmax(szParse[]), szParse[3], charsmax(szParse[]))
- // Remove all "" from our 4 parts
- remove_quotes(szParse[0])
- remove_quotes(szParse[1])
- remove_quotes(szParse[2])
- remove_quotes(szParse[3])
- // Check expire date for this steam/name (Steam/Name unique to check with)
- CheckDate(szParse[3], szParse[0])
- // Check if user in file is same who we check
- if (equali(szSteamID, szParse[0]) || equali(szName, szParse[0]))
- {
- // Player exists in the file, this means he is VIP
- g_bIsUserVIP[id] = true
- copy(g_szPassword, charsmax(g_szPassword), szParse[1])
- // Return his flags
- return read_flags(szParse[2])
- }
- }
- }
- else
- {
- // File not exists, then create it (Here we can use new file system without problems)
- new iFileHandler = fopen(g_szLocalFile, "wt")
- fputs(iFileHandler, "; Zombie Escape VIP^n^n")
- fputs(iFileHandler, ";Flags:^n^n")
- fputs(iFileHandler, "; a -- Connect Message and VIP List^n")
- fputs(iFileHandler, "; b -- Multi-Jump^n")
- fputs(iFileHandler, "; c -- Parachute^n")
- fputs(iFileHandler, "; d -- Scoreboard Attrib.^n")
- fputs(iFileHandler, "; e -- VIP Damage^n^n")
- fputs(iFileHandler, ";Usage Example:^n^n")
- fputs(iFileHandler, "; ^"Steam/Nick^" ^"Password^" ^"Flags^" ^"ExpireDate^"")
- fclose(iFileHandler)
- }
- g_bIsUserVIP[id] = false
- if (g_bSetVIP[id] == true)
- {
- return g_iFlags[id]
- }
- else
- {
- return NON_VIP
- }
- }
- public native_ze_set_vip_flags(id, Flags)
- {
- g_bSetVIP[id] = true
- g_iFlags[id] = Flags
- ze_get_vip_flags(id)
- }
- public native_ze_is_user_vip(id)
- {
- if (ze_get_vip_flags(id) & VIP_Z)
- return false
- return true
- }
- /*
- * Dedicated stock for our plugin, to delete expired lines.
- * You should give it the expire date, and key.
- * Key should be unique like steam or name, so we can in another stock detect this line and delete it.
- */
- stock CheckDate(const szEndDate[], const szKey[])
- {
- new szCurrentDate[64],
- szFormatedEndDate[64],
- szCurrentDay[32],
- szCurrentMonth[32],
- szCurrentYear[32],
- szEndDay[32],
- szEndMonth[32],
- szEndYear[32]
- copy(szFormatedEndDate, charsmax(szFormatedEndDate), szEndDate)
- get_time("%d-%m-%Y", szCurrentDate, charsmax(szCurrentDate))
- for (new ch = 0; ch <= charsmax(szFormatedEndDate); ch++)
- {
- if (szFormatedEndDate[ch] == '-')
- szFormatedEndDate[ch] = ' '
- }
- for (new ch = 0; ch <= charsmax(szCurrentDate); ch++)
- {
- if (szCurrentDate[ch] == '-')
- szCurrentDate[ch] = ' '
- }
- parse(szCurrentDate, szCurrentDay, charsmax(szCurrentDay), szCurrentMonth, charsmax(szCurrentMonth), szCurrentYear, charsmax(szCurrentYear))
- parse(szFormatedEndDate, szEndDay, charsmax(szEndDay), szEndMonth, charsmax(szEndMonth), szEndYear, charsmax(szEndYear))
- if (str_to_num(szFormatedEndDate) == 0)
- return
- new iCurrentDay,
- iCurrentMonth,
- iCurrentYear,
- iEndDay,
- iEndMonth,
- iEndYear
- iCurrentDay = str_to_num(szCurrentDay)
- iCurrentMonth = str_to_num(szCurrentMonth)
- iCurrentYear = str_to_num(szCurrentYear)
- iEndDay = str_to_num(szEndDay)
- iEndMonth = str_to_num(szEndMonth)
- iEndYear = str_to_num(szEndYear)
- // Just a check, maybe useless
- if ((!iCurrentDay && !iCurrentMonth && !iCurrentYear) || (!iEndDay && !iEndMonth && !iEndYear))
- return
- /*
- * Check expire date algorithm idea:
- *
- * If current year > Expire year -- This means it's already expired so delete this line.
- *
- * If Same year then check by month:
- * If current month > expire month -- Expired delete the line.
- *
- * If same month then check by day:
- * If current day > expire date -- Expired detete the line.
- */
- if (iEndYear < iCurrentYear)
- {
- Delete_Line(g_szLocalFile, szKey)
- }
- else if (iEndYear == iCurrentYear)
- {
- if (iEndMonth < iCurrentMonth)
- {
- Delete_Line(g_szLocalFile, szKey)
- }
- else if (iEndMonth == iCurrentMonth)
- {
- if (iEndDay < iCurrentDay)
- {
- Delete_Line(g_szLocalFile, szKey)
- }
- }
- }
- }
- /*
- * Stock used to delete line in file, based on key.
- * Key is steamid or name.
- * For some purposes we can't use new file system here.
- */
- stock Delete_Line(const szFile[], const szKey[])
- {
- // Check if file there or not
- if (file_exists(szFile))
- {
- // Get max lines in the file
- new iMaxLines = file_size(szFile, FSOPT_LINES_COUNT)
- // Some variables
- new Array:szFileLines, szLineToRead[400], iTextLen, szParse[4][65]
- // Create dynamic array to handle all lines in our file (every line will be in element)
- szFileLines = ArrayCreate(400)
- // Loop through whole file
- for (new iLine = 0; iLine < iMaxLines; iLine++)
- {
- // Read line by line
- read_file(szFile, iLine, szLineToRead, charsmax(szLineToRead), iTextLen)
- // Just split our line so we get the steamid or name and compare with key
- parse(szLineToRead, szParse[0], charsmax(szParse[]), szParse[1], charsmax(szParse[]), szParse[2], charsmax(szParse[]), szParse[3], charsmax(szParse[]))
- // Remove any ""
- remove_quotes(szParse[0])
- remove_quotes(szParse[1])
- remove_quotes(szParse[2])
- remove_quotes(szParse[3])
- // If steamid or name is same as one we need to delete, then don't copy to our array
- if (equal(szParse[0], szKey))
- continue
- // Push all lines to our array except one we need to delete
- ArrayPushString(szFileLines, szLineToRead)
- }
- // Delete the file
- delete_file(szFile)
- // Recreate the file and print all data to it
- for (new iLine = 0; iLine < ArraySize(szFileLines); iLine++)
- {
- // Get strings in our array
- ArrayGetString(szFileLines, iLine, szLineToRead, charsmax(szLineToRead))
- // Write them to our file
- write_file(szFile, szLineToRead)
- }
- // Destroy this array and free it's memory
- ArrayDestroy(szFileLines)
- }
- }
- stock Happy_Hours()
- {
- new szTime[3], szHappyHours[32], szHappyHours_Start[32], szHappyHours_End[32]
- get_time("%H", szTime, charsmax(szTime))
- get_pcvar_string(g_pCvarHappyHours, szHappyHours, charsmax(szHappyHours))
- for (new ch = 0; ch <= charsmax(szHappyHours); ch++)
- {
- if (szHappyHours[ch] == '-')
- szHappyHours[ch] = ' '
- }
- parse(szHappyHours, szHappyHours_Start, charsmax(szHappyHours_Start), szHappyHours_End, charsmax(szHappyHours_End))
- new iTime, iHappyHourStart, iHappyHourEnd
- iTime = str_to_num(szTime)
- iHappyHourStart = str_to_num(szHappyHours_Start)
- iHappyHourEnd = str_to_num(szHappyHours_End)
- if(iHappyHourEnd > iTime >= iHappyHourStart)
- {
- g_bIsHappyHour = true
- }
- else
- {
- g_bIsHappyHour = false
- }
- }