Código:
/*================================================================================
[ZP] Zombie Class: Swarm Zombie
Copyright (C) 2010 by meTaLiCroSS, Viña del Mar, Chile
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
In addition, as a special exception, the author gives permission to
link the code of this program with the Half-Life Game Engine ("HL
Engine") and Modified Game Libraries ("MODs") developed by Valve,
L.L.C ("Valve"). You must obey the GNU General Public License in all
respects for all of the code used other than the HL Engine and MODs
from Valve. If you modify this file, you may extend this exception
to your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from your
version.
=================================================================================*/
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <zombieplague>
/*================================================================================
[Customizations]
=================================================================================*/
// Zombie Attributes
new const zclass_name[] = "Swarm Zombie" // name
new const zclass_info[] = "You can only Kill/Hurt" // description
new const zclass_model[] = "zombie_source" // model
new const zclass_clawmodel[] = "v_knife_zombie.mdl" // claw model
const zclass_health = 1800 // health
const zclass_speed = 190 // speed
const Float:zclass_gravity = 1.0 // gravity
const Float:zclass_knockback = 1.0 // knockback
/*================================================================================
Customization ends here! Yes, that's it. Editing anything beyond
here is not officially supported. Proceed at your own risk...
=================================================================================*/
// Variables
new g_iSwarmZID, g_iMaxPlayers, g_msgSayText
// Cvar pointers
new cvar_dmgmult, cvar_surv_dmgmult, cvar_blockinfbomb_infect
// Cached cvars
new bool:g_bCvar_Infbomb_Infect, Float:g_flCvar_DmgMult, Float:g_flCvar_SurvDmgMult
// Bools
new bool:g_bIsConnected[33], bool:g_bRoundEnding
// Offsets
const m_pPlayer = 41
// A const
const NADE_TYPE_INFECTION = 1111 // from main ZP plugin
// Plug info.
#define PLUG_VERSION "0.7"
#define PLUG_AUTH "meTaLiCroSS"
// Macros
#define zp_get_grenade_type(%1) (entity_get_int(%1, EV_INT_flTimeStepSound))
#define is_user_valid_connected(%1) (1 <= %1 <= g_iMaxPlayers && g_bIsConnected[%1])
/*================================================================================
[Init, CFG and Precache]
=================================================================================*/
public plugin_init()
{
// Plugin Register
register_plugin("[ZP] Zombie Class: Swarm Zombie", PLUG_VERSION, PLUG_AUTH)
// Main events
register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")
// Hamsandwich Forwards
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fw_KnifeAttack")
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_KnifeAttack")
// Cvars
cvar_dmgmult = register_cvar("zp_swarm_damage_mult", "2.0")
cvar_surv_dmgmult = register_cvar("zp_swarm_surv_damage_mult", "3.0")
cvar_blockinfbomb_infect = register_cvar("zp_swarm_infbomb_infect", "1")
static szCvar[30]
formatex(szCvar, charsmax(szCvar), "v%s by %s", PLUG_VERSION, PLUG_AUTH)
register_cvar("zp_zclass_swarm", szCvar, FCVAR_SERVER|FCVAR_SPONLY)
// Vars
g_iMaxPlayers = get_maxplayers()
g_msgSayText = get_user_msgid("SayText")
}
public plugin_cfg()
{
// Do some cvars cache
cache_cvars()
}
public plugin_precache()
{
// Hamsandwich Forwards
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
// Register the new class and store ID for reference
g_iSwarmZID = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}
/*================================================================================
[Main Events]
=================================================================================*/
public event_RoundStart()
{
// Do some cvars cache
cache_cvars()
// Update bool
g_bRoundEnding = false
}
/*================================================================================
[Main Forwards]
=================================================================================*/
public client_putinserver(id)
{
// Updating bool
g_bIsConnected[id] = true
}
public client_disconnect(id)
{
// Updating bool
g_bIsConnected[id] = false
}
public fw_KnifeAttack(knife)
{
// We need to block the Knife attack, because
// when has throwed an Infection bomb it can Kill/Infect
// with Knife, and will be a bug
// ----
// Get knife owner (player)
static iPlayer
iPlayer = get_pdata_cbase(knife, m_pPlayer, 4)
// Non-player entity
if(!is_user_valid_connected(iPlayer))
return HAM_IGNORED
// Swarm zombie class, not a nemesis and has throwed a infection nade
if(zp_get_user_zombie_class(iPlayer) == g_iSwarmZID && !zp_get_user_nemesis(iPlayer) && zp_get_user_infection_nade(iPlayer) > 0)
return HAM_SUPERCEDE
return HAM_IGNORED
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype)
{
// In the Main ZP plugin, the TakeDamage forward is Superceded, so
// we need to register this in Precache to get it working again
// ----
// Non-player attacker, self attack, attacked by world, or isn't make damage by himself
if(!is_user_valid_connected(attacker) || victim == attacker || !attacker || attacker != inflictor)
return HAM_IGNORED
// Swarm zombie class
if(zp_get_user_zombie(attacker) && zp_get_user_zombie_class(attacker) == g_iSwarmZID && !zp_get_user_nemesis(attacker) && !g_bRoundEnding)
{
// Get damage result (with survivor and human damage multiplier)
static Float:flDamageResult
flDamageResult = damage * (zp_get_user_survivor(victim) ? g_flCvar_SurvDmgMult : g_flCvar_DmgMult)
// Do damage again
ExecuteHam(Ham_TakeDamage, victim, inflictor, attacker, flDamageResult, damagetype)
// Stop here
return HAM_SUPERCEDE;
}
return HAM_IGNORED
}
/*================================================================================
[Zombie Plague Forwards]
=================================================================================*/
public zp_user_infect_attempt(victim, infector, nemesis)
{
// Non-player infection or turned into a nemesis
if(!infector || nemesis)
return PLUGIN_CONTINUE
// Check Swarm Zombie class and block infection.
// I'm detecting if is Zombie and isn't Nemesis because
// can be an infection by zp_infect_user native
if(zp_get_user_zombie_class(infector) == g_iSwarmZID && zp_get_user_zombie(infector) && !zp_get_user_nemesis(infector))
{
// With infection grenade then must kill or infect, defined by cvar.
if(zp_get_user_infection_nade(infector) > 0)
{
switch(g_bCvar_Infbomb_Infect)
{
case true: return PLUGIN_CONTINUE // Infect
case false: ExecuteHamB(Ham_Killed, victim, infector, 0) // Kill
}
}
return ZP_PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public zp_user_infected_post(id, infector, nemesis)
{
// It's the selected zombie class
if(zp_get_user_zombie_class(id) == g_iSwarmZID && !nemesis)
{
// My rofl message :D
client_printcolor(id, "/g[ZP]/y /g%s /yClass by /ctr%s/y", zclass_name, PLUG_AUTH)
}
}
public zp_round_ended(winteam)
{
// Update bool
g_bRoundEnding = true
}
/*================================================================================
[Internal Functions]
=================================================================================*/
cache_cvars()
{
// Caching cvars
g_flCvar_DmgMult = get_pcvar_float(cvar_dmgmult)
g_flCvar_SurvDmgMult = get_pcvar_float(cvar_surv_dmgmult)
g_bCvar_Infbomb_Infect = bool:get_pcvar_num(cvar_blockinfbomb_infect)
}
/*================================================================================
[Stocks]
=================================================================================*/
stock zp_get_user_infection_nade(id)
{
static iNade
iNade = get_grenade(id)
if(iNade > 0 && is_valid_ent(iNade)
&& zp_get_grenade_type(iNade) == NADE_TYPE_INFECTION)
return iNade
return 0;
}
stock client_printcolor(id, const input[], any:...)
{
static iPlayersNum[32], iCount; iCount = 1
static szMsg[191]
vformat(szMsg, charsmax(szMsg), input, 3)
replace_all(szMsg, 190, "/g", "^4") // green txt
replace_all(szMsg, 190, "/y", "^1") // orange txt
replace_all(szMsg, 190, "/ctr", "^3") // team txt
replace_all(szMsg, 190, "/w", "^0") // team txt
if(id) iPlayersNum[0] = id
else get_players(iPlayersNum, iCount, "ch")
for (new i = 0; i < iCount; i++)
{
if (g_bIsConnected[iPlayersNum[i]])
{
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, iPlayersNum[i])
write_byte(iPlayersNum[i])
write_string(szMsg)
message_end()
}
}
}
o swarm n esta pegando no zombie plague 4.3 ja desativei todos os plugins e tentei so q quando eu tento entrar no server o cs fecha na hora..
e quando eu compro survivor fala que eu compro nemesis e eu quero que tipo so de para comprar survivor e nemesis antes da infecção pque eu viro zombie ae da pra compra ainda... a sma vo por abaixo.
Código:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <zombieplague>
#include <zmvip>
#define PLUGIN "[ZP] S/N Buy"
#define VERSION "1.1"
#define AUTHOR "aaarnas"
new g_msgSayText
new nemesis, survivor
new g_bought[33], bought
new cvar_n_price, cvar_s_price, cvar_limit_all, cvar_everytime, cvar_show_bought, cvar_allow_times
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
cvar_everytime = register_cvar("zp_allow_buy", "2")
cvar_allow_times = register_cvar("zp_allow_times", "4")
cvar_limit_all = register_cvar("zp_limit_for_all", "1")
cvar_n_price = register_cvar("zp_nemesis_price", "150")
cvar_s_price = register_cvar("zp_survivor_price", "150")
cvar_show_bought = register_cvar("zp_show_who_bought", "1")
g_msgSayText = get_user_msgid("SayText")
// Extra items
nemesis = zv_register_extra_item("comprar Nemesis", "For one round", get_pcvar_num(cvar_n_price), 0)
survivor = zv_register_extra_item("comprar Survivor","For one round", get_pcvar_num(cvar_s_price), 0)
}
public zp_round_ended()
bought = false
public zv_extra_item_selected(id, itemid) {
new value = get_pcvar_num(cvar_everytime)
if(itemid == nemesis) {
if(get_pcvar_num(cvar_limit_all) && bought) {
client_printcolor(id, "/g[ZP] This is no more avaible in this round. Try next round.")
return ZV_PLUGIN_HANDLED
}
if(g_bought[id] >= get_pcvar_num(cvar_allow_times)) {
client_printcolor(id, "/g[ZP] You can't buy it more than %d times.", get_pcvar_num(cvar_allow_times))
return ZV_PLUGIN_HANDLED
}
if(value == 2) {
zp_make_user_nemesis(id)
new name[64]
get_user_name(id, name, 63)
client_printcolor(0, "/g[ZP] %s /ybought nemesis", name)
g_bought[id]++
}
else if(zp_has_round_started() == value) {
zp_make_user_nemesis(id)
if(get_pcvar_num(cvar_show_bought)) {
new name[64]
get_user_name(id, name, 63)
client_printcolor(0, "/g[ZP] %s /ybought nemesis", name)
g_bought[id]++
bought = true
}
}
else {
client_printcolor(id, "/g[ZP] /yYou can buy Nemesis only when %s.", value ? "round started":"round not started")
return ZV_PLUGIN_HANDLED
}
}
else if(itemid == survivor) {
if(get_pcvar_num(cvar_limit_all) && bought) {
client_printcolor(id, "/g[ZP] This is no more avaible in this round. Try next round.")
return ZV_PLUGIN_HANDLED
}
if(g_bought[id] >= get_pcvar_num(cvar_allow_times)) {
client_printcolor(id, "/g[ZP] You can't buy it more than %d times.", get_pcvar_num(cvar_allow_times))
return ZV_PLUGIN_HANDLED
}
if(value == 2) {
zp_make_user_survivor(id)
new name[64]
get_user_name(id, name, 63)
client_printcolor(0, "/g[ZP] %s /ybought nemesis", name)
g_bought[id]++
}
else if(zp_has_round_started() == value) {
zp_make_user_survivor(id)
if(get_pcvar_num(cvar_show_bought)) {
new name[64]
get_user_name(id, name, 63)
client_printcolor(0, "/g[ZP] %s /ybought survivor", name)
g_bought[id]++
bought = true
zp_has_round_started()
return 1
}
}
else {
client_printcolor(id, "/g[ZP] /yYou can buy Survivor only when %s.", value ? "round started":"round not started")
return ZV_PLUGIN_HANDLED
}
}
return 1
}
stock client_printcolor(const id, const input[], any:...)
{
new iCount = 1, iPlayers[32]
static szMsg[191]
vformat(szMsg, charsmax(szMsg), input, 3)
replace_all(szMsg, 190, "/g", "^4") // green txt
replace_all(szMsg, 190, "/y", "^1") // orange txt
replace_all(szMsg, 190, "/ctr", "^3") // team txt
replace_all(szMsg, 190, "/w", "^0") // team txt
if(id) iPlayers[0] = id
else get_players(iPlayers, iCount, "ch")
for (new i = 0; i < iCount; i++)
{
if (is_user_connected(iPlayers[i]))
{
message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, iPlayers[i])
write_byte(iPlayers[i])
write_string(szMsg)
message_end()
}
}
}