AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   2 questions! (https://forums.alliedmods.net/showthread.php?t=20187)

atomic 11-03-2005 10:42

2 questions!
 
1.how do i get all players that is a specific radius!

2. how do i get the person that im looking at (in my crosshair)

im making a mod :P

v3x 11-03-2005 10:55

1) Something like this:
Code:
#define DISTANCE  999 // Edit this to w/e you want new g_iOrigins[33][3]; new g_iPlace[3] = { 2398, 281, 3 } // Edit this to the origin you want public MyFunc() {   new iPlayers[32]   new iNum, iDistance;   get_players(iPlayers, iNum, "a");   for(new i = 0; i <= iNum; i++)   {     new id = iPlayers[i];     if(!is_user_connected(id)) continue;     get_user_origin(id, g_iOrigins[id], 0);     iDistance = get_distance(g_iOrigins[id], g_iPlace);     if(iDistance <= DISTANCE)     {       client_print(id, 3, "Hooray, you're close!");     }     else     {       client_print(id, 3, "Ah crap, you're not close!");     }   } }
2) I think get_user_aiming should work..

atomic 11-03-2005 11:12

:P

so if i want to ... for example... slap the user im looking at...how would i do that

LynX 11-03-2005 11:14

There is easier way v3x.

Code:
new origin[3], eOrigin[3]; new Float:vel[3]; get_user_origin( id, origin ); new players[32]; new num, player; get_players(players, num, "a");   for (new i = 0; i < num; i++) {     player = players[i];               if( player != id ) {                 //Check their range.         get_user_origin( player, eOrigin );                 if( get_distance( origin, eOrigin ) <= distance ) // distance = any number you specify         {               // do stuff here         }     } }

Also, get_user_aiming shall be enough for you second question.

v3x 11-03-2005 11:18

Code:
public MyFunc( id ) {   new index, tmp;   get_user_aiming(id, index, tmp);   if(!is_user_connected(index) || !is_user_alive(index))   {     client_print(id, 4, "You're not aiming at someone");   }   else   {     new szUserName[33];     get_user_name(index, szUserName, 32);     client_print(id, 4, "Slapped %s", szUserName);     user_slap(index, 0);   } }
Should work

Edit: LynX, he's not talking about getting the distances between 2 players. At least I don't think he is..

LynX 11-03-2005 11:26

Don't ask me, I just posted mine pushaway code ( removed the pushaway from it )

XxAvalanchexX 11-03-2005 14:14

1.
Code:
while((ent = find_ent_in_sphere(ent,origin,radius)) != 0) {     if(!is_user_connected(ent)) continue;  }

2.
Code:
new ent, body;  get_user_aiming(id,ent,body);

Shorter alternatives for the win. Seriously, we have find_ent_in_sphere for a reason, use it.

atomic 11-03-2005 15:02

Code:
new ent, body;  get_user_aiming(id,ent,body);

so if i want to do something with that person im aiming at, what is the person called... id??



Code:
new ent, body; get_user_aiming(id,ent,body); } client_print (id, "im watching you") }
just an example..the } { is total wrong

v3x 11-03-2005 15:23

It'd be "ent".

atomic 11-03-2005 15:47

:)


All times are GMT -4. The time now is 23:40.

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