Raised This Month: $ Target: $400
 0% 

[resolved] create_entity() How to make an entity at user's aim.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 01-06-2007 , 21:17   [resolved] create_entity() How to make an entity at user's aim.
Reply With Quote #1

I have looked at other plugins, looked at the entity tutorial by Hawk552, but I don't understand why the code below does not work. As far as I know, this should create a player.mdl at the origin where the client's sight intersects with another ent or world.

The only output I get is the client_print(). I don't see any models.

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Model" #define VERSION "1.0" #define AUTHOR "stupok69" #define MODEL "models/player.mdl" #define CLASSNAME "info_target" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("create", "create_function", ADMIN_BAN) } public plugin_precache() {     precache_model(MODEL) } public create_function(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         new origin[3]         get_user_origin(id, origin, 3)         client_print(id, print_chat, "Origin: %5i : %5i : %5i", origin[0], origin[1], origin[2])         new ent = create_entity(CLASSNAME)     entity_set_origin(ent, float:origin)     entity_set_model(ent, MODEL)             return PLUGIN_HANDLED }

Last edited by stupok; 01-06-2007 at 22:55.
stupok is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 01-06-2007 , 21:36   Re: create_entity() How to make an entity at user's aim.
Reply With Quote #2

Try using DispatchSpawn().
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 01-06-2007 , 21:44   Re: create_entity() How to make an entity at user's aim.
Reply With Quote #3

Now I have the code below, but I still see no models.

Code:
public create_function(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         new origin[3]         get_user_origin(id, origin, 3)         client_print(id, print_chat, "Origin: %5i : %5i : %5i", origin[0], origin[1], origin[2])         new ent = create_entity(CLASSNAME)     entity_set_origin(ent, float:origin)     entity_set_model(ent, MODEL)         DispatchSpawn(ent)         return PLUGIN_HANDLED }
stupok is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 01-06-2007 , 22:54   Re: create_entity() How to make an entity at user's aim.
Reply With Quote #4

I learned that get_user_origin() returns the origin in integers, but an entity must be spawned at a float.. here is the working code.

Code:
public create_function(id, level, cid) {     if(!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED         new Float:float_origin[3]     new integer_origin[3]         get_user_origin(id, integer_origin, 3)         for(new i = 0; i < 3; i++)         float_origin[i] = float(integer_origin[i])     new ent = create_entity("info_target")     entity_set_string(ent,EV_SZ_classname,"stupok69_ent")     entity_set_model(ent,MODEL)     entity_set_origin(ent,float_origin)     return PLUGIN_HANDLED }
stupok is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-06-2007 , 23:56   Re: [resolved] create_entity() How to make an entity at user's aim.
Reply With Quote #5

The engine_stocks.inc has the handy IVecFVec and FVecIVec functions.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 01-07-2007 , 13:13   Re: [resolved] create_entity() How to make an entity at user's aim.
Reply With Quote #6

No it doesn't. I was moved to the vector.inc (engine not required).
VEN 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 22:24.


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