SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/12/2017, 12:58 PM   #1
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Post /dice command

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.
Osamakurdi is offline   Reply With Quote
Old 18/12/2017, 01:26 PM   #2
jasperschellekens
High-roller
 
jasperschellekens's Avatar
 
Join Date: Dec 2016
Location: Holland
Posts: 1,080
Reputation: 126
Default Re: /dice command

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.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!


Undead Wasteland Roleplay - The year is 1996. San Andreas is a wasteland ruled by the undead. the once so glorius landscape of San Andreas, is now a shattered decayed place that is only a vague memory of the world as we used to know it.
Discord - Website
jasperschellekens is offline   Reply With Quote
Old 18/12/2017, 01:34 PM   #3
DelK
Huge Clucker
 
DelK's Avatar
 
Join Date: Apr 2017
Location: Brazil
Posts: 456
Reputation: 40
Default Re: /dice command

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;

__________________
DelK is offline   Reply With Quote
Old 18/12/2017, 02:00 PM   #4
GaByM
Big Clucker
 
GaByM's Avatar
 
Join Date: Jan 2014
Location: Romania
Posts: 112
Reputation: 10
Default Re: /dice command

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.
GaByM is offline   Reply With Quote
Old 18/12/2017, 02:05 PM   #5
adri1
Banned
 
Join Date: Oct 2010
Posts: 1,779
Reputation: 965
Default Re: /dice command

Code:
stock minrand(min, max) //By Alex "******" Cole
{
	return random(max - min) + min;
}
Code:
new dice = minrand(1, 6);
printf("dice: %d", dice);
adri1 is offline   Reply With Quote
Old 18/12/2017, 04:49 PM   #6
Argument
Big Clucker
 
Join Date: Jan 2015
Location: :/
Posts: 55
Reputation: 4
Default Re: /dice command

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;

__________________
SA-MP 0.4a is released!
Download: http://files.sa-mp.com/sa-mp-0.4a-install.exe
english is bad
Argument is offline   Reply With Quote
Old 21/12/2017, 11:49 AM   #7
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Re: /dice command

Thanks All , All codes Works
Osamakurdi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dice command. GabiXx Scripting Help 7 26/12/2015 11:57 AM
Dice command help request , i give reputation ++ ! buburuzu19 Scripting Help 4 31/10/2014 09:43 AM
[Tutorial] How to Make a Dice Command kosa451 Tutorials 13 04/09/2014 07:46 PM
command /dice. capsator10 Scripting Help 30 14/08/2014 06:28 PM
Dice command friezakinght Scripting Help 2 10/07/2014 02:01 PM


All times are GMT. The time now is 04:59 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.