Raised This Month: $ Target: $400
 0% 

win percent


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-29-2018 , 08:27   win percent
Reply With Quote #1

Hello, I'm trying to announce a winner based in player's win chance percent. I already managed to calculate the chance percent but I'm getting some trouble to announce the winner.

The max money that player can gamble it's 50,000 and max win chance percent it's 50%. What I did then was generate a random number between 0 and win chance percent in 50,000 (50% = 25,000).I noticed that sometimes player with 1% of chance win against a player of 50% of chance, so my code it's not right.

Someone have idea?

Code:
// iMaxDeposit = 50,000 // rgJackpot[JP_PLAYER_CASH] = cash that player gambled something() {     ArraySort(g_aJackpot, "arrayJackpotSort");     for (new i = 0; i < iMax; i++)     {         ArrayGetArray(g_aJackpot, i, rgJackpot);         if (iWinner == -1)         {             iWinPercent = floatround(float(rgJackpot[JP_PLAYER_CASH]) / float(iMaxDeposit) * 50.0);             iRandomNum = floatround((float(iWinPercent) * float(iMaxDeposit)) / 100.0);             if (iRandomNum <= random_num(1, iMaxDeposit))                 iWinner = i;         }         iReward += rgJackpot[JP_PLAYER_CASH];     } } public arrayJackpotSort(Array:aWhich, iItem1, iItem2) {     new rgJackpot[2][eJackpot];     ArrayGetArray(aWhich, iItem1, rgJackpot[0]);     ArrayGetArray(aWhich, iItem2, rgJackpot[1]);     if (rgJackpot[0][JP_PLAYER_CASH] > rgJackpot[1][JP_PLAYER_CASH])         return 1;     return -1; }
__________________








CrazY. 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 07:31.


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