Raised This Month: $ Target: $400
 0% 

random[ ( num ) ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zombieplague
Veteran Member
Join Date: Apr 2009
Old 01-01-2010 , 03:14   random[ ( num ) ]
Reply With Quote #1

Does anyone know how to get 2 random player or more instead of 1 ?

PHP Code:
new players32 ], num
get_players
playersnum"a" )

 new 
night_stalker playersrandomnum ) ] 
zombieplague is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-01-2010 , 05:24   Re: random[ ( num ) ]
Reply With Quote #2

Code:
new iPlayers[ 32 ], iNum; get_players( iPlayers, iNum, "a" ); new iNightStalkers[ 2 ]; new iNightStalkers[ 0 ] = iPlayers[ random( iNum ) ]; if( iNum > 2 ) {     while( ( iNightStalkers[ 1 ] = iPlayers[ random( iNum ) ] ) == iNightStalkers[ 0 ] ) { } }
__________________
xPaw is offline
Merc3y
Member
Join Date: Dec 2009
Old 01-01-2010 , 06:11   Re: random[ ( num ) ]
Reply With Quote #3

Quote:
Originally Posted by zombieplague View Post
Does anyone know how to get 2 random player or more instead of 1 ?

PHP Code:
new players32 ], num
get_players
playersnum"a" )
 
 new 
night_stalker playersrandomnum ) ] 
night_stalker ?

Issi't it same as mine ?

By the way xPaw could you help me with this ? http://forums.alliedmods.net/showthread.php?t=113994
__________________
How I Wish That I Can Host Without Any Problem.

Last edited by Merc3y; 01-01-2010 at 06:36.
Merc3y is offline
zombieplague
Veteran Member
Join Date: Apr 2009
Old 01-01-2010 , 06:14   Re: random[ ( num ) ]
Reply With Quote #4

Quote:
Originally Posted by Merc3y View Post
night_stalker ?

Izzit same as mine ?

By the way xPaw could you help me with this ? http://forums.alliedmods.net/showthread.php?t=113994

Sorry because i also needed this too, i saw your post so i took some part of it.

To xPaw it doesn't work, all the players were the stalker rather than 2

PHP Code:
public Game_Startid )
{
        new 
players32 ], num
        get_players
playersnum"a" )

        new 
Night_Stalker]
        
Night_Stalker] = playersrandomnum ) ]
        if ( 
num )
        {
             while( ( 
Night_Stalker] = playersrandomnum ) ] ) == Night_Stalker] ) { }
             
StatsNight_Stalker] )
        }
}

public 
Statsid )
{    
        
fm_set_user_healthid150 )
        
fm_set_user_gravityid0.3 )


Last edited by zombieplague; 01-01-2010 at 06:32.
zombieplague is offline
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 01-01-2010 , 19:31   Re: random[ ( num ) ]
Reply With Quote #5

PHP Code:
new players32 ], num
get_players
playersnum"a" )
new 
night_stalker playersrandomnum ) ]
new 
night_stalker2
do
night_stalker2=players[random(num)]
while (
night_stalker2 == night_stalker); 
Mxnn is offline
zombieplague
Veteran Member
Join Date: Apr 2009
Old 01-02-2010 , 08:52   Re: random[ ( num ) ]
Reply With Quote #6

Quote:
Originally Posted by Mxnn View Post
PHP Code:
new players32 ], num
get_players
playersnum"a" )
new 
night_stalker playersrandomnum ) ]
new 
night_stalker2
do
night_stalker2=players[random(num)]
while (
night_stalker2 == night_stalker); 
If i want more than 2 stalker how will it be done ?
zombieplague is offline
issen1
Member
Join Date: Jan 2010
Old 01-02-2010 , 09:14   Re: random[ ( num ) ]
Reply With Quote #7

PHP Code:
#include <amxmodx>

plugin_init()
{
//                 v  night stalker count there
  
new night_stalker[4] = {0}; // is that allowed?
  
new players[32];
  new 
plCount;

  
get_players(playersplCount"a");
  
rndNightStalker(night_stalker4playersplCount);
}

public 
rndNightStalker(night_stalker[], sizeplayers[], plCount)
{
  for(new 
i=0sizei++)
    for(new 
j=0sizej++)
      if(
!= j)
        if(
night_stalker[i] == night_stalker[j])
        {
          
night_stalker[i] = players[random(plCount)];
          
rndNightStalker(night_stalkersizeplayersplCount);
        }


Something like this.
__________________
greets (:
issen1 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-02-2010 , 11:03   Re: random[ ( num ) ]
Reply With Quote #8

http://forums.alliedmods.net/showthread.php?t=74666
__________________
Bugsy is offline
zombieplague
Veteran Member
Join Date: Apr 2009
Old 01-02-2010 , 13:55   Re: random[ ( num ) ]
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
I try this but didn't work properly.

PHP Code:
public Game_Startid )
{
    new 
players32 ], pnum
    GetRandomPlayers
playerspnum"a" )
    
Night_Stalker playersrandompnum ) ]
}

GetRandomPlayersplayers32 ], &pnum, const flags[ ]="", const teamORname[ ]="" )
{
    new 
original32 ], total
    get_players
originaltotalflagsteamORname )
    
    
pnum // I thought this is getting 4 random player to be the stalker ?
    
    
new rand 
    
do
    {
        
rand random(total)
        
        
playerspnum++ ] = originalrand ]
        
        
originalrand ] = original[ --total ]
    }
    while( 
total )

zombieplague is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-02-2010 , 14:10   Re: random[ ( num ) ]
Reply With Quote #10

PHP Code:
public Game_Startid )
{
    new 
players32 ], pnum
    GetRandomPlayers
playerspnum"a" )
    
    new 
player
    
for( new 04i++ ) // get first 4 random players
    
{
        
player players]
        
// player is a night stalker
    
}
}

// do not edit this function.
GetRandomPlayersplayers32 ], &pnum, const flags[ ]="", const teamORname[ ]="" )
{
    new 
original32 ], total
    get_players
originaltotalflagsteamORname )
    
    
pnum 0
    
    
new rand 
    
do
    {
        
rand random(total)
        
        
playerspnum++ ] = originalrand ]
        
        
originalrand ] = original[ --total ]
    }
    while( 
total )

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Old 01-02-2010, 14:35
Merc3y
This message has been deleted by Merc3y.
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:11.


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