Hello I'm trying make some cards with lua and have made it someway now. Drawing cards from a deck is random and works fine aswell as displays fine.
Yet I want to be able to only draw the cards 1 time. untill the deck has been shuffled again. So I need to somehow limit how many times I can draw the cards. and a command to shuffle them again.
Code looks like this so far.
card={"♥2", "♥3", "♥4", "♥5", "♥6", "♥7", "♥8", "♥9", "♥10", "♥J", "♥Q", "♥K", "♥A", "♣2", "♣3", "♣4", "♣5", "♣6", "♣7", "♣8", "♣9", "♣10", "♣J", "♣Q", "♣K", "♣A", "♦2", "♦3", "♦4", "♦5", "♦6", "♦7", "♦8", "♦9", "♦10", "♦J", "♦Q", "♦", "♦ACE", "♠2", "♠3", "♠4", "♠5", "♠6", "♠7", "♠8", "♠9", "♠10", "♠J", "♠Q", "♠K", "♠A"}
function cmd_card (player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]))
end
function cmd_card2(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
function cmd_card3(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
function cmd_card4(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
function cmd_card5(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
AddCommand("card", cmd_card)
AddCommand("card2", cmd_card2)
AddCommand("card3", cmd_card3)
AddCommand("card4", cmd_card4)
AddCommand("card5", cmd_card5)
Thanks in advance if someone is able to help me.
Yet I want to be able to only draw the cards 1 time. untill the deck has been shuffled again. So I need to somehow limit how many times I can draw the cards. and a command to shuffle them again.
Code looks like this so far.
card={"♥2", "♥3", "♥4", "♥5", "♥6", "♥7", "♥8", "♥9", "♥10", "♥J", "♥Q", "♥K", "♥A", "♣2", "♣3", "♣4", "♣5", "♣6", "♣7", "♣8", "♣9", "♣10", "♣J", "♣Q", "♣K", "♣A", "♦2", "♦3", "♦4", "♦5", "♦6", "♦7", "♦8", "♦9", "♦10", "♦J", "♦Q", "♦", "♦ACE", "♠2", "♠3", "♠4", "♠5", "♠6", "♠7", "♠8", "♠9", "♠10", "♠J", "♠Q", "♠K", "♠A"}
function cmd_card (player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]))
end
function cmd_card2(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
function cmd_card3(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
function cmd_card4(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
function cmd_card5(player)
math.randomseed( os.time() )
AddPlayerChat(player, "drawed " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]) .. " - " .. (card[math.random(#card)]))
end
AddCommand("card", cmd_card)
AddCommand("card2", cmd_card2)
AddCommand("card3", cmd_card3)
AddCommand("card4", cmd_card4)
AddCommand("card5", cmd_card5)
Thanks in advance if someone is able to help me.
Comment