AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Give player a radius? (https://forums.alliedmods.net/showthread.php?t=48172)

hlstriker 12-06-2006 15:42

Give player a radius?
 
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 :)!

The Specialist 12-06-2006 15:48

Re: Give player a radius?
 
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 :up:

dutchmeat 12-06-2006 15:56

Re: Give player a radius?
 
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
}


The Specialist 12-06-2006 16:07

Re: Give player a radius?
 
why return 0 ? return and return 0 are ==

dutchmeat 12-06-2006 16:14

Re: Give player a radius?
 
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.

The Specialist 12-06-2006 16:35

Re: Give player a radius?
 
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

hlstriker 12-06-2006 19:05

Re: Give player a radius?
 
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; }

The Specialist 12-06-2006 19:52

Re: Give player a radius?
 
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; }

hlstriker 12-06-2006 20:00

Re: Give player a radius?
 
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.

The Specialist 12-06-2006 20:05

Re: Give player a radius?
 
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 .


All times are GMT -4. The time now is 06:59.

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