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

Do something when two players are near each other at a certain distance?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 10-16-2008 , 21:49   Do something when two players are near each other at a certain distance?
Reply With Quote #1

Hey, I'm trying to figure out how to do something (Ex. Play a sound) when two players are within a certain distance. Say user1 is within 120 of user2 a sound will play until they spread further than 120. Possible?
fang is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-16-2008 , 21:53   Re: Do something when two players are near each other at a certain distance?
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> new g_max_clients; public plugin_init() {     register_forward(FM_StartFrame, "FwdStartFrame");         g_max_clients = get_maxplayers(); } public FwdStartFrame() {     static client1, client2;     static Float:origin1[3], Float:origin2[3];         for( client1 = 1; client1 <= g_max_clients; client1++ )     {         if( !is_user_alive(client1) ) continue;                 pev(client1, pev_origin, origin1);                 for( client2 = client1 + 1; client2 <= g_max_clients; client2++ )         {             if( !is_user_alive(client2) ) continue;                         pev(client2, pev_origin, origin2);                         if( get_distance_f(origin1, origin2) <= YOUR_DISTANCE )             {                 // do something             }         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 10-16-2008 , 22:16   Re: Do something when two players are near each other at a certain distance?
Reply With Quote #3

... You sir are a genius

+Karma
fang 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 22:03.


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