Raised This Month: $ Target: $400
 0% 

Random problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 07-15-2007 , 12:48   Re: Random problem
Reply With Quote #1

I would make it this way:

PHP Code:
#include <amxmodx>
new g_player_num[33]
new 
g_max_players

public plugin_init(){
    
register_plugin"test""1.0""Sylwester" )
    
g_max_players get_maxplayers()
    
set_numbers()
    
mix_numbers()
}

public 
set_numbers(){   //set default numbers {1,...,32}
    
for(new i=1i<=32i++)
        
g_player_num[i] = i
}

public 
mix_numbers(){   //exchange every number with randomly chosen
    
new temp_exchange
    
new temp_random

    
for(new i=1i<=g_max_playersi++){
        
temp_random random_num(1g_max_players)  //use this if you want to give them numbers {1,...,g_max_players}
        //temp_random = random_num(1, 32)    //use this if you want to give them numbers {1,...,32}

        //exchange numbers
        
temp_exchange g_player_num[i]
        
g_player_num[i] = g_player_num[temp_random]
        
g_player_num[temp_random] = temp_exchange
    
}

__________________
Impossible is Nothing

Last edited by Sylwester; 07-15-2007 at 12:52.
Sylwester 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 21:24.


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