[HELP] How to create a dices command

Hi, I tried to make a command that his funtion is to print a msg in the chat like that:

[Player ID] You have rolled the die and rolled a (random number from 1 to 10).

Anyone have idea how to do it? thx :slight_smile:

Hello, this is a friendly reminder because this is your first time creating a topic (or it has been a while since your last topic) in this category.

Please note that most of the support is provided by the Cfx.re community on a voluntary basis. We ask you to be patient; there is no guarantee we have a solution to your problem(s). To avoid unnecessary/duplicate topics, please browse the forums before creating a topic.

To improve your chances of your issue(s) being solved, please provide as much information as possible about the issue(s) you are having. Also —whenever possible— please use the template given to you when creating a topic.

Thanks for keeping these forums tidy!
:mascot:

RegisterCommand('roll', function(source, args, rawCommand)
 local number = math.random(1,6)
 loadAnimDict("anim@mp_player_intcelebrationmale@wank")
 TaskPlayAnim(GetPlayerPed(-1), "anim@mp_player_intcelebrationmale@wank", "wank", 8.0, 1.0, -1, 49, 0, 0, 0, 0)
 Citizen.Wait(1500)
 ClearPedTasks(GetPlayerPed(-1))
 TriggerEvent('chatMessage', '[Dice]', {128, 0, 128}, 'You Rolled: '..number)
end)

function loadAnimDict(dict)
 while not HasAnimDictLoaded(dict) do
  RequestAnimDict( dict )
  Citizen.Wait(5)
 end
end

chatMessage is no longer used so you will need to update this however it’s an example.

1 Like

Thanks!!
But what we use now instead of “chatMessage”?

See https://docs.fivem.net/docs/scripting-manual/migrating-from-deprecated/chat-messages/

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.