Fearless Forums
/card command to draw a random card - Printable Version

+- Fearless Forums (https://fearlessrp.net)
+-- Forum: CityRP Server (https://fearlessrp.net/forumdisplay.php?fid=6)
+--- Forum: Suggestions (https://fearlessrp.net/forumdisplay.php?fid=7)
+---- Forum: Finished (https://fearlessrp.net/forumdisplay.php?fid=26)
+---- Thread: /card command to draw a random card (/showthread.php?tid=93402)

Pages: 1 2 3


RE: /card command to draw a random card - Lewwings - 07-23-2019

+Support! Smile


RE: /card command to draw a random card - DouxFlame - 07-23-2019

+Support. Bring back our best dealer


RE: /card command to draw a random card - CorieTheNub - 07-23-2019

After playing blackjack in casinos. Sometimes it gets a bit confussing when you see a 13 or 12. It gives younger players a better chance of following the game.

Big +Support


RE: /card command to draw a random card - Zulu - 07-24-2019

(07-23-2019, 04:13 PM)Ryan Wrote: It's this just /dice though?

Yes but less shit and more adaptable to pober etc...


RE: /card command to draw a random card - Conn - 07-24-2019

Another possible solution, this time generating a deck with 1-6 packs of cards in. Obviously a bit of a guessing game and I haven't tested the main code (yet) on a sandbox, but it should work I think..



Spoiler :
Code:
local playerCards = {}


-- Command to create a set of 1-8 decks of playing cards
cityrp.command.add("deck", "b", 1, function(ply, arguments)

   local decksize = tonumber(arguments[1])

   if (!decksize or decksize < 1 or decksize > 8) then
       
       ply:Notify("Please choose a decksize between 1 and 8.", 1)    
       return
       
   end
   
   local suits = {"Spades", "Clubs", "Hearts", "Diamonds"}
   local values = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"}

   local deck = {}

   for i=1, decksize do
       
       for k, value in pairs(values) do
           
           for k, suit in pairs(suits) do  
                     
               table.insert(deck, value .. " of " .. suit)  
                     
           end   
                    
       end   
            
   end

   table.insert(playerCards, {ply, deck})
   ply:Notify("Deck generated!")

end, "Commands", "<1-8>", "Creates a pile of 1-8 card decks for casino games")

-- Command to print a random playing card from a generated deck
cityrp.command.add("card", "b", 0, function(ply)

   local deck = {}
   local index = 0
   for k,v in pairs(playerCards) do
       if (v[1] == ply) then
           deck = v[2]
           index = k
           break
       end
   end

   if (!deck or table.IsEmpty(deck)) then

       ply:Notify("You must generate a deck. Use /deck <1-8>", 1)
       return
       
   end

   local card, index = table.Random(deck)
   table.remove(playerCards,index)
   table.insert(playerCards, index, {ply, deck})

   ply:ConCommand("cityrp me drew " .. card)

end, "Commands", "<none>", "Picks a random card from the deck")

Changed a bit with Devon, should work Smile





RE: /card command to draw a random card - Rossi - 07-24-2019

+Support

Like it


RE: /card command to draw a random card - Flame.. - 07-24-2019

Only if i get HALF your money...











+support


RE: /card command to draw a random card - Chumps - 07-24-2019

+Support


RE: /card command to draw a random card - RedPanda - 07-24-2019

+Support


RE: /card command to draw a random card - RoCKy - 07-24-2019

+supporrrrrt