Witam. Jako że na tym rodzaju programowania znam się mało albo wcale
proszę was o pomoc.
Chcę zrobić plugin w którym gracz może podłożyć swoje granaty jako pułapki, a później zdalnie zdetonować je za pomocą klawisza.
Znalazłem w diablo coś podobnego, otóż granat się podkłada ale wybucha jeżeli obok przejdzie wróg:
//pulapki z granatow
public grenade_throw(id, ent, wID)
{
if(!g_TrapMode[id] || !is_valid_ent(ent))
return PLUGIN_CONTINUE
new Float:fVelocity[3]
VelocityByAim(id, cvar_throw_vel, fVelocity)
entity_set_vector(ent, EV_VEC_velocity, fVelocity)
new Float: angle[3]
entity_get_vector(ent,EV_VEC_angles,angle)
angle[0]=0.00
entity_set_vector(ent,EV_VEC_angles,angle)
entity_set_float(ent,EV_FL_dmgtime,get_gametime()+3.5)
entity_set_int(ent, NADE_PAUSE, 0)
entity_set_int(ent, NADE_ACTIVE, 0)
entity_set_int(ent, NADE_VELOCITY, 0)
entity_set_int(ent, NADE_TEAM, get_user_team(id))
new param[1]
param[0] = ent
set_task(3.0, "task_ActivateTrap", 0, param, 1)
return PLUGIN_CONTINUE
}
public task_ActivateTrap(param[])
{
new ent = param[0]
if(!is_valid_ent(ent))
return PLUGIN_CONTINUE
entity_set_int(ent, NADE_PAUSE, 1)
entity_set_int(ent, NADE_ACTIVE, 1)
new Float:fOrigin[3]
entity_get_vector(ent, EV_VEC_origin, fOrigin)
fOrigin[2] -= 8.1*(1.0-floatpower( 2.7182, -0.06798*float(player_agility[entity_get_edict(ent,EV_ENT_owner)])))
entity_set_vector(ent, EV_VEC_origin, fOrigin)
return PLUGIN_CONTINUE
}
public think_Grenade(ent)
{
new entModel[33]
entity_get_string(ent, EV_SZ_model, entModel, 32)
if(!is_valid_ent(ent) || equal(entModel, "models/w_c4.mdl"))
return PLUGIN_CONTINUE
if(entity_get_int(ent, NADE_PAUSE))
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public think_Bot(bot)
{
new ent = -1
while((ent = find_ent_by_class(ent, "grenade")))
{
new entModel[33]
entity_get_string(ent, EV_SZ_model, entModel, 32)
if(equal(entModel, "models/w_c4.mdl"))
continue
if(!entity_get_int(ent, NADE_ACTIVE))
continue
new Players[32], iNum
get_players(Players, iNum, "a")
for(new i = 0; i < iNum; ++i)
{
new id = Players[i]
if(entity_get_int(ent, NADE_TEAM) == get_user_team(id))
continue
if(get_entity_distance(id, ent) > cvar_activate_dis || player_speed(id) <200.0)
continue
if(entity_get_int(ent, NADE_VELOCITY)) continue
new Float:fOrigin[3]
entity_get_vector(ent, EV_VEC_origin, fOrigin)
while(PointContents(fOrigin) == CONTENTS_SOLID)
fOrigin[2] += 100.0
entity_set_vector(ent, EV_VEC_origin, fOrigin)
drop_to_floor(ent)
new Float:fVelocity[3]
entity_get_vector(ent, EV_VEC_velocity, fVelocity)
fVelocity[2] += float(cvar_nade_vel)
entity_set_vector(ent, EV_VEC_velocity, fVelocity)
entity_set_int(ent, NADE_VELOCITY, 1)
new param[1]
param[0] = ent
//set_task(cvar_explode_delay, "task_ExplodeNade", 0, param, 1)
entity_set_float(param[0], EV_FL_nextthink, halflife_time() + cvar_explode_delay)
entity_set_int(param[0], NADE_PAUSE, 0)
}
}
if(get_timeleft()<2 && map_end<2)
{
map_end=2
}
else if(get_timeleft()<6 && map_end<1)
{
new play[32],num
get_players(play,num)
for(new i=0;i<num;i++)
{
savexpcom(play[i])
}
map_end=1
}
entity_set_float(bot, EV_FL_nextthink, halflife_time() + 0.1)
}
Jeżeli byłby ktoś tak miły i przerobił to tak jak opisałem wyżej będę wdzięczny (a jeżeli ktoś liczy sobie czas za swoją pracę wpłacę co nie co, ale bez przesady
)
Użytkownik Sniper Elite edytował ten post 04.03.2014 22:51


Dodatki SourceMod












