Raised This Month: $ Target: $400
 0% 

Random problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Drak
Veteran Member
Join Date: Jul 2005
Old 07-15-2007 , 06:56   Re: Random problem
Reply With Quote #2

Code:
new playerNum[33]; // Global public giveNum(id) {     if(id>=1)     {         new number = random_num(1,32)         if(checkNum(number))         {             playerNum[id] = number;         } else {             giveNum(id)         }         return PLUGIN_HANDLED     }         new i,players[32],num     get_players(players,num)     for(i;i<num;i++)     {         new randomNum = random_num(1,32)         if(checkNum(randomNum))         {             playerNum[i] = randomNum;         } else {             giveNum(i) // Someone has the number, call the function again. Only for this player         }             } } public checkNum(number) {     for(new i;i<sizeof(playerNum);i++) {         if(number == playerNum[i]) {             return 0;         } else {             return 1;         }     } }
I think i'm making this way over complicated, but... This might, but probably wont, work.

Just call the function with id being zero.
__________________
Oh yeah

Last edited by Drak; 07-15-2007 at 07:11.
Drak is offline
Send a message via MSN to Drak
 



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