entity issues
hello o/, I'm getting annoying issues on the usage of this plugin... the problem is Its entity, It's not removing, no errors from compiling but when I use It, it makes everything stuck, I mean, hostages aren't moving they are getting under the ground too, C4 flying after planted, respawning inside walls and instantly dying, here goes the code and the debug walls from It:
I did change Its natives from vexd to engine, so they could get compiled on newer amxmodx versions, don't know if this information is useful but yeah
note: error lines have the a prefix indicating which line it is
PHP Code:
/* CVARS - copy and paste to shconfig.cfg
*
// Iceman - Marvel Comics
iceman_level 0 // Level at which Iceman is available
iceman_speed 260 // Speed of Iceman on ice trail
*
*/
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fun>
#include <superheromod>
#define PLUGIN_NAME "SH Iceman"
#define PLUGIN_VERSION "22.05.18"
#define PLUGIN_AUTHOR "Kojiro"
#define SUPERHERO_NAME "Iceman"
#define SUPERHERO_INFO "Ice Trail"
#define SUPERHERO_HELP "Slide on an ice trail towards a targeted direction."
new gHeroID, gPcvarLevel, gPcvarSpeed
new const gSoundTrail[] = "roach/rch_smash.wav"
new gSpriteIce[1][] = {"sprites/bubble.spr"}
new gSpriteTrail
new bool:gHasIcemanPower[SH_MAXSLOTS+1]
new Float:gMaxSpeed
new gIceTrailRunning[SH_MAXSLOTS+1]
new gEndLocation[SH_MAXSLOTS+1][3]
new gIce[SH_MAXSLOTS]
//----------------------------------------------------------------------------------------------------------------------
public plugin_init()
{
// PLUGIN
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
// CVARS
gPcvarLevel = register_cvar("iceman_level", "0")
gPcvarSpeed = register_cvar("iceman_speed", "260")
// HERO
gHeroID = sh_create_hero(SUPERHERO_NAME, gPcvarLevel)
sh_set_hero_info(gHeroID, SUPERHERO_INFO, SUPERHERO_HELP)
sh_set_hero_bind(gHeroID)
// LOADING
set_task(4.0, "iceman_loading")
}
//----------------------------------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound(gSoundTrail)
for (new i = 0; i < 1; i++)
{
precache_model(gSpriteIce[i])
}
gSpriteTrail = precache_model("sprites/laserbeam.spr")
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_loading()
{
gMaxSpeed = get_pcvar_float(gPcvarSpeed)
}
//----------------------------------------------------------------------------------------------------------------------
public client_connect(id)
{
if (id <=0 || id > SH_MAXSLOTS)
{
return
}
gIceTrailRunning[id] = 0
set_user_info(id, "JETPACK_RUN", "0")
iceman_removetrail(id)
remove_task(id+36485)
}
//----------------------------------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
if (gHeroID != heroID)
{
return
}
switch(mode)
{
case SH_HERO_ADD:
{
gHasIcemanPower[id] = true
remove_task(id+36485)
set_task(0.1, "iceman_location", id+36485, "", 0, "b")
}
case SH_HERO_DROP:
{
gHasIcemanPower[id] = false
remove_task(id+36485)
}
}
}
//----------------------------------------------------------------------------------------------------------------------
public sh_hero_key(id, heroID, key)
{
if (gHeroID != heroID || !is_user_alive(id) || !gHasIcemanPower[id])
{
return
}
switch(key)
{
case SH_KEYDOWN:
{
gIceTrailRunning[id] = 1
set_user_info(id, "JETPACK_RUN", "1")
iceman_loading()
line 120 > iceman_starttrail(id)
return
}
case SH_KEYUP:
{
if (gIceTrailRunning[id] != 1)
{
return
}
gIceTrailRunning[id] = 0
set_user_info(id, "JETPACK_RUN","0")
iceman_removetrail(id)
}
}
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_location(id)
{
id -= 36485
new Float:velocity[3]
new origin[3]
new user_origin[3]
new aimvec[3]
new Float:b_orig[3]
if (!is_user_alive(id))
{
return PLUGIN_HANDLED
}
get_user_origin(id, gEndLocation[id], 3)
if (gIceTrailRunning[id] == 1)
{
emit_sound(id, CHAN_STATIC, gSoundTrail, 0.5, ATTN_NORM, 0, PITCH_HIGH)
get_user_origin(id, user_origin)
entity_get_vector(id, EV_VEC_velocity, velocity)
new distance
distance = get_distance(gEndLocation[id], user_origin)
velocity[0] = (gEndLocation[id][0] - user_origin[0]) * (1.0 * gMaxSpeed / distance)
velocity[1] = (gEndLocation[id][1] - user_origin[1]) * (1.0 * gMaxSpeed / distance)
velocity[2] = (gEndLocation[id][2] - user_origin[2]) * (1.0 * gMaxSpeed / distance)
entity_set_vector(id, EV_VEC_velocity, velocity)
new distance2[2]
distance2[0] = gEndLocation[id][0]-user_origin[0]
distance2[1] = gEndLocation[id][1]-user_origin[1]
new unitsinfront = 1
aimvec[0]=user_origin[0]+(unitsinfront*distance2[0])/sqrt(distance2[0]*distance2[0]+distance2[1]*distance2[1])
aimvec[1]=user_origin[1]+(unitsinfront*distance2[1])/sqrt(distance2[0]*distance2[0]+distance2[1]*distance2[1])
aimvec[2]=user_origin[2]-34
b_orig[0] = float(aimvec[0]);
b_orig[1] = float(aimvec[1]);
b_orig[2] = float(aimvec[2]);
entity_set_origin(gIce[id], b_orig)
get_user_origin(id, origin, 1)
iceman_effect(origin)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_effect(origin[3])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_TELEPORT)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2]-34)
message_end()
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_starttrail(id)
{
new user_origin[3]
new origin2[3]
get_user_origin(id, origin2, 1)
line 207 > iceman_maketrail(id, origin2)
get_user_origin(id, user_origin)
get_user_origin(id, gEndLocation[id], 3)
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_maketrail(id, origin2[3])
{
if (!is_user_alive(id))
{
return PLUGIN_HANDLED
}
new Float: Origin[3]
new Float: vAngle[3]
new Float: Velocity[3]
line 223 > remove_entity(gIce[id])
entity_get_vector(id, EV_VEC_origin , Origin)
entity_get_vector(id, EV_VEC_v_angle, vAngle)
gIce[id] = create_entity("info_target")
entity_set_string(gIce[id], EV_SZ_classname, "ice_sheet")
entity_set_model(gIce[id], gSpriteIce[0])
new Float:MinBox[3]
new Float:MaxBox[3]
MinBox[0] = -1.0
MinBox[1] = -1.0
MinBox[2] = -1.0
MaxBox[0] = 1.0
MaxBox[1] = 1.0
MaxBox[2] = 1.0
entity_set_vector(gIce[id], EV_VEC_mins, MinBox)
entity_set_vector(gIce[id], EV_VEC_maxs, MaxBox)
entity_set_origin(gIce[id], Origin)
entity_set_vector(gIce[id], EV_VEC_angles, vAngle)
entity_set_int(gIce[id], EV_INT_solid, 0)
entity_set_int(gIce[id], EV_INT_movetype, 5)
entity_set_edict(gIce[id], EV_ENT_owner, id)
VelocityByAim(id, 0, Velocity)
entity_set_vector(gIce[id], EV_VEC_velocity, Velocity)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(gIce[id])
write_short(gSpriteTrail)
write_byte(35)
write_byte(25)
write_byte(0)
write_byte(128)
write_byte(255)
write_byte(3000)
message_end()
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_removetrail(id)
{
if (gIce[id])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY, {0, 0, 0}, gIce[id])
write_byte(TE_KILLBEAM)
write_short(gIce[id])
message_end()
remove_entity(gIce[id])
gIce[id] = 0
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------------------------------------------------------------------
public sh_client_death(id)
{
if (gHasIcemanPower[id])
{
gIceTrailRunning[id] = 0
set_user_info(id, "JETPACK_RUN", "0")
iceman_removetrail(id)
}
}
//----------------------------------------------------------------------------------------------------------------------
public sh_client_spawn(id)
{
if (!gHasIcemanPower[id])
{
return PLUGIN_CONTINUE
}
if (gHasIcemanPower[id] && gIce[id])
{
remove_entity(gIce[id])
gIce[id] = 0
gIceTrailRunning[id] = 0
set_user_info(id, "JETPACK_RUN", "0")
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------------------------------
public client_disconnected(id)
{
if (id <=0 || id > SH_MAXSLOTS)
{
return
}
gIceTrailRunning[id] = 0
set_user_info(id, "JETPACK_RUN", "0")
iceman_removetrail(id)
remove_task(id+36485)
}
//----------------------------------------------------------------------------------------------------------------------
debug:
PHP Code:
L 05/28/2022 - 23:32:02: [ENGINE] Entity 0 can not be removed
L 05/28/2022 - 23:32:02: [AMXX] Displaying debug trace (plugin "sh_iceman.amxx", version "22.05.18")
L 05/28/2022 - 23:32:02: [AMXX] Run time error 10: native error (native "remove_entity")
L 05/28/2022 - 23:32:02: [AMXX] [0] sh_iceman.sma::iceman_maketrail (line 223)
L 05/28/2022 - 23:32:02: [AMXX] [1] sh_iceman.sma::iceman_starttrail (line 207)
L 05/28/2022 - 23:32:02: [AMXX] [2] sh_iceman.sma::sh_hero_key (line 120)
|