Raised This Month: $ Target: $400
 0% 

Give player a radius?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-06-2006 , 15:42   Give player a radius?
Reply With Quote #1

Hi, how would I give a player a radius?

For example: I have 2 players, one player has a radius. When the other player steps into the first players radius it will say "You are in the radius".

I think I find the origin of both players then calculate the distance or something?

Please someone help me !

Last edited by hlstriker; 12-07-2006 at 10:23. Reason: Resolved kindof
hlstriker is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 15:48   Re: Give player a radius?
Reply With Quote #2

theres a couple differant ways to do it
Code:
  get_distance(playerA,playerB);
that will return the distnce in units between the two players. firt youll need to get there origin . using either
Code:
pev(playerA,origin) or use engines   entity_get_vector(players[i],EV_VEC_origin,pOrigin)
If you need a good exmple you can look at my "Follow The Bomb" plugin which measures between terrorists and the bomb
The Specialist is offline
Send a message via AIM to The Specialist
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-06-2006 , 15:56   Re: Give player a radius?
Reply With Quote #3

try my function:

Code:
public userinradius(a,id){
new distanceBetween
new origin1[3], origin[3]
new dmgRadius = 100
get_user_origin(id, origin)
if ( is_user_alive(a) && a != id) {
get_user_origin(a, origin1)
distanceBetween = get_distance(origin, origin1)
if ( distanceBetween < dmgRadius ) {
return 1
}
}
return 0
}
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.

Last edited by dutchmeat; 12-06-2006 at 16:14.
dutchmeat is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 16:07   Re: Give player a radius?
Reply With Quote #4

why return 0 ? return and return 0 are ==
The Specialist is offline
Send a message via AIM to The Specialist
dutchmeat
Senior Member
Join Date: Sep 2006
Old 12-06-2006 , 16:14   Re: Give player a radius?
Reply With Quote #5

The correct way of using this function is:
a should be in a loop of all players like this:


Code:
for(new a = 1; a <= get_playersnum(); a++) {  if(userinradius(a,id)){   console_print(a,"YOU ARE IN THE RADIUS OF GOD!")  } }

You should remove the console_print out of the inradius function.
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 16:35   Re: Give player a radius?
Reply With Quote #6

well if your going to do that then you might as well use
Code:
find_sphere_class(id,"player",entlist , maxents,radius)

finding all indexs of the players in the rduius
The Specialist is offline
Send a message via AIM to The Specialist
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-06-2006 , 19:05   Re: Give player a radius?
Reply With Quote #7

Hi, here is the code i'm using and it is hooked to a set_task. It doesn't do what its supposed to though. Can anyone fix it for me?

Code:
public checkPass(id) {          for(new player1 = 1; player1 <= get_playersnum(); player1++) {         for(new player2 = 1; player2 <= get_playersnum(); player2++) {             if( (is_user_alive(player1) && is_user_alive(player2)) && (is_user_connected(player1) && is_user_connected(player2)) ) {                 if(!(player1 == player2)) {                     new distance;                     new origin1[3], origin2[3];                     new radius = 100;                                         get_user_origin(player1, origin1);                     get_user_origin(player2, origin2);                     distance = get_distance(origin1, origin2);                     if(distance < radius) {                         entity_set_int(player1, EV_INT_solid, SOLID_NOT);                         entity_set_int(player2, EV_INT_solid, SOLID_NOT);                     } else {                         entity_set_int(player1, EV_INT_solid, SOLID_BBOX);                         entity_set_int(player2, EV_INT_solid, SOLID_BBOX);                     }                 }             }         }     }     return PLUGIN_CONTINUE; }
hlstriker is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 19:52   Re: Give player a radius?
Reply With Quote #8

im not exactly sure what it is your tryign to do . please explaine why your setting solid and not solid ? heres a function from my follwo the bomb plugin .

Code:
public find_bomb(id) {  new g_iBomb = find_ent_by_class(-1,"weapon_c4");  if(get_pcvar_num(g_iFollow_Bomb)==0 || g_iBomb == 0)  {   return PLUGIN_HANDLED;  }else{   entity_get_vector(g_iBomb,EV_VEC_origin,c4origin);   new players[32];   new num;   get_players(players,num,"ace","TERRORIST");     for(new i=0;i<num;i++)   {    entity_get_vector(players[i],EV_VEC_origin,pOrigin);    new Float:  g_Dist = get_distance_f(c4origin,pOrigin);    new g_iDist = floatround(g_Dist);        set_hudmessage(255, 255, 255, -1.0, 0.79, 0, 6.0, 2.0);    show_hudmessage(players[i], "%L",players,"METER",g_iDist);        if( g_Dist > get_pcvar_num(g_iRadius))    {     punish_mode(players[i]);        }else if(g_Dist >  get_pcvar_num(g_iRadius) / 2)    {      set_hudmessage(255, 0, 0, -1.0, 0.31, 0, 6.0, 12.0);      show_hudmessage(players[i], "%L",players,"WARNING");    }   }  }  return PLUGIN_HANDLED; }

Last edited by The Specialist; 12-06-2006 at 19:56.
The Specialist is offline
Send a message via AIM to The Specialist
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 12-06-2006 , 20:00   Re: Give player a radius?
Reply With Quote #9

I'm trying to set it so when players are in so much distance of each other they will become not solid so they can walk through each other.
hlstriker is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 12-06-2006 , 20:05   Re: Give player a radius?
Reply With Quote #10

ah ok i see what your doing now . Well above is the function from my follow the bomb plugin which uses all of those types of functions . You should look at my plugin to see how it works . your function is a horable mess , with a for in a for .
The Specialist is offline
Send a message via AIM to The Specialist
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 06:59.


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