teobrvt1995
T.E.T.Я.I.S
- 19/9/10
- 691
- 2
mới làm thử cái nỳ, chưa test, mọi người xem dùm mình vời :)
PHP:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <xs>
#define fm_find_ent_in_sphere(%1,%2,%3) engfunc(EngFunc_FindEntityInSphere, %1, %2, %3)
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
#define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
#define fm_entity_set_model(%1,%2) engfunc(EngFunc_SetModel, %1, %2)
#define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor, %1)
new g_iCanUseBomb[33]
new Bomb_model[64] = {" models/bomb.mdl"}
new trail_spr, exp_spr
new const Bomb_Sounds[][] = {
"weapons/bomb_warming,wav",
"weapons/bomb_start.wav",
"weapons/bomb_explode.wav"
}
public plugin_init()
{
register_plugin("Direct Bomb"," 1.0", "Teobrvt1995")
register_event("HLTV","Event_HLTV","a","1=0","2=0")
register_event("DeathMsg","Event_DeathMsg","b")
register_forward(FM_CmdStart,"fwFM_CmdStart")
register_forward(FM_Touch,"fwFM_Touch")
}
public plugin_precache()
{
precache_model(Bomb_model)
for( new i = 0; i < sizeof Bomb_Sounds;i++)
precache_sound(Bomb_Sounds[i])
trail_spr = precache_model("sprites/eexplo.spr")
exp_spr = precache_model("sprites/smoke.spr")
}
public client_connect(id) g_iCanUseBomb[id] = 0
public client_disconnect(id) g_iCanUseBomb[id] = 0
public zp_user_infected_post(id) g_iCanUseBomb[id] = 0
public zp_user_humanized_post(id,survivor)
{
if(!zp_get_user_survivor(id) && !survivor)
{
g_iCanUseBomb[id] = 0
g_iCanUseBomb[survivor] = 0
}
else
{
g_iCanUseBomb[id] = 1
}
}
public Event_HLTV()
{
for( new id =0; id< get_maxplayers(); id++)
g_iCanUseBomb[id] = 1
}
public Event_DeathMsg()
{
g_iCanUseBomb[read_data(2)] = 0
}
public fwFM_CmdStart(id,handle,seed)
{
if(!is_user_alive(id))
return FMRES_IGNORED
if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
return FMRES_IGNORED
if(!g_iCanUseBomb[id])
return FMRES_IGNORED
new iButton = get_uc(handle,UC_Buttons)
if(iButton&IN_USE)
{
set_uc(handle,UC_Buttons,iButton&~IN_USE)
UseBomb(id)
emit_sound(id,CHAN_AUTO,Bomb_Sounds[0], 1.0, ATTN_NORM,0,PITCH_NORM)
g_iCanUseBomb[id] = 0
}
return FMRES_HANDLED
}
UseBomb(id)
{
if(!is_user_alive(id) || zp_get_user_zombie(id))
return
set_task(120.0,"task_ReuseBomb",id+1000)
new Float:fOrigin[3]
fm_get_aim_origin(id,fOrigin)
new iVictim = -1
while ( ( iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, fOrigin, 100.0) ) != 0 )
{
if(!is_user_alive(iVictim) || !zp_get_user_zombie(iVictim))
continue
if(is_wall_between_points(fOrigin,iVictim))
continue
new param[2]
param[0] = id
param[1] = iVictim
set_task(120.0,"task_CreateBomb",_,param,1)
}
}
public task_ReuseBomb(id)
{
id-= 1000
if(!is_user_alive(id) || zp_get_user_zombie(id))
return
g_iCanUseBomb[id] = 1
}
public task_CreateBomb(param[])
{
new id = param[0]
new iVictim = param[1]
new Float:fVicOrigin[3],Float: fAngle[3], iEnt
iEnt = fm_create_entity("info_target")
if(!iEnt) return
pev(iVictim, pev_origin,fVicOrigin)
fVicOrigin[2]+= random_float(500.0,100.0)*random_float(1.0,1.5)
fAngle[0] = 90.0
fAngle[1] = 0.0
fAngle[2] = 0.0
set_pev(iEnt, pev_classname,"direct_bomb")
set_pev(iEnt, pev_origin,fVicOrigin)
set_pev(iEnt, pev_angles,fAngle)
fm_entity_set_model(iEnt,Bomb_model)
set_pev(iEnt, pev_mins,{ -1.0,-1.0,-1.0})
set_pev(iEnt, pev_maxs, {1.0, 1.0, 1.0})
set_pev(iEnt, pev_movetype,MOVETYPE_TOSS)
set_pev(iEnt, pev_gravity, 1000)
set_pev(iEnt, pev_owner,id)
emit_sound(iEnt,CHAN_AUTO,Bomb_Sounds[1],1.0,ATTN_NORM,0,PITCH_NORM)
fm_drop_to_floor(iEnt)
create_trail(iEnt)
}
public fwFM_Touch(iEnt)
{
if(!pev_valid(iEnt)) return FMRES_IGNORED
new sClassname[32]
pev(iEnt, pev_classname, sClassname,31)
if(equal(sClassname,"direct_bomb"))
{
Bomb_Explode(iEnt)
fm_remove_entity(iEnt)
}
return FMRES_IGNORED
}
Bomb_Explode(ent)
{
if(!pev_valid (ent))
return
new Float:fOrigin[3]
pev (ent,pev_origin,fOrigin)
engfunc (EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0 )
write_byte (TE_EXPLOSION)
engfunc (EngFunc_WriteCoord, fOrigin[0])
engfunc (EngFunc_WriteCoord, fOrigin[1])
engfunc (EngFunc_WriteCoord, fOrigin[2])
write_short(exp_spr)
write_byte(50)
write_byte(15)
write_byte(0)
message_end()/*
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, origin[0])
engfunc(EngFunc_WriteCoord, origin[1])
engfunc(EngFunc_WriteCoord, origin[2])
write_byte(random_num(46, 48))
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(5)
write_coord(floatround(origin[0]))
write_coord(floatround(origin[1]))
write_coord(floatround(origin[2]))
write_short(smoke)
write_byte(35)
write_byte(5)
message_end()*/
new owner = pev(ent, pev_owner)
for ( new i = 1; i < get_maxplayers(); i++ )
{
if(!is_user_alive(i) || !zp_get_user_zombie(i))
continue
new Float:fOrigin2[3]
pev(i, pev_origin,fOrigin2)
new Float:distance_f = get_distance_f(fOrigin, fOrigin2)
new Float:radius_f = 300.0
if ( distance_f <= radius_f)
{
new normaldamage = floatround(500.0 - (1000.0*distance_f)/radius_f)
new d = get_user_health(i)- normaldamage
if( d >= 1)
{
set_pev(i, pev_health, float(d))
}
else
{
Death_Msg(i,"grenade",owner)
}
}
}
}
stock Death_Msg(iVictim,const class[], iAttacker)
{
set_msg_block(get_user_msgid("DeathMsg"),BLOCK_SET)
ExecuteHamB(Ham_Killed,iVictim,iAttacker,0)
set_msg_block(get_user_msgid("DeathMsg"),BLOCK_NOT)
make_deathmsg(iAttacker,iVictim,0,class)
message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
write_byte(iAttacker)
write_short(pev(iAttacker, pev_frags))
write_short(cs_get_user_deaths(iAttacker))
write_short(0)
write_short(get_user_team(iAttacker))
message_end()
message_begin(MSG_BROADCAST, get_user_msgid("ScoreInfo"))
write_byte(iVictim)
write_short(pev(iVictim, pev_frags))
write_short(cs_get_user_deaths(iVictim))
write_short(0)
write_short(get_user_team(iVictim))
message_end()
}
stock create_trail(iEnt)
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(iEnt)
write_short(trail_spr)
write_byte(10)
write_byte(3)
write_byte(255)
write_byte(255)
write_byte(255)
write_byte(255)
message_end()
}
stock fm_get_aim_origin(index, Float:origin[3]) {
new Float:start[3], Float:view_ofs[3];
pev(index, pev_origin, start);
pev(index, pev_view_ofs, view_ofs);
xs_vec_add(start, view_ofs, start);
new Float:dest[3];
pev(index, pev_v_angle, dest);
engfunc(EngFunc_MakeVectors, dest);
global_get(glb_v_forward, dest);
xs_vec_mul_scalar(dest, 9999.0, dest);
xs_vec_add(start, dest, dest);
engfunc(EngFunc_TraceLine, start, dest, 0, index, 0);
get_tr2(0, TR_vecEndPos, origin);
return 1;
}
stock is_wall_between_points(const Float:fStart[3], Ent, iIgnoreEnt = 0, isIgnoreMonsters = true)
{
new Float:fEnd[3]
pev(Ent, pev_origin,fEnd)
new ptr = create_tr2()
engfunc(EngFunc_TraceLine, fStart, fEnd, (isIgnoreMonsters) ? IGNORE_MONSTERS : DONT_IGNORE_MONSTERS, iIgnoreEnt, ptr)
new Float:fFraction
get_tr2(ptr, TR_flFraction, fFraction)
free_tr2(ptr)
return (fFraction != 1.0)
}


, nó cứ xoay xoay, lúc đỏ lúc ko đỏ, kệ nó thôi,

. Yên tâm là khi ta dedicated server tên chú kungfulon sẽ có trong credits với sontung0
