AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [resolved] create_entity() How to make an entity at user's aim. (https://forums.alliedmods.net/showthread.php?t=49554)

stupok 01-06-2007 21:17

[resolved] create_entity() How to make an entity at user's aim.
 
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 }

Zenith77 01-06-2007 21:36

Re: create_entity() How to make an entity at user's aim.
 
Try using DispatchSpawn().

stupok 01-06-2007 21:44

Re: create_entity() How to make an entity at user's aim.
 
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 01-06-2007 22:54

Re: create_entity() How to make an entity at user's aim.
 
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 }

XxAvalanchexX 01-06-2007 23:56

Re: [resolved] create_entity() How to make an entity at user's aim.
 
The engine_stocks.inc has the handy IVecFVec and FVecIVec functions.

VEN 01-07-2007 13:13

Re: [resolved] create_entity() How to make an entity at user's aim.
 
No it doesn't. I was moved to the vector.inc (engine not required).


All times are GMT -4. The time now is 22:24.

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