Raised This Month: $51 Target: $400
 12% 

Solved Problem with entity properties !


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thEsp
BANNED
Join Date: Aug 2017
Old 02-17-2019 , 15:01   Problem with entity properties !
Reply With Quote #1

Hi,
I am facing a problem in some lines of code, I want to spawn model (entity) "w_ak47.mdl" (Just for testing purposes) and set it's origin to where I aim. But It does not work. Let's get to the point... this is the code :
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

#define PLUGIN "-"
#define VERSION "1.0"
#define AUTHOR "-"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /ent","CreateEnt")
}
public 
plugin_precache()
{
    
precache_model("models/w_ak47.mdl")
}
public 
CreateEnt(id)
{
    
    new 
float:aimorigin[3]
    
pev(id,pev_v_angle,aimorigin
    new 
ent create_entity("info_target")
    
entity_set_model(ent,"models/w_ak47.mdl")
    
entity_set_origin(ent,aimorigin)
    
entity_set_size(ent,Float:{-16.0,-16.0,-16.0},Float:{16.0,16.0,16.0})
    
entity_set_int(ent,EV_INT_solid,SOLID_BBOX)
    
entity_set_float(ent,EV_FL_takedamage,DAMAGE_AIM
    
entity_set_float(ent,EV_FL_health,100.0)

Thanks in advance !

Last edited by thEsp; 02-18-2019 at 05:51.
thEsp is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 02-17-2019 , 22:45   Re: Problem with entity properties !
Reply With Quote #2

pev(id,pev_v_angle,aimorigin) does not return the aim origin.

Quote:
Originally Posted by thEsp View Post
Just search a bit more ...
PartialCloning is offline
thEsp
BANNED
Join Date: Aug 2017
Old 02-18-2019 , 03:35   Re: Problem with entity properties !
Reply With Quote #3

Quote:
Originally Posted by PartialCloning View Post
pev(id,pev_v_angle,aimorigin) does not return the aim origin.
How should I do that ? I took it from here and tested it with client_print, it shows some numbers but not sure if correct.
thEsp is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-18-2019 , 03:42   Re: Problem with entity properties !
Reply With Quote #4

get_user_origin(index,iOrigin,3)
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
thEsp
BANNED
Join Date: Aug 2017
Old 02-18-2019 , 04:17   Re: Problem with entity properties !
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
get_user_origin(index,iOrigin,3)
Thanks for the reply but it does not return a value. All are 0.00000 .
Edit: I used %f instead of %i. Now values are correct I think, but the problem is something else it seems.

Last edited by thEsp; 02-18-2019 at 04:44.
thEsp is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-18-2019 , 05:07   Re: Problem with entity properties !
Reply With Quote #6

It doesn't return float values. U should know that.


Add this after get_user_origin..
new Float:aimorigin[3]
aimorigin[0] = float(iOrigin[0])
aimorigin[1] = float(iOrigin[1])
aimorigin[2] = float(iOrigin[2])
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-18-2019 at 05:07.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
PartialCloning
Senior Member
Join Date: Dec 2015
Old 02-18-2019 , 05:09   Re: Problem with entity properties !
Reply With Quote #7

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

#define PLUGIN "-"
#define VERSION "1.0"
#define AUTHOR "-"

#define MODEL_ENTITY "models/w_ak47.mdl"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /ent","CreateEnt")
}

public 
plugin_precache()
{
    
precache_model(MODEL_ENTITY)
}

public 
CreateEnt(id)
{
    new 
iAimOrigin[3], Float:flAimOrigin[3];
    
get_user_origin(idiAimOrigin3);
    
IVecFVec(iAimOriginflAimOrigin);

    new 
Entity create_entity("info_target");
    
entity_set_int(EntityEV_INT_solid,SOLID_BBOX);
    
entity_set_float(EntityEV_FL_takedamage,DAMAGE_AIM); 
    
entity_set_float(EntityEV_FL_health,100.0);
    
entity_set_model(EntityMODEL_ENTITY);
    
entity_set_origin(EntityflAimOrigin);
    
entity_set_size(EntityFloat:{-16.0,-16.0,-16.0}, Float:{16.0,16.0,16.0});

PartialCloning is offline
thEsp
BANNED
Join Date: Aug 2017
Old 02-18-2019 , 05:51   Re: Problem with entity properties !
Reply With Quote #8

Quote:
Originally Posted by PartialCloning View Post
PHP Code:
#include <amxmodx>
#include <engine>

#define PLUGIN "-"
#define VERSION "1.0"
#define AUTHOR "-"

#define MODEL_ENTITY "models/w_ak47.mdl"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /ent","CreateEnt")
}

public 
plugin_precache()
{
    
precache_model(MODEL_ENTITY)
}

public 
CreateEnt(id)
{
    new 
iAimOrigin[3], Float:flAimOrigin[3];
    
get_user_origin(idiAimOrigin3);
    
IVecFVec(iAimOriginflAimOrigin);

    new 
Entity create_entity("info_target");
    
entity_set_int(EntityEV_INT_solid,SOLID_BBOX);
    
entity_set_float(EntityEV_FL_takedamage,DAMAGE_AIM); 
    
entity_set_float(EntityEV_FL_health,100.0);
    
entity_set_model(EntityMODEL_ENTITY);
    
entity_set_origin(EntityflAimOrigin);
    
entity_set_size(EntityFloat:{-16.0,-16.0,-16.0}, Float:{16.0,16.0,16.0});

Thank you very much ! This works and helps well !
thEsp is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-18-2019 , 06:47   Re: Problem with entity properties !
Reply With Quote #9

Again this forum is not for do for me you need at least knowledge about coding.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 14:12.


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