SA-MP Forums Archive
Question about roulette. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about roulette. (/showthread.php?tid=620515)



Question about roulette. - ThatFag - 30.10.2016

hello there.
im currently making an roulette system for players.
I have created numbers and made the command
now my question is , can a player know for example what the next number will fall ??

Code:
enum rouletteHands_Enum
{
	RNumber,
	RCard[12],
}
new RouletteHands[][rouletteHands_Enum] = {
	{0, "Green"},
	{32, "Red"},
	{15, "Black"},
	{19, "Red"},
	{4, "Black"},
	{21, "Red"},
	{2, "Black"},
	{25, "Red"},
	{17, "Black"},
	{34, "Red"},
	{6, "Black"},
	{27, "Red"},
	{13, "Black"},
	{36, "Red"},
	{11, "Black"},
	{30, "Red"},
	{8, "Black"},
	{23, "Red"},
	{10, "Black"},
	{5, "Red"},
	{24, "Black"},
	{16, "Red"},
	{33, "Black"},
	{1, "Red"},
	{20, "Black"},
	{14, "Red"},
	{31, "Black"},
	{9, "Red"},
	{22, "Black"},
	{18, "Red"},
	{29, "Black"},
	{7, "Red"},
	{28, "Black"},
	{12, "Red"},
	{35, "Black"},
	{3, "Red"},
	{26, "Black"}
};
Those are my codes and the timer when player calls after pressing the cmd
Code:
function:RouletteTimer(playerid)
{
	new rouletteID = minrand(0, sizeof(RouletteHands));
	new iFormat[128];
	if(!strcmp(RouletteHands[rouletteID][RCard], "Black"))
	{
		format(iFormat, sizeof(iFormat), "** The wheel lands on %d (%s) ** (( %s ))", RouletteHands[rouletteID][RNumber], RouletteHands[rouletteID][RCard], MaskedName(playerid));
		NearMessage(playerid, iFormat, 0x282828FF);
	}
	else if(!strcmp(RouletteHands[rouletteID][RCard], "Red"))
	{
		format(iFormat, sizeof(iFormat), "** The wheel lands on %d (%s) ** (( %s ))", RouletteHands[rouletteID][RNumber], RouletteHands[rouletteID][RCard], MaskedName(playerid));
		NearMessage(playerid, iFormat, 0xFF1A1AFF);
	}
	else
	{
		format(iFormat, sizeof(iFormat), "** The wheel lands on %d (%s) ** (( %s ))", RouletteHands[rouletteID][RNumber], RouletteHands[rouletteID][RCard], MaskedName(playerid));
		NearMessage(playerid, iFormat, COLOR_GREEN);
	}
}



Re: Question about roulette. - NeXoR - 30.10.2016

I have a suggestion for you, let me get on my PC and I'll post it


Re: Question about roulette. - NeXoR - 30.10.2016

There you go
PHP Code:
static const RedNums[] =
{
    
// All Red Numbers
};
static const 
BlueNums[] =
{
    
// Blue Numbers
};
static const 
GreenNums[] =
{
    
// Green Nums
};
function:
RouletteTimer(playerid)
{
    new 
rouletteID random(3), randomnum;
    new 
iFormat[128];
    switch(
rouletteID)
    {
        case 
0// red
        
{
            
randomnum random(sizeof(RedNums));
            
format(iFormatsizeof(iFormat), "** The wheel lands on %d (Red) ** (( %s ))"RedNums[randomnum], MaskedName(playerid));
            
NearMessage(playeridiFormat0x282828FF);
        }
        case 
1// blue
        
{
            
randomnum random(sizeof(BlueNums));
            
format(iFormatsizeof(iFormat), "** The wheel lands on %d (Blue) ** (( %s ))"BlueNums[randomnum], MaskedName(playerid));
            
NearMessage(playeridiFormat0x282828FF);
        }
        case 
2// green
        
{
            
randomnum random(sizeof(GreenNums));
            
format(iFormatsizeof(iFormat), "** The wheel lands on %d (Green) ** (( %s ))"GreenNums[randomnum], MaskedName(playerid));
            
NearMessage(playeridiFormat0x282828FF);
        }
    }
    return 
1;




Re: Question about roulette. - ThatFag - 30.10.2016

Well my question was , can a player know what number will fall not how to script xD

but for ur effor ill give u a rep cuz u deserv it ty.


Re: Question about roulette. - NeXoR - 30.10.2016

Quote:
Originally Posted by ThatFag
View Post
Well my question was , can a player know what number will fall not how to script xD

but for ur effor ill give u a rep cuz u deserv it ty.
I don't care about reputations but thanks, SAMP Community helped me so much so far so I want to give back
Well, basically, a player can guess the next number, but he has to do hell lot of work to do so.
Also - Since nobody who plays in your server knows your code, no chance they will do it.
P.S I still suggest on using my way, no one could ever guess the code since everything's random.


Re: Question about roulette. - Mauzen - 30.10.2016

The result is chosen directly before it is shown to the players, so its impossible that they know it earlier, even if they had access to all the server variables somehow.

@NeXoR
Nice attempt to get cleaner code, but yours actually messes up the probabilities of the game. Theres just one or two green numbers, 0 and 00 (depending on the play style). With your code, those two number would have a 33% chance to appear. I know, its all about maximizing then casinos profits, but this is too obvious and players will complain about it


Re: Question about roulette. - NeXoR - 31.10.2016

Quote:
Originally Posted by Mauzen
View Post
The result is chosen directly before it is shown to the players, so its impossible that they know it earlier, even if they had access to all the server variables somehow.

@NeXoR
Nice attempt to get cleaner code, but yours actually messes up the probabilities of the game. Theres just one or two green numbers, 0 and 00 (depending on the play style). With your code, those two number would have a 33% chance to appear. I know, its all about maximizing then casinos profits, but this is too obvious and players will complain about it
Yeah actually a good point, I could have added a percentage rate for each number xD


Re: Question about roulette. - Pearson - 31.10.2016

i think no.