Hello everyone. i was want to make a new gamemod...but i have problem is making server down when get this gamemod how can fix this
PHP Code:
/*================================================================================
----------------------------------
-*- [ZP] Game Mode: NightWar -*-
----------------------------------
This plugin is part of Zombie Plague Mod and is distributed under the
terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
================================================================================*/
#include <amxmodx>
#include <fun>
#include <amx_settings_api>
#include <cs_teams_api>
#include <zp50_gamemodes>
#include <zp50_class_sniper>
#include <zp50_class_assassin>
#include <zp50_class_nemesis>
#include <zp50_class_survivor>
#include <zp50_deathmatch>
// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
// Default sounds
new const sound_nightwar[][] = { "zombie_plague/zoz_nightwar.mp3" }
#define SOUND_MAX_LENGTH 64
new Array:g_sound_nightwar
// HUD messages
#define HUD_EVENT_X -1.0
#define HUD_EVENT_Y 0.17
#define HUD_EVENT_R 0
#define HUD_EVENT_G 50
#define HUD_EVENT_B 200
new g_MaxPlayers
new g_HudSync
new cvar_nightwar_chance, cvar_nightwar_min_players
new cvar_nightwar_ratio
new cvar_nightwar_nem_hp_multi, cvar_nightwar_surv_hp_multi, cvar_nightwar_ass_hp_multi, cvar_nightwar_sniper_hp_multi
new cvar_nightwar_show_hud, cvar_nightwar_sounds
new cvar_nightwar_allow_respawn
public plugin_precache()
{
// Register game mode at precache (plugin gets paused after this)
register_plugin("[ZoZ] Game Mode: NightWar", ZP_VERSION_STRING, "madness")
zp_gamemodes_register("NightWar Mode")
// Create the HUD Sync Objects
g_HudSync = CreateHudSyncObj()
g_MaxPlayers = get_maxplayers()
cvar_nightwar_chance = register_cvar("zp_nightwar_chance", "20")
cvar_nightwar_min_players = register_cvar("zp_nightwar_min_players", "0")
cvar_nightwar_ratio = register_cvar("zp_nightwar_ratio", "0.5")
cvar_nightwar_ass_hp_multi = register_cvar("cvar_nightwar_ass_hp_multi", "0.25")
cvar_nightwar_sniper_hp_multi = register_cvar("cvar_nightwar_sniper_hp_multi", "0.25")
cvar_nightwar_nem_hp_multi = register_cvar("zp_nightwar_nem_hp_multi", "0.25")
cvar_nightwar_surv_hp_multi = register_cvar("zp_nightwar_surv_hp_multi", "0.25")
cvar_nightwar_show_hud = register_cvar("zp_nightwar_show_hud", "1")
cvar_nightwar_sounds = register_cvar("zp_nightwar_sounds", "1")
cvar_nightwar_allow_respawn = register_cvar("zp_nightwar_allow_respawn", "0")
// Initialize arrays
g_sound_nightwar = ArrayCreate(SOUND_MAX_LENGTH, 1)
// Load from external file
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ROUND NIGHTWAR", g_sound_nightwar)
// If we couldn't load custom sounds from file, use and save default ones
new index
if (ArraySize(g_sound_nightwar) == 0)
{
for (index = 0; index < sizeof sound_nightwar; index++)
ArrayPushString(g_sound_nightwar, sound_nightwar[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ROUND NIGHTWAR", g_sound_nightwar)
}
// Precache sounds
new sound[SOUND_MAX_LENGTH]
for (index = 0; index < ArraySize(g_sound_nightwar); index++)
{
ArrayGetString(g_sound_nightwar, index, sound, charsmax(sound))
if (equal(sound[strlen(sound)-4], ".mp3"))
{
format(sound, charsmax(sound), "sound/%s", sound)
precache_generic(sound)
}
else
precache_sound(sound)
}
}
// Deathmatch module's player respawn forward
public zp_fw_deathmatch_respawn_pre(id)
{
// Respawning allowed?
if (!get_pcvar_num(cvar_nightwar_allow_respawn))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_gamemodes_choose_pre(game_mode_id, skipchecks)
{
if (!skipchecks)
{
// Random chance
if (random_num(1, get_pcvar_num(cvar_nightwar_chance)) != 1)
return PLUGIN_HANDLED;
// Min players
if (GetAliveCount() < get_pcvar_num(cvar_nightwar_min_players))
return PLUGIN_HANDLED;
}
// Game mode allowed
return PLUGIN_CONTINUE;
}
public zp_fw_gamemodes_start()
{
// Calculate player counts
new id, alive_count = GetAliveCount()
new sniper_count = floatround(alive_count * get_pcvar_float(cvar_nightwar_ratio), floatround_ceil)
new assassin_count = alive_count - sniper_count
new survivor_count = alive_count - sniper_count
new nemesis_count = alive_count - sniper_count
// Turn specified amount of players into Snipers
new iSniper, iMaxSniper = sniper_count
while (iSniper < iMaxSniper)
{
// Choose random guy
id = GetRandomAlive(random_num(1, alive_count))
// Already a Sniper?
if (zp_class_sniper_get(id))
continue;
// If not, turn him into one
zp_class_sniper_set(id)
iSniper++
// Apply Sniper health multiplier
set_user_health(id, floatround(get_user_health(id) * get_pcvar_float(cvar_nightwar_sniper_hp_multi)))
}
// Turn specified amount of players into Assassin
new iAssassin, iMaxAssassin = assassin_count
while (iAssassin< iMaxAssassin)
{
// Choose random guy
id = GetRandomAlive(random_num(1, alive_count))
// Already a Assassin?
if (zp_class_assassin_get(id))
continue;
// If not, turn him into one
zp_class_assassin_set(id)
iAssassin++
// Apply Sniper health multiplier
set_user_health(id, floatround(get_user_health(id) * get_pcvar_float(cvar_nightwar_ass_hp_multi)))
}
// Turn specified amount of players into Survivors
new iSurvivors, iMaxSurvivors = survivor_count
while (iSurvivors < iMaxSurvivors)
{
// Choose random guy
id = GetRandomAlive(random_num(1, alive_count))
// Already a survivor?
if (zp_class_survivor_get(id))
continue;
// If not, turn him into one
zp_class_survivor_set(id)
iSurvivors++
// Apply survivor health multiplier
set_user_health(id, floatround(get_user_health(id) * get_pcvar_float(cvar_nightwar_surv_hp_multi)))
}
// Turn specified amount of players into Nemesis
new iNemesis, iMaxNemesis = nemesis_count
while (iNemesis < iMaxNemesis)
{
// Choose random guy
id = GetRandomAlive(random_num(1, alive_count))
// Already a survivor or nemesis?
if (zp_class_survivor_get(id) || zp_class_nemesis_get(id))
continue;
// If not, turn him into one
zp_class_nemesis_set(id)
iNemesis++
// Apply nemesis health multiplier
set_user_health(id, floatround(get_user_health(id) * get_pcvar_float(cvar_nightwar_nem_hp_multi)))
}
// Play NightWar sound
if (get_pcvar_num(cvar_nightwar_sounds))
{
new sound[SOUND_MAX_LENGTH]
ArrayGetString(g_sound_nightwar, random_num(0, ArraySize(g_sound_nightwar) - 1), sound, charsmax(sound))
PlaySoundToClients(sound)
}
if (get_pcvar_num(cvar_nightwar_show_hud))
{
// Show NIGHTWAR HUD notice
set_hudmessage(HUD_EVENT_R, HUD_EVENT_G, HUD_EVENT_B, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_HudSync, "NightWar mod", LANG_PLAYER )
}
}
// Plays a sound on clients
PlaySoundToClients(const sound[])
{
if (equal(sound[strlen(sound)-4], ".mp3"))
client_cmd(0, "mp3 play ^"sound/%s^"", sound)
else
client_cmd(0, "spk ^"%s^"", sound)
}
// Get Alive Count -returns alive players number-
GetAliveCount()
{
new iAlive, id
for (id = 1; id <= g_MaxPlayers; id++)
{
if (is_user_alive(id))
iAlive++
}
return iAlive;
}
// Get Random Alive -returns index of alive player number target_index -
GetRandomAlive(target_index)
{
new iAlive, id
for (id = 1; id <= g_MaxPlayers; id++)
{
if (is_user_alive(id))
iAlive++
if (iAlive == target_index)
return id;
}
return -1;
}