#include <zombie_escape>
#include <engine>
#define ITEM_NAME "Paintball Gun"
#define ITEM_COST 50
new PAINTBALL_V_MODEL[64] = "models/zombie_escape/v_paintballgun.mdl"
new PAINTBALL_P_MODEL[64] = "models/zombie_escape/p_paintballgun.mdl"
new PAINTBALL_W_MODEL[64] = "models/zombie_escape/w_paintballgun.mdl"
new g_paintSprite[2][] = {"sprites/bhit.spr", "sprites/richo1.spr"}
new lastammo[33], g_paintball_gun[33], g_ballsnum = 0
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_AK47)|(1<<CSW_M4A1)|(1<<CSW_FAMAS)|(1<<CSW_GALIL)|(1<<CSW_SCOUT)|(1<<CSW_AWP)|(1<<CSW_M249)|(1<<CSW_MP5NAVY)|(1<<CSW_P90)|(1<<CSW_MAC10)|(1<<CSW_TMP)|(1<<CSW_XM1014)|(1<<CSW_M3)|(1<<CSW_G3SG1)|(1<<CSW_SG550)|(1<<CSW_SG552)|(1<<CSW_AUG)|(1<<CSW_UMP45);
// Cvars //
new paintball_lifetime, paintball_maxballs, paintball_dmg_multi, paintball_unlimited_clip, g_iItemID
public plugin_natives()
{
register_native("is_has_paint_ball_gun", "native_is_has_paint_ball_gun", 1)
}
public plugin_init()
{
register_plugin("[ZE] Extra Item: Paint Ball Gun", "1.1", "KRoTaL | [P]erfec[T] [S]cr[@]s[H] | Mark")
register_cvar("ze_paintballgun", "1.1", FCVAR_SERVER|FCVAR_UNLOGGED);
RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_AddToPlayer")
register_forward(FM_SetModel, "fw_SetModel")
register_event("CurWeapon", "make_paint", "be", "3>0")
register_event("WeapPickup","checkModel","b","1=19")
register_event("CurWeapon","checkWeapon","be","1=1")
register_event("HLTV", "new_round", "a", "1=0", "2=0")
paintball_maxballs = register_cvar("ze_paintball_maxballs", "200")
paintball_lifetime = register_cvar("ze_paintball_lifetime", "10")
paintball_dmg_multi = register_cvar("ze_paintball_dmg_multi", "4")
paintball_unlimited_clip = register_cvar("ze_paintball_unlimited_clip", "0")
g_iItemID = ze_register_item(ITEM_NAME, ITEM_COST, 0)
}
public plugin_precache()
{
precache_model("sprites/bhit.spr")
precache_model("sprites/richo1.spr")
precache_model(PAINTBALL_V_MODEL)
precache_model(PAINTBALL_P_MODEL)
precache_model(PAINTBALL_W_MODEL)
}
public native_is_has_paint_ball_gun(id)
{
return g_paintball_gun[id];
}
public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
if (is_user_alive(attacker) && get_user_weapon(attacker) == CSW_MP5NAVY && g_paintball_gun[attacker] && !ze_is_user_zombie(attacker))
{
SetHamParamFloat(4, damage * get_pcvar_float(paintball_dmg_multi ))
set_rendering(victim, kRenderFxGlowShell, random_num(0,255), random_num(0,255), random_num(0,255), kRenderNormal, 16);
set_task(5.0, "remove_glow", victim)
}
}
public ze_user_humanized(id)
{
g_paintball_gun[id] = false
remove_glow(id)
}
public ze_user_infected(iVictim)
{
g_paintball_gun[iVictim] = false
remove_glow(iVictim)
}
public ze_select_item_pre(id, itemid)
{
if (itemid != g_iItemID)
return ZE_ITEM_AVAILABLE
if (ze_is_user_zombie(id))
return ZE_ITEM_DONT_SHOW
return ZE_ITEM_AVAILABLE
}
public ze_select_item_post(id, itemid)
{
if (itemid != g_iItemID)
return
ze_colored_print(id, "Congrats! You have bought a Paintball Gun! :D")
Get_MyWeapon(id)
}
public Get_MyWeapon(id)
{
drop_weapons(id, 1);
g_paintball_gun[id] = true
give_item(id, "weapon_mp5navy")
}
public remove_glow(id)
{
set_rendering(id);
}
public checkWeapon(id)
{
new plrClip, plrAmmo, plrWeap[32], plrWeapId
plrWeapId = get_user_weapon(id, plrClip , plrAmmo)
if (plrWeapId == CSW_MP5NAVY && g_paintball_gun[id])
checkModel(id)
else return PLUGIN_CONTINUE;
if (plrClip == 0 && get_pcvar_num(paintball_unlimited_clip))
{
// If the user is out of ammo..
get_weaponname(plrWeapId, plrWeap, 31)
// Get the name of their weapon
give_item(id, plrWeap)
engclient_cmd(id, plrWeap)
engclient_cmd(id, plrWeap)
engclient_cmd(id, plrWeap)
}
return PLUGIN_HANDLED
}
public checkModel(id)
{
if (ze_is_user_zombie(id)) return PLUGIN_HANDLED;
new szWeapID = read_data(2)
if ( szWeapID == CSW_MP5NAVY && g_paintball_gun[id])
{
entity_set_string(id, EV_SZ_viewmodel, PAINTBALL_V_MODEL)
entity_set_string(id, EV_SZ_weaponmodel, PAINTBALL_P_MODEL)
}
return PLUGIN_HANDLED
}
public make_paint(id)
{
new ammo = read_data(3)
if(get_user_weapon(id) == CSW_MP5NAVY && lastammo[id] > ammo && g_paintball_gun[id])
{
new iOrigin[3]
get_user_origin(id, iOrigin, 4)
new Float:fOrigin[3]
IVecFVec(iOrigin, fOrigin)
if(g_ballsnum < get_pcvar_num(paintball_maxballs) && worldInVicinity(fOrigin))
{
new ent = create_entity("info_target")
if(ent > 0)
{
entity_set_string(ent, EV_SZ_classname, "paint_ent")
entity_set_int(ent, EV_INT_movetype, 0)
entity_set_int(ent, EV_INT_solid, 0)
entity_set_model(ent, g_paintSprite[random_num(0,1)])
new r, g, b
r = random_num(64,255)
g = random_num(64,255)
b = random_num(64,255)
set_rendering(ent, kRenderFxNoDissipation, r, g, b, kRenderGlow, 255)
entity_set_origin(ent, fOrigin)
entity_set_int(ent, EV_INT_flags, FL_ALWAYSTHINK)
entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(paintball_lifetime))
++g_ballsnum
}
}
}
lastammo[id] = ammo
}
public pfn_think(entity)
{
if(!is_valid_ent(entity))
return
new class[32]; entity_get_string(entity, EV_SZ_classname, class, 31)
if(entity > 0 && equal(class, "paint_ent"))
{
remove_entity(entity)
--g_ballsnum
}
}
public new_round()
{
for(new id = 1; id <= get_maxplayers(); id++) g_paintball_gun[id] = false
remove_entity_name("paint_ent")
g_ballsnum = 0
}
stock worldInVicinity(Float:origin[3])
{
new ent = find_ent_in_sphere(-1, origin, 4.0)
while(ent > 0)
{
if(entity_get_float(ent, EV_FL_health) > 0 || entity_get_float(ent, EV_FL_takedamage) > 0.0) return 0;
ent = find_ent_in_sphere(ent, origin, 4.0)
}
new Float:traceEnds[8][3], Float:traceHit[3], hitEnt
traceEnds[0][0] = origin[0] - 2.0; traceEnds[0][1] = origin[1] - 2.0; traceEnds[0][2] = origin[2] - 2.0
traceEnds[1][0] = origin[0] - 2.0; traceEnds[1][1] = origin[1] - 2.0; traceEnds[1][2] = origin[2] + 2.0
traceEnds[2][0] = origin[0] + 2.0; traceEnds[2][1] = origin[1] - 2.0; traceEnds[2][2] = origin[2] + 2.0
traceEnds[3][0] = origin[0] + 2.0; traceEnds[3][1] = origin[1] - 2.0; traceEnds[3][2] = origin[2] - 2.0
traceEnds[4][0] = origin[0] - 2.0; traceEnds[4][1] = origin[1] + 2.0; traceEnds[4][2] = origin[2] - 2.0
traceEnds[5][0] = origin[0] - 2.0; traceEnds[5][1] = origin[1] + 2.0; traceEnds[5][2] = origin[2] + 2.0
traceEnds[6][0] = origin[0] + 2.0; traceEnds[6][1] = origin[1] + 2.0; traceEnds[6][2] = origin[2] + 2.0
traceEnds[7][0] = origin[0] + 2.0; traceEnds[7][1] = origin[1] + 2.0; traceEnds[7][2] = origin[2] - 2.0
for (new i = 0; i < 8; i++)
{
if (PointContents(traceEnds[i]) != CONTENTS_EMPTY) return 1;
hitEnt = trace_line(0, origin, traceEnds[i], traceHit)
if (hitEnt != -1) return 1;
for (new j = 0; j < 3; j++) if (traceEnds[i][j] != traceHit[j]) return 1;
}
return 0
}
public fw_SetModel(entity, model[])
{
if(!is_valid_ent(entity))
return FMRES_IGNORED;
if(!equal(model, "models/w_mp5.mdl"))
return FMRES_IGNORED;
static szClassName[33]
entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED
static iOwner, iStoredMp5ID
iOwner = entity_get_edict(entity, EV_ENT_owner)
iStoredMp5ID = find_ent_by_owner(-1, "weapon_mp5navy", entity)
if(g_paintball_gun[iOwner] && is_valid_ent(iStoredMp5ID))
{
g_paintball_gun[iOwner] = false
entity_set_int(iStoredMp5ID, EV_INT_impulse, 1664656581)
entity_set_model(entity, PAINTBALL_W_MODEL)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public fw_AddToPlayer(wpn, id)
{
if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_impulse) == 1664656581)
{
g_paintball_gun[id] = true
entity_set_int(wpn, EV_INT_impulse, 0)
return HAM_HANDLED
}
return HAM_IGNORED
}
stock give_item(index, const item[]) {
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0;
new ent = create_entity(item);
if (!pev_valid(ent))
return 0;
new Float:origin[3];
pev(index, pev_origin, origin);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Spawn, ent);
new save = pev(ent, pev_solid);
dllfunc(DLLFunc_Touch, ent, index);
if (pev(ent, pev_solid) != save)
return ent;
engfunc(EngFunc_RemoveEntity, ent);
return -1;
}
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
{
static wname[32]
get_weaponname(weaponid, wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}
stock client_printcolor(const id,const input[], any:...)
{
new msg[191], players[32], count = 1
vformat(msg,190,input,3);
replace_all(msg,190,"!g","^4"); // green
replace_all(msg,190,"!y","^1"); // normal
replace_all(msg,190,"!t","^3"); // team
if (id) players[0] = id; else get_players(players,count,"ch");
for (new i=0;i<count;i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}