Raised This Month: $ Target: $400
 0% 

Spawned a NULL entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Fixsek Kot
Junior Member
Join Date: Feb 2022
Old 07-04-2022 , 14:19   Spawned a NULL entity
Reply With Quote #1

Hi,

I've been struggling creating a lasermine, just can't understand it, because people have to make their codes way to hard to read for some reason. So I wrote some code, tested it in game and I got a fatal error: "Spawned a NULL entity!" I tried to search what this means and how to fix it, so I'm begging for not only a help to solve this issue, but also explain to me at least a little, how to make the lasermine work, because I guess it won't work properly:

Quote:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <xs>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
new LM_MODEL[] = "models/zombiechronicbykot/lasermine/lasermine.mdl"
enum _:SERVER_DATA
{
LASER_ENTITY
}
enum _:LASER_PROPS
{
LASER_OWNER = pev_iuser1,
LASER_BEAM = pev_iuser2,
LASER_TEAM = pev_iuser3,
LASER_STEP = pev_iuser4,
LASER_END = pev_vuser1,
LASER_ANGLES = pev_angles,
LASER_ORIGIN = pev_origin,
LASER_POWERUP = 0,
LASER_ACTIVATED = 1,
LASER_EXPLODE = 2,
LASER_CREATE = 3,
LASER_REMOVE = 4
}
enum _:LASER_VECTOR
{
Float:LV_PLAYER,
Float:LV_ANGLES,
Float:LV_END,
Float:LV_NORMAL,
}
new server_data[SERVER_DATA]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
}
public plugin_precache()
{
precache_model(LM_MODEL)
}
public client_putinserver(id)
{
set_task(8.0, "CreateUserLaser", id)
}
public CreateUserLaser(iTask)
{
static id, iEnt

iEnt = engfunc(EngFunc_CreateNamedEntity, server_data[LASER_ENTITY])

engfunc(EngFunc_SetModel, iEnt, LM_MODEL);
engfunc(EngFunc_SetSize, iEnt, { -4.0,-4.0,-4.0 }, { 4.0,4.0,4.0 });

set_pev(iEnt, pev_classname, "zm_laser");
set_pev(iEnt, pev_solid, SOLID_NOT);
set_pev(iEnt, pev_movetype, MOVETYPE_FLY);

set_pev(iEnt, pev_health, 750.0);
set_pev(iEnt, pev_takedamage, 0.0);

set_pev(iEnt, pev_iuser1, id);
set_pev(iEnt, pev_iuser3, get_user_team(id));
set_pev(iEnt, pev_iuser4, 0);

SetLaserPosition(id, iEnt);

set_pev(iEnt, pev_frame, 0);
set_pev(iEnt, pev_framerate, 0);
set_pev(iEnt, pev_body, 3);
set_pev(iEnt, pev_sequence, 7);
set_pev(iEnt, pev_nextthink, get_gametime() + 3.0)
}
SetLaserPosition(const id, const iEnt)
{
static Float:fVector[LASER_VECTOR][3], Float:fFraction, iTrace;
iTrace = create_tr2();

pev(id, pev_origin, fVector[LV_PLAYER]);
pev(id, pev_v_angle, fVector[LV_ANGLES]);

angle_vector(fVector[LV_ANGLES], ANGLEVECTOR_FORWARD, fVector[LV_ANGLES]);

xs_vec_mul_scalar(fVector[LV_ANGLES], 128.0, fVector[LV_ANGLES]);
xs_vec_add(fVector[LV_PLAYER], fVector[LV_ANGLES], fVector[LV_END]);

engfunc(EngFunc_TraceLine, fVector[LV_PLAYER], fVector[LV_END], DONT_IGNORE_MONSTERS, id, iTrace);

get_tr2(iTrace, TR_flFraction, fFraction);
get_tr2(iTrace, TR_vecEndPos, fVector[LV_END]);
get_tr2(iTrace, TR_vecPlaneNormal, fVector[LV_NORMAL]);

free_tr2(iTrace);
iTrace = create_tr2();

xs_vec_mul_scalar(fVector[LV_NORMAL], 8.0, fVector[LV_NORMAL]);
xs_vec_add(fVector[LV_END], fVector[LV_NORMAL], fVector[LV_END]);

engfunc(EngFunc_SetOrigin, iEnt, fVector[LV_END]);

vector_to_angle(fVector[LV_NORMAL], fVector[LV_ANGLES]);
set_pev(iEnt, LASER_ANGLES, fVector[LV_ANGLES]);

if (fFraction < 1.0)
{
xs_vec_mul_scalar(fVector[LV_NORMAL], 8192.0, fVector[LV_NORMAL]);
engfunc(EngFunc_TraceLine, fVector[LV_END], fVector[LV_NORMAL], IGNORE_MONSTERS, iEnt, iTrace);

get_tr2(iTrace, TR_vecEndPos, fVector[LV_END]);
free_tr2(iTrace);
}

set_pev(iEnt, LASER_END, fVector[LV_END])
}
Best regards,

-Fixsek Kot

Last edited by Fixsek Kot; 07-04-2022 at 14:20.
Fixsek Kot is offline
 


Thread Tools
Display Modes

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 18:05.


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