Raised This Month: $ Target: $400
 0% 

Player Radius Issues


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-13-2007 , 14:42   Re: Player Radius Issues
Reply With Quote #2

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
__________________
regalis is offline
 



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:37.


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