Post by Gaspatcho on Feb 24, 2019 20:25:49 GMT
What's No teams game-modes? No teams game-modes means that there won't be any teams. and only 1 player will be able to win the round (*Cough* not for HLDS server *cough*)
Is there any risks? Nope, if you get the stuff done the right way.
- The first thing you will need to do is to install Re-HLDS + Re-gamedll if you don't have those stuff installed, this won't work as intended.
1- Let's open zp50_gamemodes.sma and remove those codes.
Remove those codes from both
Now your mode allows friendly fire when Friendly fire is active. To enable the friendly fire for Re-HLDS use
and just use the function
2- Let's block the round end. Do this using
and just use the function
we will use
for this, it's in every single game-mode code file. we can use something like that
you can disable the freeforall cvar with this method too if you feel like you want to.
4- Setting all players to 1 team. for this you can just use the cs_team_api that comes with zp5.0
so on the gamemode start native, we will set the player's team to T and then make regamedll direction late joiners to join T
for the team thing use those commands
Don't forget to reset it, Setting player's team is done in many other gamemodes, just copy the code and use it or just edit the sma and keep it.
that's all.
Ex : This turns everyone to zombies and enables the friendly fire and blocks the round end til 1 player is left. then it end the round with
command
Is there any risks?
- The first thing you will need to do is to install Re-HLDS + Re-gamedll if you don't have those stuff installed, this won't work as intended.
1- Let's open zp50_gamemodes.sma and remove those codes.
// Prevent friendly fire
if (zp_core_is_zombie(attacker) == zp_core_is_zombie(victim))
return HAM_SUPERCEDE;
Remove those codes from both
// Ham Take Damage Forward (needed to block explosion damage too)
[Fw_TakeDamage]
// Ham Trace Attack Forward
[FW_TraceAttack]
Now your mode allows friendly fire when Friendly fire is active. To enable the friendly fire for Re-HLDS use
mp_freeforall 1
server_cmd("mp_freeforall 1")
to enable it and disable it.2- Let's block the round end. Do this using
mp_round_infinite
server_cmd("mp_round_infinite abcdefg")
to enable it, and to disable it use server_cmd("mp_round_infinite 0")
For those cvars we will use gamemodes start&end natives. please look at zp50_gamemodes.inc if you don't know already.
3- By setting the infinite round cvar to abcdefg the round becomes infinite, and we need some way to tell the plugin to tell the plugin stop reset it back when we have 1 player alive.we will use
GetAliveCount()
for this, it's in every single game-mode code file. we can use something like that
if(GetAliveCount() > 1)
{
//call the funcution again
}
else server_cmd("mp_round_infinite 0")
you can disable the freeforall cvar with this method too if you feel like you want to.
4- Setting all players to 1 team. for this you can just use the cs_team_api that comes with zp5.0
so on the gamemode start native, we will set the player's team to T and then make regamedll direction late joiners to join T
for the team thing use those commands
mp_auto_join_team 1
humans_join_team T
humans_join_team T
that's all.
Ex : This turns everyone to zombies and enables the friendly fire and blocks the round end til 1 player is left. then it end the round with
endround
/*================================================================================
------------------------------
-*- [ZP] Game Mode: Plague -*-
------------------------------
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_nemesis>
#include <zp50_deathmatch>
#include <hamsandwich>
// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
// Default sounds
new const sound_plague[][] = { "zombie_plague/nemesis1.wav" , "zombie_plague/survivor1.wav" }
#define SOUND_MAX_LENGTH 64
new Array:g_sound_plague
new num_kills[33]
// 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_nightmare_chance
new cvar_nightmare_min_players
new cvar_nightmare_ratio
new cvar_nightmare_show_hud
new cvar_nightmare_sounds
new cvar_nightmare_allow_res
new user_old_hp[33]
public plugin_precache()
{
// Register game mode at precache (plugin gets paused after this)
register_plugin("[ZP] Game Mode: Nightmare", ZP_VERSION_STRING, "Gasep")
zp_gamemodes_register("Cannibals Mode")
register_logevent("logevent_round_end", 2, "1=Round_End")
// Create the HUD Sync Objects
g_HudSync = CreateHudSyncObj()
g_maxplayers = get_maxplayers()
cvar_nightmare_chance = register_cvar("zp_nightmare_chance", "95")
cvar_nightmare_min_players = register_cvar("zp_nightmare_min_players", "0")
cvar_nightmare_ratio = register_cvar("zp_nightmare_ratio", "0.5")
cvar_nightmare_show_hud = register_cvar("zp_nightmare_show_hud", "1")
cvar_nightmare_sounds = register_cvar("zp_nightmare_sounds", "1")
cvar_nightmare_allow_res = register_cvar("zp_nightmare_allow_res", "0")
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1)
// Initialize arrays
g_sound_plague = ArrayCreate(SOUND_MAX_LENGTH, 1)
// Load from external file
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ROUND PLAGUE", g_sound_plague)
// If we couldn't load custom sounds from file, use and save default ones
new index
if (ArraySize(g_sound_plague) == 0)
{
for (index = 0; index < sizeof sound_plague; index++)
ArrayPushString(g_sound_plague, sound_plague[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "ROUND PLAGUE", g_sound_plague)
}
// Precache sounds
new sound[SOUND_MAX_LENGTH]
for (index = 0; index < ArraySize(g_sound_plague); index++)
{
ArrayGetString(g_sound_plague, 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_nightmare_allow_res))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_gamemodes_choose_pre(game_mode_id, skipchecks)
{
new alive_count = GetAliveCount()
if (!skipchecks)
{
// Random chance
if (random_num(1, get_pcvar_num(cvar_nightmare_chance)) != 1)
return PLUGIN_HANDLED;
// Min players
if (alive_count < get_pcvar_num(cvar_nightmare_min_players))
return PLUGIN_HANDLED;
}
// Game mode allowed
return PLUGIN_CONTINUE;
}
public zp_fw_gamemodes_start()
{
//server_cmd("ajc_team T")
set_task(0.5,"Start_Nightmare",1020)
// Play sound
if (get_pcvar_num(cvar_nightmare_sounds))
{
new sound[SOUND_MAX_LENGTH]
ArrayGetString(g_sound_plague, random_num(0, ArraySize(g_sound_plague) - 1), sound, charsmax(sound))
PlaySoundToClients(sound)
}
if (get_pcvar_num(cvar_nightmare_show_hud))
{
// Show Plague 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, "Cannibals Mode")
}
}
// 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;
}
public Start_Nightmare()
{
for (new id = 1; id <= g_maxplayers; id++)
{
if(is_user_alive(id))
{
//zp_class_nemesis_set(id)
zp_core_force_infect(id)
set_user_health(id, get_user_health(id) / 10)
client_print(id,print_chat,"Get ready to fight for survival")
server_cmd("mp_auto_join_team 1")
server_cmd("humans_join_team T")
set_task(0.1,"Announce",1010)
set_task(1.0, "Check_Count")
}
}
}
public Check_Count()
{
if(GetAliveCount() > 1) set_task(1.0, "Check_Count", 2019)
else
{
remove_task(2019)
announce_winner()
}
}
public Announce()
{
client_print(0,print_center,"Round starts in 5")
set_task(0.5,"A2")
server_cmd("mp_round_infinite abcdefg")
}
public A2()
{
client_print(0,print_center,"Round starts in 4")
set_task(0.5,"A3")
server_cmd("mp_round_infinite abcdefg")
}
public A3()
{
client_print(0,print_center,"Round starts in 3")
set_task(0.5,"A4")
server_cmd("mp_round_infinite abcdefg")
}
public A4()
{
client_print(0,print_center,"Round starts in 2")
set_task(0.5,"A5")
server_cmd("mp_round_infinite abcdefg")
}
public A5()
{
client_print(0,print_center,"Round starts in 1")
set_task(0.5,"A6")
server_cmd("mp_round_infinite abcdefg")
}
public A6()
{
client_print(0,print_center,"Round Started! Fight to survive!")
server_cmd("mp_freeforall 1")
}
public announce_winner()
{
//server_cmd("sv_restartround 1")
server_cmd("mp_freeforall 0")
server_cmd("humans_join_team any")
server_cmd("mp_round_infinite 0")
server_cmd("endround")
client_print(0,print_chat,"The last nemesis stands! Round has ended!")
}
public logevent_round_end()
{
server_cmd("mp_freeforall 0")
server_cmd("humans_join_team any")
server_cmd("mp_round_infinite 0")
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
if(zp_core_is_zombie(attacker) && zp_core_is_zombie(victim) && !zp_class_nemesis_get(attacker) && is_user_alive(attacker) && is_user_connected(attacker))
{
num_kills[attacker] += 1
}
if(num_kills[attacker] >=2)
{
user_old_hp[attacker] = get_user_health(attacker)
zp_class_nemesis_set(attacker)
set_user_health(attacker, user_old_hp[attacker])
}
}