View Single Post
02-15-24, 11:47 PM   #9
DennytXVII
A Murloc Raider
Join Date: Feb 2024
Posts: 6
Noted! I will definitely keep that in mind Thank you for the help, I truly appreciate it lol. I'm in fact a noobie lol. I did away with the ConvertToCopper, added the StartGame that I SOMEHOW deleted, it's mostly working (the error comments at least lol) but I go to do /deathdice 5 copper and it won't even let me click enter, just stays in the chat bar while targeting my friend to test. Though, when not targeting my friend it enters, but shows the "You must target a friendly player to start a Death Dice game." error message. I'm missing stuff, or maybe something is in the wrong place is all I can think , also I downloaded the BugGrabber and BugSack, since I forgot to earlier. Will definitely install them and test with them! Here's what I have updated lol

Lua Code:
  1. -- Global variable to keep track of whose turn it is
  2. local currentPlayer = ""
  3. local isGameInProgress = false
  4.  
  5. -- Function to start the game
  6.  function StartGame(player, target, amount, unit)
  7.     currentPlayer = player
  8.     isGameInProgress = true
  9.    
  10.     print(player .. " starts a Death Dice game with " .. target .. "! Type '/ddroll' to make your first roll.")
  11.     print("Bet amount: " .. amount .. " " .. unit .. ".")
  12. end
  13.  
  14. -- Function to handle rolling the dice
  15. local function RollDice(player)
  16.     if player ~= currentPlayer then
  17.         print("It's not your turn to roll!")
  18.         return
  19.     end
  20.    
  21.     local roll = math.random(1, 100)
  22.     print(player .. " rolls: " .. roll)
  23. end
  24.  
  25. -- Define the confirmation popup dialog
  26. StaticPopupDialogs["DEATHDICE_CONFIRM"] = {
  27.     text = "",
  28.     button1 = "Yes",
  29.     button2 = "No",
  30.     OnAccept = function(self, data)
  31.         StartGame(data.player, UnitName("player"), data.amount, data.unit)
  32.         StaticPopup_Hide("DEATHDICE_CONFIRM")  -- Close the confirmation popup
  33.     end,
  34.     OnCancel = function(self)
  35.         print("You declined the Death Dice game.")
  36.         StaticPopup_Hide("DEATHDICE_CONFIRM")  -- Close the confirmation popup
  37.     end,
  38.     timeout = 0,
  39.     whileDead = true,
  40.     hideOnEscape = true,
  41.     preferredIndex = 3,
  42. }
  43.     end
  44. -- Define the SlashCmdList.DEATHDICE function to handle initiating and declining a match
  45. function SlashCmdList.DEATHDICE(msg)
  46.     if isGameInProgress then
  47.         print("A Death Dice game is already in progress!")
  48.         return
  49.     end
  50.  
  51.     local player = UnitName("player")
  52.     local targetName = UnitName("target")
  53.     local amount, unit = tonumber(msg:match("(%d+)")), msg:match("(%a+)")
  54.  
  55.     if not targetName then
  56.         print("You must target a friendly player to start a Death Dice game.")
  57.         return
  58.     end
  59.  
  60.     if not amount or not unit or (unit ~= "copper" and unit ~= "silver" and unit ~= "gold") then
  61.         print("Usage: /deathdice <amount> <unit> (e.g., /deathdice 5 copper)")
  62.         return
  63.     end
  64.  
  65.     -- Send a request to the target player
  66.     SendRequestToTarget(player, targetName, amount, unit)
  67. end
  68.  
  69. -- Function to send a request to the target player
  70. local function SendRequestToTarget(player, targetName, amount, unit)
  71.     -- Display a confirmation popup on the target player's screen
  72.     local confirmation = StaticPopup_Show("DEATHDICE_CONFIRM", "Do you want to start a Death Dice game with " .. player .. "?")
  73.     if confirmation then
  74.         confirmation.data = { player = player, target = targetName, amount = amount, unit = unit }
  75.     end
  76. end
  77.  
  78. -- Define the /ddroll command to allow players to roll the dice during a Death Dice game
  79. function SlashCmdList.DDROLL(msg)
  80.     if not isGameInProgress then
  81.         print("No Death Dice game in progress!")
  82.         return
  83.     end
  84.    
  85.     RollDice(UnitName("player"))
  86. end
  87.  
  88. -- Define the slash commands
  89. SLASH_DEATHDICE1 = "/deathdice"
  90. SLASH_DDROLL1 = "/ddroll"

Last edited by DennytXVII : 02-15-24 at 11:54 PM.
  Reply With Quote