Raised This Month: $ Target: $400
 0% 

Creating an entity with a model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 01-07-2008 , 15:06   Creating an entity with a model
Reply With Quote #1

I've never done this before, but I'm trying to create an entity where the player is aiming and give it a model. Right now all I'm seeing is the implode effect. I feel like I'm missing something really basic...

Code:
#include <amxmodx> #include <amxmisc> #include <engine>   #define PLUGIN "Radioactive Waste" #define AUTHOR "Harman" #define VERSION "1.0"   new isotopeModel[] = "models/chromegibs.mdl" new aimVector[3]   public plugin_precache() {      precache_model(isotopeModel) }   public plugin_init() {      register_plugin(PLUGIN, AUTHOR, VERSION)      register_clcmd("waste", "radiate") }   public radiate(id) {      new isotopeEnt = create_entity("info_target")      entity_set_string(isotopeEnt,EV_SZ_classname,"isotope")      get_user_origin(id, aimVector, 3) //where the player is aiming      entity_set_origin(isotopeEnt, aimVector)      entity_set_model(isotopeEnt, isotopeModel)            message_begin(MSG_BROADCAST,SVC_TEMPENTITY) //implosion effect      write_byte(TE_IMPLOSION)      write_coord(aimVector[0])      write_coord(aimVector[1])      write_coord(aimVector[2])      write_byte(100) //radius      write_byte(50)  //count      write_byte(25)  //lifetime      message_end()            client_print(id, print_chat, "Test")            return PLUGIN_HANDLED }
Prajch is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 01-07-2008 , 15:14   Re: Creating an entity with a model
Reply With Quote #2

Try to use fakemeta instead of engine, is more efficient and is more handy.

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
 
#define PLUGIN "Radioactive Waste"
#define AUTHOR "Harman"
#define VERSION "1.0"
 
new isotopeModel[] = "models/chromegibs.mdl"
new aimVector[3]
 
public plugin_precache()
{
 precache_model(isotopeModel)
}
 
public plugin_init()
{
 register_plugin(PLUGIN, AUTHOR, VERSION)
 register_clcmd("waste", "radiate")
}
 
public radiate(id)
{
 //new isotopeEnt = create_entity("info_target")
 new isotopeEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"));
 
 //entity_set_string(isotopeEnt,EV_SZ_classname,"isotope")
 set_pev(isotopeEnt, pev_classname, "isotope");
 get_user_origin(id, aimVector, 3) //where the player is aiming
 
 new Float:fOrigin[3];
 IVecFVec(aimVector, fOrigin); //covert aim origin(int) to float.
 
 set_pev(isotopeEnt, pev_origin, fOrigin);
 //entity_set_model(isotopeEnt, isotopeModel)
 engfunc(EngFunc_SetModel, isotopeEnt, isotopeModel);
 
 message_begin(MSG_BROADCAST,SVC_TEMPENTITY) //implosion effect
 write_byte(TE_IMPLOSION)
 write_coord(aimVector[0])
 write_coord(aimVector[1])
 write_coord(aimVector[2])
 write_byte(100) //radius
 write_byte(50)  //count
 write_byte(25)  //lifetime
 message_end()
 
 client_print(id, print_chat, "Test")
 
 return PLUGIN_HANDLED
}
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Prajch
Senior Member
Join Date: Dec 2007
Location: anger++
Old 01-07-2008 , 15:30   Re: Creating an entity with a model
Reply With Quote #3

Ah ha! IVecFVec is exactly what I needed. I thought entity_set_origin might cast the integers to float but I guess not.

Is fakemeta much faster than engine though?
Prajch is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 01-08-2008 , 00:23   Re: Creating an entity with a model
Reply With Quote #4

Yeap.
__________________
Still...lovin' . Connor noob! Hello
Alka 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 06:13.


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