AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Finding and manupulating objects XYZ? (https://forums.alliedmods.net/showthread.php?t=82489)

frozenarmageddon 12-24-2008 09:41

Finding and manupulating objects XYZ?
 
Erm, how do I do that? I wanted to make like a build mode, so I kinda need that for precise building, and I hope you forgive me for not checking all the 501 pages for a semiliar post ^_^

CodeMaster 12-24-2008 13:03

Re: Finding and manupulating objects XYZ?
 
You might want to check funcwiki.
As far as I know you can move only entities, so you could check something about entities.

So the gag is all about origins.Origin is representation of X,Y and Z as an array.
Code:

new Float:origin[3] - Vector of position
origin[0] - X
origin[1] - Y
origin[2] - Z

How do you get origins?
I'd suggest using Fakemeta module.
It's one of the most flexible tools of amxmodx.
Origin's are stored in entity edict data, and with Fakemeta you get it using pev() function, and then set it with set_pev().
Code:

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

// Later part of code
new Float:origin[3]
pev(entity_id, pev_origin,origin)
origin[2] += 2.0
set_pev(entity_id,pev_origin,origin)

That should increase Z coordinate by two units, so object would be positioned higher.

If you need anything, just post I'll try to help. Right now I don't have time to finish this, but I'll do later

Cheers ;)

Nidza

ConnorMcLeod 12-24-2008 13:22

Re: Finding and manupulating objects XYZ?
 
To set an entity origin, use EngFunc_SetOrigin.

See from fakemeta_util.inc :

Code:
stock fm_entity_set_origin(index, const Float:origin[3]) {     new Float:mins[3], Float:maxs[3];     pev(index, pev_mins, mins);     pev(index, pev_maxs, maxs);     engfunc(EngFunc_SetSize, index, mins, maxs);     return engfunc(EngFunc_SetOrigin, index, origin); }

Also, don't use this stock if you are already setting entity size.

CodeMaster 12-24-2008 15:53

Re: Finding and manupulating objects XYZ?
 
Ok, I just gave the practical idea how to do it.
I'm not actually sure would it work, so Connor, is my idea right?

Nidza

frozenarmageddon 12-24-2008 16:41

Re: Finding and manupulating objects XYZ?
 
ConnorMcLeod, could really help if you explain XD

Thanks CodeMaster, You help ALOT, because the Oregin manupulating is basicly the main part of my addon, I wont forget to Credit you with it :D

Btw, where to get the FakeMeta module? lol

I got a bad feeling that it comes with the plugin [can't check it right now, because I use amxx only for Sven coop, and I just deleted it to update from 3.0 to 4.0b, and gotta reinstall amxx now ^_^]

If im allready at it... I wanted to know how to add karma to someone, because I will +karma you (CodeMaster) as soon as I find out if it works XD

danielkza 12-24-2008 17:33

Re: Finding and manupulating objects XYZ?
 
Quote:

Originally Posted by frozenarmageddon (Post 732674)
ConnorMcLeod, could really help if you explain XD

Thanks CodeMaster, You help ALOT, because the Oregin manupulating is basicly the main part of my addon, I wont forget to Credit you with it :D

Btw, where to get the FakeMeta module? lol

I got a bad feeling that it comes with the plugin [can't check it right now, because I use amxx only for Sven coop, and I just deleted it to update from 3.0 to 4.0b, and gotta reinstall amxx now ^_^]

If im allready at it... I wanted to know how to add karma to someone, because I will +karma you (CodeMaster) as soon as I find out if it works XD

Fakemeta comes with the default AMXX installation. And to +/-karma a post, click the [+-] sign right below the user's avatar.

frozenarmageddon 12-24-2008 20:28

Re: Finding and manupulating objects XYZ?
 
thx :D
____________
Quote:

Originally Posted by CodeMaster (Post 732575)
[code]#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

// Later part of code
new Float:origin[3]
pev(entity_id, pev_origin,origin)
origin[2] += 2.0
set_pev(entity_id,pev_origin,origin)
[/code]

ok, im both a newbie and trying to understand, so lets break it down, shall we?

[includes]

new Float:origin[3]
Declares that origin is a "Group" of 3 "members" that all are Floats?

pev(entity_id, pev_origin,origin)
Sets origin as enitity_id's pev_origin [that is, its origin]?

[addition]

set_pev(entity_id,pev_origin,origin)
Updates the entity_id's pev_origin with the values of origin?

as for example, and quick step by step explanation [of what I understand] will be:

Code:

//includes
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
 
// Later part of code
new Float:position[3]  //declaration
pev(1253, pev_origin,position) //"fills" position with 1253's origin
position[2] += 10.0 //adds 10 to position's third "member" [shouldnt I add f after a float number? i.e. 10.0f]
set_pev(1253,pev_origin,position) //updates ent. 1253's pev_origin with "position"

Edit: Yea, im bored, thats why I colored.
Edit2: I found out something random... my naighbor snorts so loud I can hear him ._.

frozenarmageddon 12-24-2008 21:14

Re: Finding and manupulating objects XYZ?
 
Ok, started anuther message because the one before really was abit too huge ._.

If im allready into all this stuff, [still on topic] is there any way to retourn the ID of an entity im looking at?

CodeMaster 12-25-2008 06:51

Re: Finding and manupulating objects XYZ?
 
pev(entity_id, pev_origin,origin)
Gets enitity_id's pev_origin.

And yes, there is way to get entity you're looking at.
I assume you mean the one you're aiming at.

PHP Code:

new aimed_entity
new body_part
get_user_aiming
(player_id,aimed_entity,body_part

aimed_entity is what you need. It points to player or entity you're aiming at, and if you're not aiming to anything, it'll return 0.0

If you're looking for a coordinate, you can use a function from fakemeta_util.inc

PHP Code:

new Float:aim_origin[3]
fm_get_aim_origin(id,end_origin 

That'd get player's aim origin coordinate, so if it'd hit a wall it'd return the origin of the point where it hit the wall.

frozenarmageddon 12-25-2008 08:53

Re: Finding and manupulating objects XYZ?
 
Quote:

Originally Posted by CodeMaster (Post 732906)
pev(entity_id, pev_origin,origin)
Gets entity_id's pev_origin.

Yea, but it stores what it Gets to "origin" right?

also, I didn't understand how to use:
Code:


new aimed_entity
new body_part
get_user_aiming(player_id,aimed_entity,body_part)

it just gets the values from get_user_aiming and puts them into vars? [not so sure about the name, didn't code at any language for a while :\]
like player's ID into player_id but will write in 0.0 if its null?
same with aimed_entity will return ent_id but 0.0 if its not an entity?
if thats correct, so I didn't know that gold-source had different ids for different body-parts or something, any way I can find info about it?

oh, and it seems like I'm gonna ask you about how to code the whole plug-in step by step, so don't worry... I am trying to learn the most from any piece of information I get :D

Otherwise, you are a REALLY helpful guy :D
I guess there's no chance we can somehow talk over an IM software, right?
[me no want to spam forums with questions =^.^=][But I will if its OK XD]


All times are GMT -4. The time now is 09:15.

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