Raised This Month: $ Target: $400
 0% 

Random player on a team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 10-01-2006 , 02:30   Random player on a team
Reply With Quote #1

I was just wondering if this is the right way to do it and/or a what is a more efficient way to do this.

Code:
get_players(Players, iNum, "ae", "TERRORIST")
while(!is_user_alive(g_var[terrorist]))
{
                               // from 0?
  g_var[terrorist] = random_num(Players[1], Players[iNum])
}
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-01-2006 , 02:32   Re: Random player on a team
Reply With Quote #2

Code:
get_players(Players, iNum, "ae", "TERRORIST") g_var[terrorist] = Players[random_num(0,iNum-1)];
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 10-01-2006 , 02:44   Re: Random player on a team
Reply With Quote #3

lol. Works great! Thanks.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 10-02-2006 , 00:43   Re: Random player on a team
Reply With Quote #4

This is sorta in the same topic. So what about this one?

PHP Code:
        new Float:tempOrigin[3]
        
tempOrigin[2] = fOrigin[2] + 20.0
        
while(PointContents(tempOrigin) != CONTENTS_EMPTY)
        {
            switch(
random_num(03))
            {
                case 
0tempOrigin[0] = fOrigin[0] - random_float(35.050.0), tempOrigin[1] = fOrigin[1] - random_float(35.050.0)
                case 
1tempOrigin[0] = fOrigin[0] - random_float(35.050.0), tempOrigin[1] = fOrigin[1] + random_float(35.050.0)
                case 
2tempOrigin[0] = fOrigin[0] + random_float(35.050.0), tempOrigin[1] = fOrigin[1] - random_float(35.050.0)
                case 
3tempOrigin[0] = fOrigin[0] + random_float(35.050.0), tempOrigin[1] = fOrigin[1] + random_float(35.050.0)
            }
            
            if(
PointContents(tempOrigin) == CONTENTS_EMPTY)
            {
                
// do stuff

                
break
            } 
trying to check 4 random origins untill one is CONTENTS_EMPTY.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-02-2006 , 18:24   Re: Random player on a team
Reply With Quote #5

i would rather do something like this
PHP Code:
        new Float:tempOrigin[3], Float:max 50.0bool:found false
        tempOrigin
[2] = fOrigin[2] + 20.0
        
while(PointContents(tempOrigin) != CONTENTS_EMPTY)
        {
            for(new 
i=0i<3i++)
            {
               switch(
i)
               {
                   case 
0:{
                      
tempOrigin[0] = fOrigin[0] - random_float(max-15max)
                      
tempOrigin[1] = fOrigin[1] - random_float(max-15max)
                   }
                   case 
1:{
                      
tempOrigin[0] = fOrigin[0] - random_float(max-15max)
                      
tempOrigin[1] = fOrigin[1] + random_float(max-15max)
                   }
                   case 
2:{
                      
tempOrigin[0] = fOrigin[0] + random_float(max-15max)
                      
tempOrigin[1] = fOrigin[1] - random_float(max-15max)
                   }
                   case 
3:{
                      
tempOrigin[0] = fOrigin[0] + random_float(max-15max)
                      
tempOrigin[1] = fOrigin[1] + random_float(max-15max)
                   }
               }
               if(
PointContents(tempOrigin) == CONTENTS_EMPTY)
               {
                   
found true
                   
break
               }
            }
            if(
found)
            {
                
// do stuff

                
break
            }
            else
                
max += 15
         


Last edited by Emp`; 10-02-2006 at 18:28.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-02-2006 , 19:39   Re: Random player on a team
Reply With Quote #6

This is a good scenrio for a recrusive function. My only fear of using this is that it might hang up the game, even if it's for like a quater of a second.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 10-02-2006 , 22:51   Re: Random player on a team
Reply With Quote #7

Thanks Emp
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
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 04:48.


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