Zrób wszystko według poradnika tylko zamiast tego dłuższego kodu wklej to:
public kula1(id)
{
new xD = floatround(halflife_time()-wait1[id])
new czas = 10-xD
if (halflife_time()-wait1[id] <= 10)
{
client_print(id, print_center, "Za %d sek mozesz uzyc mocy!", czas)
return PLUGIN_CONTINUE;
}
else {
DispBall_Spawn(id)
wait1[id]=floatround(halflife_time())
}
return PLUGIN_HANDLED
}
public DispBall_Explode(ent)
{
if (!pev(ent, pev_iuser3)){
new Float: origin[3];
pev(ent, pev_origin, origin);
set_pev(ent, pev_iuser3, 1);
UTIL_MakeBeamCylinder(origin, m_DispRing) ;
new Players[32], playerCount, a
get_players(Players, playerCount, "ah")
new id = pev(ent,pev_owner)
for (new i=0; i<playerCount; i++)
{
a = Players[i]
new Float:aOrigin[3]
pev(a,pev_origin,aOrigin)
if (get_user_team(id) != get_user_team(a) && get_distance_f(aOrigin,origin) < 280.0)
{
ExecuteHamB(Ham_TakeDamage, a, ent, id, 25.0+player_intelligence[id]*1.5, DMG_ENERGYBEAM );
}
}
}
set_pev(ent, pev_velocity, Float:{0.0, 0.0, 0.0});
set_pev(ent, pev_iuser4, 1);
set_pev(ent, pev_nextthink, get_gametime() + 0.6);
}
public DispBall_Spawn(id)
{
static AllocStringCached;
if (!AllocStringCached)
{
AllocStringCached = engfunc(EngFunc_AllocString, "info_target");
}
new ent = engfunc(EngFunc_CreateNamedEntity, AllocStringCached);
if(!pev_valid(ent)) return 0;
set_pev(ent, pev_classname, BALL_CLASSNAME);
new Float: origin[3];
new Float: velocity[3];
new Float: v_forward[3];
new Float: v_right[3];
new Float: v_up[3];
GetGunPosition(id, origin);
global_get(glb_v_forward, v_forward);
global_get(glb_v_right, v_right);
global_get(glb_v_up, v_up);
//xs_vec_mul_scalar(v_forward, 29.0, v_forward)
xs_vec_mul_scalar(v_right, 2.0, v_right);
xs_vec_mul_scalar(v_up, -5.0, v_up);
xs_vec_add(origin, v_forward, origin);
xs_vec_add(origin, v_right, origin);
xs_vec_add(origin, v_up, origin);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_owner, id);
set_pev(ent, pev_dmg, 100.0);
engfunc(EngFunc_SetModel, ent, m_ExitPortal);
engfunc(EngFunc_SetSize, ent, Float:{0.0, 0.0, 0.0} , Float:{0.0, 0.0, 0.0});
set_pev(ent, pev_effects, pev(ent, pev_effects) | EF_LIGHT);
set_rendering(ent, kRenderFxNone, 0, 0, 0, kRenderTransAdd, 255);
velocity_by_aim(id, 500, velocity);
set_pev(ent, pev_velocity, velocity);
dllfunc(DLLFunc_Spawn, ent);
set_pev(ent, pev_movetype, MOVETYPE_FLY);
set_pev(ent, pev_solid, SOLID_BBOX);
set_pev(ent, pev_scale, 5);
set_pev(ent, pev_nextthink, get_gametime() + 0.1);
return ent;
}
public DispBall_Think(ent)
{
if (!pev_valid(ent))
return;
DispBall_Animate(ent);
if (pev(ent, pev_iuser4))
{
remove_entity(ent);
return;
}
static Float: velocity[3];
pev(ent, pev_velocity, velocity);
if (!vector_length(velocity) || !IsInWorld(ent))
{
DispBall_Explode(ent)
return;
}
static ptr, i, id, owner, beam;
static Float: Dist;
static Float: flFraction;
static Float: origin[3];
static Float: vecDir[3];
static Float: vecEndPos[3];
Dist = 1.00; ptr = create_tr2();
pev(ent, pev_origin, origin);
while ((id = engfunc(EngFunc_FindEntityInSphere, id, origin, 280.0)))
{
if (random_float(0.0, 1.0) <= 0.2 && pev(id, pev_takedamage) && is_visible(id, ent) && id != (owner = pev(ent, pev_owner)))
{
static Float: target_origin[3]; pev(id, pev_origin, target_origin);
ExecuteHamB(Ham_TakeDamage, id, ent, owner, 22.0, DMG_ENERGYBEAM );
if ((beam = BeamCreate(id, SPRITE_PLASMA, m_Plasma, 65.0)))
{
RelinkBeam(beam, origin, target_origin);
BeamSetColor(beam, 255.0, 255.0, 255.0);
BeamSetNoise(beam, 45);
BeamSetBrightness(beam, 255.0);
BeamSetScrollRate(beam, 35.0);
BeamLiveForTime(beam, 0.1);
}
}
}
for (i = 0; i < 10; i++)
{
vecDir[0] = random_float(-1.0, 1.0);
vecDir[1] = random_float(-1.0, 1.0);
vecDir[2] = random_float(-1.0, 1.0);
VecNormilize(vecDir, vecDir);
xs_vec_mul_scalar(vecDir, 1536.0, vecDir);
xs_vec_add(vecDir, origin, vecDir);
engfunc(EngFunc_TraceLine, origin, vecDir, IGNORE_MONSTERS, ent, ptr);
get_tr2(ptr, TR_flFraction, flFraction);
if (Dist > flFraction)
{
get_tr2(ptr, TR_vecEndPos, vecEndPos);
Dist = flFraction;
}
}
if (Dist < 1.0)
{
if ((beam = BeamCreate(ent, SPRITE_PLASMA, m_Plasma, 30.0)))
{
RelinkBeam(beam, vecEndPos, origin);
BeamSetColor(beam, 23.0, 170.0, 17.0);
BeamSetNoise(beam, 65);
BeamSetBrightness(beam, 255.0);
BeamSetScrollRate(beam, 35.0);
BeamLiveForTime(beam, 1.0);
}
}
set_pev(ent, pev_nextthink, get_gametime() + 0.1);
free_tr2(ptr);
}
public DispBeam_Think(ent)
{
if (pev_valid(ent))
{
remove_entity(ent);
}
}
public DispBall_Explode_Touch(ent)
{
if (pev_valid(ent))
{
DispBall_Explode(ent);
}
}
stock GetGunPosition(const player, Float:origin[3] )
{
new Float:viewOfs[3];
pev(player, pev_origin, origin);
pev(player, pev_view_ofs, viewOfs);
xs_vec_add( origin, viewOfs, origin);
}
stock BeamCreate(const endIndex, const pSpriteName[], const spriteIndex, const Float: width)
{
static AllocStringCached;
if (!AllocStringCached)
{
AllocStringCached = engfunc(EngFunc_AllocString, "beam");
}
static ent;
if (!(ent = engfunc(EngFunc_CreateNamedEntity, AllocStringCached)))
return 0;
set_pev(ent, pev_classname, BEAM_CLASSNAME);
set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_CUSTOMENTITY);
BeamSetFrame(ent, 0);
set_pev(ent, pev_model, pSpriteName);
BeamSetTexture(ent, spriteIndex);
BeamSetWidth(ent, width);
set_pev(ent, pev_skin, endIndex);
set_pev(ent, pev_sequence, 0);
set_pev(ent, pev_rendermode, 1);
DispatchSpawn(ent);
return ent;
}
stock RelinkBeam(const beam, const Float: startPos[3], const Float: endPos[3])
{
static Float: mins[3], Float: maxs[3];
mins[0] = floatmin(startPos[0], endPos[0]);
mins[1] = floatmin(startPos[1], endPos[1]);
mins[2] = floatmin(startPos[2], endPos[2]);
maxs[0] = floatmax(startPos[0], endPos[0]);
maxs[1] = floatmax(startPos[1], endPos[1]);
maxs[2] = floatmax(startPos[2], endPos[2]);
xs_vec_sub(mins, startPos, mins);
xs_vec_sub(maxs, startPos, maxs);
set_pev(beam, pev_mins, mins);
set_pev(beam, pev_maxs, maxs);
engfunc(EngFunc_SetSize, beam, mins, maxs);
engfunc(EngFunc_SetOrigin, beam, startPos);
}
stock VecNormilize(Float: in[3], Float: out[3])
{
static Float: vlen;
vlen = vector_length(in);
vlen = 1/vlen;
out[0] *= vlen;
out[1] *= vlen;
out[2] *= vlen;
}
stock UTIL_MakeBeamCylinder(const Float:origin[3], const m_Sprite)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMCYLINDER);
engfunc(EngFunc_WriteCoord, origin[0]);
engfunc(EngFunc_WriteCoord, origin[1]);
engfunc(EngFunc_WriteCoord, origin[2]);
engfunc(EngFunc_WriteCoord, origin[0]);
engfunc(EngFunc_WriteCoord, origin[1]);
engfunc(EngFunc_WriteCoord, origin[2] + 200.0) ;
write_short(m_Sprite) ;
write_byte(0);
write_byte(10);
write_byte(3);
write_byte(20);
write_byte(0);
write_byte(255);
write_byte(255);
write_byte(255);
write_byte(255);
write_byte(0);
message_end();
}
DispBall_Animate(const ent)
{
entity_set_float(ent, EV_FL_frame, entity_get_float(ent, EV_FL_frame) + 10.0);
if (entity_get_float(ent, EV_FL_frame) > 24.0)
entity_set_float(ent, EV_FL_frame, 0.0);
}
BeamLiveForTime(const ent, const Float: time)
{
set_pev(ent, pev_nextthink, halflife_time() + time);
}
BeamSetColor(const ent, const Float: red, const Float: green, const Float: blue)
{
static Float: rgb[3];
rgb[0] = red;
rgb[1] = green;
rgb[2] = blue;
set_pev(ent, pev_rendercolor, rgb);
}
BeamSetBrightness(const ent, const Float: brightness)
{
set_pev(ent, pev_renderamt, brightness);
}
BeamSetNoise(const ent, const noise)
{
set_pev(ent, pev_body, noise);
}
BeamSetFrame(const ent, const frame)
{
set_pev(ent, pev_frame, frame);
}
BeamSetScrollRate(const ent, const Float: speed)
{
set_pev(ent, pev_animtime, speed);
}
BeamSetTexture(const ent, const spriteIndex)
{
set_pev(ent, pev_modelindex, spriteIndex);
}
BeamSetWidth(const ent, const Float: width)
{
set_pev(ent, pev_scale, width);
}