AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity and radius (https://forums.alliedmods.net/showthread.php?t=242119)

Kiske 06-14-2014 08:43

Entity and radius
 
Hi,
I have a problem with an entity and his radius.


PHP Code:

set_task(0.1"entityThink"entity__"a"100);

public 
entityThink(const entity) {
static 
Float:vecEntityOrigin[3];
static 
Float:vecIdOrigin[3];
static 
iEnt;

entity_get_vector(iEntEV_VEC_originvecEntityOrigin);
iEnt = -1;

while((
iEnt find_ent_in_sphere(iEntvecEntityOrigin330.0)) != 0) {
if(!
is_user_alive(iEnt)) {
continue;
}

entity_get_vector(iEntEV_VEC_originvecIdOrigin);

if(
get_distance_f(vecIdOriginvecEntityOrigin) > 300.0) {
set_user_godmode(iEnt0);
continue;
}

set_user_godmode(iEnt1);
}


The result of that code it's this (example, view of top):
http://i.imgur.com/zTQnK9a.jpg





Buuuut, what happens when there are two entities like this close enough, something like that (example, view of top):
http://i.imgur.com/PkhYmuy.jpg


The 'User with problem' has godmode for the 'Entity 1' and hasn't godmode for the 'Entity 2'.

How to fix that ?

Black Rose 06-14-2014 09:03

Re: Entity and radius
 
I don't really see the problem.

The user gets godmode, isn't that the point?

This is completely useless:
Code:
    while((iEnt = find_ent_in_sphere(iEnt, vecEntityOrigin, 330.0)) != 0) {         // ...         entity_get_vector(iEnt, EV_VEC_origin, vecIdOrigin);         if(get_distance_f(vecIdOrigin, vecEntityOrigin) > 300.0) {

Kiske 06-14-2014 09:25

Re: Entity and radius
 
Quote:

Originally Posted by Black Rose (Post 2151534)
I don't really see the problem.

The user gets godmode, isn't that the point?

This is completely useless:
Code:
while((iEnt = find_ent_in_sphere(iEnt, vecEntityOrigin, 330.0)) != 0) { // ...  entity_get_vector(iEnt, EV_VEC_origin, vecIdOrigin);  if(get_distance_f(vecIdOrigin, vecEntityOrigin) > 300.0) {

If I remove that, the user always will have godmode, even if not in range.

Nextra 06-14-2014 09:38

Re: Entity and radius
 
Please don't blank out your posts and show us what you did wrong.

Kiske 06-14-2014 09:58

Re: Entity and radius
 
Quote:

Originally Posted by Nextra (Post 2151563)
Please don't blank out your posts and show us what you did wrong.

It works, nothing more.
"Solved" (?

HamletEagle 06-14-2014 10:43

Re: Entity and radius
 
It work's, then let it here so others can learn from it and find a solution.

Kiske 06-14-2014 10:47

Re: Entity and radius
 
Quote:

Originally Posted by HamletEagle (Post 2151594)
It work's, then let it here so others can learn from it and find a solution.

What solution ?
There was never an error, it was a misunderstanding.

HamletEagle 06-14-2014 11:21

Re: Entity and radius
 
Doesn't metter, don't blank your post.

Kiske 06-14-2014 11:29

Re: Entity and radius
 
Ok.


All times are GMT -4. The time now is 21:13.

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