Raised This Month: $ Target: $400
 0% 

Random problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 07-15-2007 , 17:14   Re: Random problem
Reply With Quote #5

You made some mistakes.
PHP Code:
#include <amxmodx>
 
#define PLUGIN "Random Num"
#define VERSION "1.0"
#define AUTHOR "sylwester"
 
new g_player_num[33]
new 
g_max_players
 
public plugin_init() {
 
 
register_plugin(PLUGINVERSIONAUTHOR);
 
register_event("HLTV""new_round""a""1=0""2=0");
 
 
g_max_players get_maxplayers();
 
set_numbers();    //you need to use set_numbers function only once
}
 
public 
new_round() {
 
// set_task(1.0,"set_numbers");  
 
set_task(1.5,"mix_numbers");
}
 
public 
set_numbers() {
// for(new i=1 ; i <= g_max_players ; i++)
//fill whole array with numbers, it's not mistake but may avoid some errors later
//in case you want to use temp_random = random_num(1, 32);
 
for(new i=<= 32 i++)
  
g_player_num[i] = i;
}
 
public 
mix_numbers() {
 
 new 
temp_exchange;
 new 
temp_random;
 
 for(new 
i=<= g_max_players i++)
 {
  
temp_random random_num(1g_max_players);
 
  
temp_exchange g_player_num[i];
  
g_player_num[i] = g_player_num[temp_random];
  
g_player_num[temp_random] = temp_exchange;

  
//temp_exchange is not your current number, it's your old number
  //client_print(i, print_chat, "You'r number : %i", temp_exchange);
  //displaying numbers to players here is wrong
  //(number for current player may change in next iterations)
 
}

 for(new 
i=<= g_max_players i++)
 {
  
client_print(iprint_chat"Your number : %i"g_player_num[i]);
 }


__________________
Impossible is Nothing

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


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