Raised This Month: $ Target: $400
 0% 

win percent


Post New Thread Reply   
 
Thread Tools Display Modes
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
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-29-2018 , 08:44   Re: win percent
Reply With Quote #2

I can't even wrap my head around what your code is actually trying to do, your algorithm just seems very wrong.
Describe the rules of your game precisely.
__________________
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-29-2018 , 09:05   Re: win percent
Reply With Quote #3

I already made an effective jackpot plugin take alook it might be helpful.
https://forums.alliedmods.net/showpo...2&postcount=17

As klippy said you have something wrong with your calculations, win chance it depends on the player money in jackpot divide by total amount of money in the jackpot multiplied by 100 so it would be an integer also it cant be 50 percent unless all players have the same amount of money in the jackpot.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-29-2018 at 12:53.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 07:31.


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