AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Creating an entity with a model (https://forums.alliedmods.net/showthread.php?t=65392)

Prajch 01-07-2008 15:06

Creating an entity with a model
 
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 }

Alka 01-07-2008 15:14

Re: Creating an entity with a model
 
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
}


Prajch 01-07-2008 15:30

Re: Creating an entity with a model
 
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?

Alka 01-08-2008 00:23

Re: Creating an entity with a model
 
Yeap. :D


All times are GMT -4. The time now is 11:12.

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