AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   random[ ( num ) ] (https://forums.alliedmods.net/showthread.php?t=113992)

zombieplague 01-01-2010 03:14

random[ ( num ) ]
 
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 ) ] 


xPaw 01-01-2010 05:24

Re: random[ ( num ) ]
 
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 ] ) { } }

Merc3y 01-01-2010 06:11

Re: random[ ( num ) ]
 
Quote:

Originally Posted by zombieplague (Post 1038691)
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

zombieplague 01-01-2010 06:14

Re: random[ ( num ) ]
 
Quote:

Originally Posted by Merc3y (Post 1038752)
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 )



Mxnn 01-01-2010 19:31

Re: random[ ( num ) ]
 
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); 


zombieplague 01-02-2010 08:52

Re: random[ ( num ) ]
 
Quote:

Originally Posted by Mxnn (Post 1039511)
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 ?

issen1 01-02-2010 09:14

Re: random[ ( num ) ]
 
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.

Bugsy 01-02-2010 11:03

Re: random[ ( num ) ]
 
http://forums.alliedmods.net/showthread.php?t=74666

zombieplague 01-02-2010 13:55

Re: random[ ( num ) ]
 
Quote:

Originally Posted by Bugsy (Post 1040087)

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 )



Exolent[jNr] 01-02-2010 14:10

Re: random[ ( num ) ]
 
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 )




All times are GMT -4. The time now is 04:11.

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