Raised This Month: $ Target: $400
 0% 

entity issues


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
brN17
Junior Member
Join Date: Mar 2022
Old 05-28-2022 , 20:15   entity issues
Reply With Quote #1

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 gHeroIDgPcvarLevelgPcvarSpeed
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_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)

    
// CVARS
    
gPcvarLevel register_cvar("iceman_level""0")
    
gPcvarSpeed register_cvar("iceman_speed""260")

    
// HERO
    
gHeroID sh_create_hero(SUPERHERO_NAMEgPcvarLevel)
    
sh_set_hero_info(gHeroIDSUPERHERO_INFOSUPERHERO_HELP)
    
sh_set_hero_bind(gHeroID)
    
    
// LOADING
    
set_task(4.0"iceman_loading")
}
//----------------------------------------------------------------------------------------------------------------------
public plugin_precache()
{
    
precache_sound(gSoundTrail)
    for (new 
01i++)
    {
        
precache_model(gSpriteIce[i])
    }
    
gSpriteTrail precache_model("sprites/laserbeam.spr")
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_loading()
{
    
gMaxSpeed get_pcvar_float(gPcvarSpeed)
}
//----------------------------------------------------------------------------------------------------------------------
public client_connect(id)
{
    if (
id <=|| 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(idheroIDmode)
{
    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(idheroIDkey)
{
    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(idgEndLocation[id], 3)
    if (
gIceTrailRunning[id] == 1)
    {
        
emit_sound(idCHAN_STATICgSoundTrail0.5ATTN_NORM0PITCH_HIGH)
        
        
get_user_origin(iduser_origin)

        
entity_get_vector(idEV_VEC_velocityvelocity)

        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(idEV_VEC_velocityvelocity)

          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(idorigin1)
        
iceman_effect(origin)
    }
    return 
PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_effect(origin[3])
{
    
message_begin(MSG_BROADCASTSVC_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(idorigin21)
line 207 iceman_maketrail(idorigin2)
    
get_user_origin(iduser_origin)
    
get_user_origin(idgEndLocation[id], 3)
}
//----------------------------------------------------------------------------------------------------------------------
public iceman_maketrail(idorigin2[3])
{
    if (!
is_user_alive(id))
    {
        return 
PLUGIN_HANDLED
    
}
    
      new 
FloatOrigin[3]
      new 
FloatvAngle[3]
      new 
FloatVelocity[3]
      
line 223 remove_entity(gIce[id])

    
entity_get_vector(idEV_VEC_origin Origin)
    
entity_get_vector(idEV_VEC_v_anglevAngle)
     
    
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_minsMinBox)
    
entity_set_vector(gIce[id], EV_VEC_maxsMaxBox)
   
    
entity_set_origin(gIce[id], Origin)
    
entity_set_vector(gIce[id], EV_VEC_anglesvAngle)

    
entity_set_int(gIce[id], EV_INT_solid0)
    
entity_set_int(gIce[id], EV_INT_movetype5)
    
entity_set_edict(gIce[id], EV_ENT_ownerid)
   
    
VelocityByAim(id0Velocity)
    
entity_set_vector(gIce[id], EV_VEC_velocityVelocity)
    
    
message_begin(MSG_BROADCASTSVC_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_BROADCASTSVC_TEMPENTITY, {000}, 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 <=|| 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: [ENGINEEntity 0 can not be removed
L 05
/28/2022 23:32:02: [AMXXDisplaying debug trace (plugin "sh_iceman.amxx"version "22.05.18")
L 05/28/2022 23:32:02: [AMXXRun time error 10native error (native "remove_entity")
L 05/28/2022 23:32:02: [AMXX]    [0sh_iceman.sma::iceman_maketrail (line 223)
L 05/28/2022 23:32:02: [AMXX]    [1sh_iceman.sma::iceman_starttrail (line 207)
L 05/28/2022 23:32:02: [AMXX]    [2sh_iceman.sma::sh_hero_key (line 120
brN17 is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 06-01-2022 , 08:19   Re: entity issues
Reply With Quote #2

[ENGINE] Entity 0 can not be removed
Have you tried anything? Like assure it is not 0, the worldspawn, at least.
Code:
if(gIce[id] > 0)
    remove_entity(gIce[id])
untested
is_valid_ent(gIce[id]) ? remove_entity(gIce[id]) : server_print("%i invalid^nCan't remove!"), gIce[id]
__________________
DJEarthQuake is offline
brN17
Junior Member
Join Date: Mar 2022
Old 06-03-2022 , 18:08   Re: entity issues
Reply With Quote #3

erasing line 223 worked fine
brN17 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode