SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Dice command problem (https://forum.sa-mp.com/showthread.php?t=676096)

Relic 29/05/2020 05:48 PM

Dice command problem
 
Hello lovely scripters,

I'm a massive rookie to pawno scripting, i'd like a little bit of assistance ^^

What am I doing wrong here?

https://i.imgur.com/IQ7UGsm.png

Nexotronix 29/05/2020 06:07 PM

Re: Dice command problem
 
Try this:

pawn Code:
CMD:dice(playerid,params[])
{
    new string[128];
    if(HasDice[playerid] == 0) return SendClientMessage(playerid, -1, "You don't have a pair of dices");
    format(string, sizeof(string), "You throwed dices and it stands to: %i", random(12));//12 'cause you throwed a pair of it
    SendClientMessage(playerid, -1, string);
    return 1;
}

Cell_ 29/05/2020 08:01 PM

Re: Dice command problem
 
pawn Code:
format(string, sizeof(string), "%s", dice[randomMSG]);
Also, next time post your code rather than taking a screenshot.

Relic 29/05/2020 08:06 PM

Re: Dice command problem
 
Quote:

Originally Posted by Nexotronix (Post 4148616)
Try this:

pawn Code:
CMD:dice(playerid,params[])
{
    new string[128];
    if(HasDice[playerid] == 0) return SendClientMessage(playerid, -1, "You don't have a pair of dices");
    format(string, sizeof(string), "You throwed dices and it stands to: %i", random(12));//12 'cause you throwed a pair of it
    SendClientMessage(playerid, -1, string);
    return 1;
}

Works smoothly man!

Thanks bruda, +repped you.

Nexotronix 29/05/2020 08:08 PM

Re: Dice command problem
 
Quote:

Originally Posted by Relic (Post 4148635)
Works smoothly man!

Thanks bruda, +repped you.

Enjoy, mate! Always ready to help 🙂

Adamoneoone 29/05/2020 08:10 PM

Re: Dice command problem
 
Little correction, random's range is [0, max-1], so random(12) will never give out 12. If you want it to be the case, just change it to random(13)


All times are GMT. The time now is 09:51 AM.

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