SA-MP Forums Archive
/dice command - 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: /dice command (/showthread.php?tid=646519)



/dice command - Osamakurdi - 18.12.2017

I need cmd that should roll a dice from 1 to 6
And there is condition if the roll is 6 the player will get 1000,000
PleaSe 🙏 give me it with tutorial and explaining.


Re: /dice command - jasperschellekens - 18.12.2017

This is the wrong section for this. But im going to help you.

At first you need to create a array to display 1-6.

Code:
new DiceArray[][] = {
    "1", 
    "2" ,
    "3" ,
    "4" ,
    "5",
    "6"       
};
//We need this part later to make it roll between 1 or 6 for now put it on top of your script at your other news
Next thing we need to do is create a command to dice.
For this example i will use ZCMD.

Code:
CMD:dice(playerid,params[])
{
    new string[128]; // this will create the string which will send the value of dicearray to all players
    new RandomDice = random(sizeof(DiceArray)); // This will store the output of DiceArray into RandomDice
    format(string,sizeof(string),"%s(%i) rolls the dice: %s",PlayerName(playerid),playerid,DiceArray[RandomDice]);
    SendClientMessageToAll(-1, string);	
    return 1;
}
Note: i did not test this so let me know if it works.


Re: /dice command - DelK - 18.12.2017

I apologize my English is not very good, but for what I understand it was this try and if it is not, it explains me better. I will leave a print of how it was > Click Here
PHP Code:
CMD:dice(playerid)
{
    new 
Dice;
    
Dice random(7);
    if(
Dice == 0)
    {
        
SendClientMessage(playerid, -1"The dice number 0");
    }
    if(
Dice == 1)
    {
        
SendClientMessage(playerid, -1"The dice number 1");
    }
    if(
Dice == 2)
    {
        
SendClientMessage(playerid, -1"The dice number 2");
    }
    if(
Dice == 3)
    {
        
SendClientMessage(playerid, -1"The dice number 3");
    }
    if(
Dice == 4)
    {
        
SendClientMessage(playerid, -1"The dice number 4");
    }
    if(
Dice == 5)
    {
        
SendClientMessage(playerid, -1"The dice number 5");
    }
    if(
Dice == 6)
    {
        
SendClientMessage(playerid, -1"The dice number 6 and you wins 1000,000 money!");
        
GivePlayerMoney(playerid100000);
    }
    return 
1;




Re: /dice command - GaByM - 18.12.2017

Code:
CMD:dice(playerid, params[])
{
    new str[30];
    new number = random(6)+1; //number can be 1,2,3,4,5 or 6
    format(str, sizeof(str), "You roll the dice: %i", k);
    SendClientMessage(playerid, 0xCECECEFF, str);
    if(k > 5)
    {
        SendClientMessage(playerid, 0x900000FF, "Congratulations! You won $100,000!");
        GivePlayerMoney(playerid, 100000);
    }
    return 1;
}
If you have any questions ask.


Re: /dice command - adri1 - 18.12.2017

Code:
stock minrand(min, max) //By Alex "******" Cole
{
	return random(max - min) + min;
}
Code:
new dice = minrand(1, 6);
printf("dice: %d", dice);



Re: /dice command - Argument - 18.12.2017

PHP Code:
CMD:dice(playeridparams[])
{
    static const 
msg_text[] = "You roll the dice: %d";
    new 
result random(5), msg[sizeof(msg_text) - 1];
    
format(msgsizeof(msg), msg_textresult+1);
    
SendClientMessage(playerid, -1msg);
    if(
result == 5)
    {
        
GivePlayerMoney(playerid100000);
        
SendClientMessage(playerid, -1"Congratulations! You won $100,000!");
    }
    return 
1;




Re: /dice command - Osamakurdi - 21.12.2017

Thanks All , All codes Works