AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player Radius Issues (https://forums.alliedmods.net/showthread.php?t=53905)

raa 04-13-2007 03:58

Player Radius Issues
 
So.... If you are within the radius of another player your screen is spammed with hud_messages "You are within.......blah blah...", of all the players you are close too. At the same time your screen is spammed with hud_messages "You are NOT within... blah blah...", of all the players you are NOT close too.

Code:
public function(id)     {     new players[32];     new num;         get_players(players, num, "a");     for(new i = 0; i < num; i++) {         if( (is_user_alive(players[i]) && is_user_alive(id)) && (is_user_connected(players[i]) && is_user_connected(id)) )             {             new distance;             new origin1[3], origin2[3];             new radius = 700;                         new tempname[33];             get_user_name(players[i], tempname, 32);                         get_user_origin(players[i], origin1);             get_user_origin(id, origin2);             distance = get_distance(origin1, origin2);                         if(distance < radius)                 {                 // WITHIN RADIUS OF PLAYER                 set_hudmessage(255, 212, 42, -1.0, -1.0, 0, 15.0, 30.0, 0.0, 0.99, 4);                 show_hudmessage(id, "You are INSIDE RANGE of %s", tempname);             }             else {                 // OUTSIDE RADIUS OF PLAYER                 set_hudmessage(255, 212, 42, -1.0, -1.0, 0, 15.0, 30.0, 0.0, 0.99, 4);                 show_hudmessage(id, "You are OUTSIDE RANGE of %s", tempname);             }                     }     }     set_task(1.0, "function", id);     return 0; }

I am trying to figure out how to make the "NOT WITHIN" hud_messages not override the "WITHIN" messages.. The player does'nt need to see he is not "WITHIN" another players radius if he is currently "WITHIN" a players radius.
Hud channels and/or coodernates is not what I'm looking to get help in here. I need someone to show me some code that would not permit the "NOT WITHIN" function from being ran IF there is currently a "WITHIN" function being ran on the player. (id)

I've been messing with it for a few now and just get caught in these stupid loops of dumbness... Heck even if there's another better way to do what I'm looking for..


thanks for your help..

regalis 04-13-2007 14:42

Re: Player Radius Issues
 
maybe try this one...but i think there are ways to optimize this function...

I have cuted "if( (is_user_alive(players[i]) && is_user_alive(id)) && (is_user_connected(players[i]) && is_user_connected(id)) )" this out because of this --> get_players(players, num, "a")
You already get alive("a") players....and to be alive you have to be connected ;)

Code:
public function(id)     {     new players[32];     new num;     new bool:inside     get_players(players, num, "a");     for(new i = 0; i < num; i++) {             new distance;             new origin1[3], origin2[3];             new radius = 700;                         new tempname[33];             get_user_name(players[i], tempname, 32);                         get_user_origin(players[i], origin1);             get_user_origin(id, origin2);             distance = get_distance(origin1, origin2);                         if(distance < radius)                 {                 // WITHIN RADIUS OF PLAYER                 inside = true;                      set_hudmessage(255, 212, 42, -1.0, -1.0, 0, 15.0, 30.0, 0.0, 0.99, 4);                 show_hudmessage(id, "You are INSIDE RANGE of %s", tempname);             }                     }         if(!inside) {                 for(new i = 0; i < num; i++) {             new distance;             new origin1[3], origin2[3];             new radius = 700;                         new tempname[33];             get_user_name(players[i], tempname, 32);                         get_user_origin(players[i], origin1);             get_user_origin(id, origin2);             distance = get_distance(origin1, origin2);                         if(distance > radius)                 {                 // OUTSIDE RADIUS OF PLAYER                 set_hudmessage(255, 212, 42, -1.0, -1.0, 0, 15.0, 30.0, 0.0, 0.99, 4);                 show_hudmessage(id, "You are OUTSIDE RANGE of %s", tempname);             }             }                }     set_task(1.0, "function", id);     return 0; }
greetz regalis

raa 04-13-2007 15:23

Re: Player Radius Issues
 
thank you. that did the trick


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

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