AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved !roulette random possibility (https://forums.alliedmods.net/showthread.php?t=303579)

TRServer 12-13-2017 05:52

!roulette random possibility
 
Hello I have a problem

I want to identify myself to the possibility of random

Black %48
Red % 48
Green % 4

Code:

public Action:ElBasi(Handle:event, const String:name[], bool:dontBroadcast)
{
        int hangirenk = GetRandomInt(1, 38);
        renkcek = hangirenk;
}
public Action:ElSonu(Handle:event, const String:name[], bool:dontBroadcast)
{
            if(renkcek==1 || renkcek==3 || renkcek==5 || renkcek==7 || renkcek==9 || renkcek==12 || renkcek==14 || renkcek==16 || renkcek==18 || renkcek==19 || renkcek==21 || renkcek==23 || renkcek==25 || renkcek==27 || renkcek==30 || renkcek==32 || renkcek==34 || renkcek==36){
                PrintToChatAll("Kırmızı");
    }else if(renkcek==37 || renkcek==38){

              PrintToChatAll("Yeşil");
    }else{
           
              PrintToChatAll("Siyah");
    }
       
}


hleV 12-13-2017 10:16

Re: !roulette random possibility
 
PHP Code:

int num GetRandomInt(1100);

if (
num <= 48)
{
    
// Black
}
else if (
num <= 48 48// Or just <= 96, but I think it's easier to understand like that?
{
    
// Red
}
else 
/* if (num <= 48 + 48 + 4) */
{
    
// Green



TRServer 12-13-2017 11:22

Re: !roulette random possibility
 
Code:

    int num = GetRandomInt(1, 100);

        if (num <= 48)
        {
            PrintToChat(client, "Siyah");
        }
        else if (num <= 48 + 48) // Or just <= 96, but I think it's easier to understand like that?
        {
            PrintToChat(client, "Kırmızı");
        }
        else if (num <= 48 + 48 + 4)
        {
            PrintToChat(client, "Yeşil");
        }

Thank you :)

Arkarr 12-15-2017 06:32

Re: !roulette random possibility
 
Wouldn't that be more random ?

PHP Code:

int num GetRandomInt(1100); 

if(
num >= 96)
     
//Green
else if(num%== 0)
     
//Black
else //if(num%2 == 1)
     //Red 


TRServer 12-15-2017 09:53

Re: !roulette random possibility
 
yes, that may be Thank you :)


All times are GMT -4. The time now is 01:12.

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