Raised This Month: $ Target: $400
 0% 

[deleted]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sneakpeek
Member
Join Date: Dec 2005
Location: Who cares really?
Old 02-04-2006 , 13:36   [deleted]
Reply With Quote #1

[deleted]

Last edited by Sneakpeek; 01-25-2014 at 02:52.
Sneakpeek is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-04-2006 , 13:45  
Reply With Quote #2

You can run find_ent_in_sphere in client_PreThink. For more details, look here:

http://wiki.tcwonline.org/index.php/..._ent_in_sphere
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Sneakpeek
Member
Join Date: Dec 2005
Location: Who cares really?
Old 02-04-2006 , 17:26  
Reply With Quote #3

So like this then right?
Yes, I know, I looked at your surf plugin.

Code:
public client_preThink(id) {     new Float : Radius = get_cvar_float("rogue_radius")     new Float : pOrigin[3], ent     entity_get_vector(id, EV_VEC_origin, pOrigin)     while((ent = find_ent_in_sphere(ent, pOrigin, Radius)) != 0)     {         if(!is_user_alive(ent) || ent == id)         {             return 0         }         else         {             //Do the stuff if a player was found             Function(id)               }     }     return 0 }
__________________
Yes, you did
Sneakpeek is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-04-2006 , 17:57  
Reply With Quote #4

This is how I do it:
Code:
// Method 1 - Compare distances between entities public myfunc(id) {   new players[32], num, i;   get_players(players, num, "a");   for(i = 0; i <= num; i++) {     if(floatround(entity_range(players[i], id)) <= 800) {       // there you go     }   } }
Code:
// Method 2 - Compare distances between origins public myfunc(id) {   new players[32], num, i;   get_players(players, num, "a");   new origin1[3];   get_user_origin(id, origin1, 0);   for(i = 0; i <= num; i++) {     new origin2[3];     get_user_origin(players[i], origin2, 0);     if(get_distance(origin1, origin2) <= 800) {       // there you go     }   } }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Sneakpeek
Member
Join Date: Dec 2005
Location: Who cares really?
Old 02-04-2006 , 18:17  
Reply With Quote #5

Ahh, thanks man.
But will this, method 2, include dead people too?
__________________
Yes, you did
Sneakpeek is offline
KoST
Senior Member
Join Date: Jul 2005
Old 02-04-2006 , 18:37  
Reply With Quote #6

no, because the third parameter of get_players is set to "a" which returns only alive players.
read this: http://www.amxmodx.org/funcwiki.php?go=func&id=174
__________________
KoST is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 02-04-2006 , 18:39  
Reply With Quote #7

Code:
stock distance_func(a,Float:dist) 
{
	if(!is_user_alive(a)) return PLUGIN_HANDLED;
        static max_clients = get_maxplayers()
	for(new b = 0; b < max_clients; b++)
	{
		if ( (entity_range(a,b) <= dist) || (dist == -1.0) ) && (a != b)  )
		{

		}
	}
	return PLUGIN_HANDLED;
}
<- Quicker
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Sneakpeek
Member
Join Date: Dec 2005
Location: Who cares really?
Old 02-05-2006 , 05:46  
Reply With Quote #8

And to make it skip teammates... like this?

Code:
public client_preThink(id) {     if(!is_user_alive(id))     {         return 0     }     new radius = get_cvar_num("rogue_radius")     new players[32], num, i;     get_players(players, num, "a");     new origin1[3];     get_user_origin(id, origin1, 0);     for(i = 0; i <= num; i++)     {         new origin2[3];         get_user_origin(players[i], origin2, 0);         if(get_distance(origin1, origin2) <= radius)         {             new team1 = cs_get_user_team(origin1)             new team2 = cs_get_user_team(origin2)             if(team1 == team2)             {                 return 0             }             //My stuff         }               }         return 0 }
__________________
Yes, you did
Sneakpeek is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-05-2006 , 05:53  
Reply With Quote #9

This is how I would do it:
Code:
new team[2]; team[0] = get_user_team(id); team[1] = get_user_team(players[i]); if(team[0] == team[1]) continue;
Also, use set_task instead of prethink ( less CPU usage ).
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Sneakpeek
Member
Join Date: Dec 2005
Location: Who cares really?
Old 02-05-2006 , 05:58  
Reply With Quote #10

Alright, thanks.
Just one last thing, I see you use "continue" instead of "return".
Should I do that instead in prethink?
__________________
Yes, you did
Sneakpeek 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 08:09.


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