Raised This Month: $ Target: $400
 0% 

Creating env_beam problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-27-2009 , 16:27   Creating env_beam problem
Reply With Quote #1

I'm trying to create an env_beam just like you would when making one in hammer editor. Using 3 ents - the start point, end point, and beam ent.

I've tried so many different things using both fakemeta and engine to get this working.

If you run the following code you will see it makes both end points and the beam sprite, but the beam sprite doesn't connect to the points (note: I made the end points a sprite just so I could see them).

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN    "Create env_beam"
#define VERSION    "1.0"
#define AUTHOR    "hlstriker"

#define BEAM_SPRITE "sprites/laserbeam.spr"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /beam""CreateBeamEnts");
}

public 
plugin_precache()
{
    
precache_model(BEAM_SPRITE);
}

public 
CreateBeamEnts(iClient)
{
    
CreateEntStart(iClient);
    
CreateEntEnd(iClient);
    
set_task(0.5"CreateBeam"iClient);
}

CreateEntStart(iClient)
{
    new 
Float:flOrigin[3];
    
GetFrontOrigin(iClient50flOrigin);
    
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
set_keyvalue(iEnt"targetname""startbeam");
    
dllfunc(DLLFunc_SpawniEnt);
    
dllfunc(DLLFunc_ThinkiEnt);
    
set_pev(iEntpev_solidSOLID_BBOX);
    
//set_pev(iEnt, pev_targetname, "startbeam");
    
engfunc(EngFunc_SetOriginiEntflOrigin);
    
engfunc(EngFunc_SetModeliEntBEAM_SPRITE);
    
engfunc(EngFunc_SetSizeiEntFloat:{-4.0, -4.00.0}, Float:{4.04.08.0});
    
    
client_print(0print_chat"START: [%f] - [%f] - [%f]"flOrigin[0], flOrigin[1], flOrigin[2]);
}

CreateEntEnd(iClient)
{
    new 
Float:flOrigin[3];
    
GetFrontOrigin(iClient300flOrigin);
    
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
set_keyvalue(iEnt"targetname""endbeam");
    
dllfunc(DLLFunc_SpawniEnt);
    
dllfunc(DLLFunc_ThinkiEnt);
    
set_pev(iEntpev_solidSOLID_BBOX);
    
//set_pev(iEnt, pev_targetname, "endbeam");
    
engfunc(EngFunc_SetOriginiEntflOrigin);
    
engfunc(EngFunc_SetModeliEntBEAM_SPRITE);
    
engfunc(EngFunc_SetSizeiEntFloat:{-4.0, -4.00.0}, Float:{4.04.08.0});
    
    
client_print(0print_chat"END: [%f] - [%f] - [%f]"flOrigin[0], flOrigin[1], flOrigin[2]);
}

public 
CreateBeam(iClient)
{
    new 
Float:flOrigin[3];
    
GetFrontOrigin(iClient150flOrigin);
    
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_beam"));
    
set_keyvalue(iEnt"Radius""256");
    
set_keyvalue(iEnt"StrikeTime""10");
    
set_keyvalue(iEnt"TextureScroll""100");
    
set_keyvalue(iEnt"texture"BEAM_SPRITE);
    
set_keyvalue(iEnt"BoltWidth""8");
    
set_keyvalue(iEnt"rendermode""5");
    
set_keyvalue(iEnt"rendercolor""255 0 0");
    
set_keyvalue(iEnt"renderamt""125");
    
set_keyvalue(iEnt"LightningEnd""endbeam");
    
set_keyvalue(iEnt"LightningStart""startbeam");
    
set_keyvalue(iEnt"spawnflags""1");
    
//set_keyvalue(iEnt, "classname", "env_beam");
    
dllfunc(DLLFunc_SpawniEnt);
    
dllfunc(DLLFunc_ThinkiEnt);
    
set_pev(iEntpev_solidSOLID_BBOX);
    
engfunc(EngFunc_SetOriginiEntflOrigin);
    
engfunc(EngFunc_SetModeliEntBEAM_SPRITE);
    
engfunc(EngFunc_SetSizeiEntFloat:{-4.0, -4.00.0}, Float:{4.04.08.0});
    
    
client_print(0print_chat"BEAM: [%f] - [%f] - [%f]"flOrigin[0], flOrigin[1], flOrigin[2]);
}

stock GetFrontOrigin(iEntiDistanceFloat:flReturnOrigin[3])
{
    static 
Float:flOrigin[3], Float:flAngles[3];
    
pev(iEntpev_originflOrigin);
    
pev(iEntpev_v_angleflAngles);
    
flAngles[0] = 0.0;
    
    
angle_vector(flAnglesANGLEVECTOR_FORWARDflReturnOrigin);
    
flReturnOrigin[0] = flOrigin[0] + flReturnOrigin[0] * iDistance;
    
flReturnOrigin[1] = flOrigin[1] + flReturnOrigin[1] * iDistance;
    
flReturnOrigin[2] = flOrigin[2];
}

stock set_keyvalue(iEntszKey[], szValue[])
{
    new 
szClassname[32];
    
pev(iEntpev_classnameszClassnamesizeof(szClassname)-1);
    
set_kvd(0KV_ClassNameszClassname);
    
set_kvd(0KV_KeyNameszKey);
    
set_kvd(0KV_ValueszValue);
    
set_kvd(0KV_fHandled0);
    
    
dllfunc(DLLFunc_KeyValueiEnt0);

Here is a screen shot of what that produces:
[img]http://img190.**************/img190/7384/beamk.jpg[/img]

Here is what I want it to produce:
[img]http://img212.**************/img212/2069/goodbeam.jpg[/img]

Anyone have any ideas how to make this?
hlstriker is offline
 



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:24.


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