mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2016
Posts: 3
S
slagga Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Jun 2016
Posts: 3
Trying to make a highcard game for users to play against a cpu dealer. So far i have this, which is what the user will flips but im stuck on how to code his card to compare to the dealer and if you lose you get a 30 sec time out.
Quote:

on *:TEXT:!HighCard:#: {
if ((%floodhighcard) || ($($+(%,floodhighcard.,$nick),2))) { return }
set -u10 %floodhighcard On
set -u30 %floodhighcard. $+ $nick On
if ($nick isop #) {
var %randmods = $rand(1,13)
if (%randmods == 1) msg $chan Dealer flips a 2 $nick
if (%randmods == 2) msg $chan Dealer Flips a 3 $nick
if (%randmods == 3) msg $chan Dealer Flips a 4 $nick
if (%randmods == 4) msg $chan Dealer Flips a 5 $nick
if (%randmods == 5) msg $chan Dealer Flips a 6 $nick
if (%randmods == 6) msg $chan Dealer Flips a 7 $nick
if (%randmods == 7) msg $chan Dealer Flips a 8 $nick
if (%randmods == 8) msg $chan Dealer Flips a 9 $nick
if (%randmods == 9) msg $chan Dealer Flips a 10 $nick
if (%randmods == 10) msg $chan Dealer Flips a Jack $nick
if (%randmods == 11) msg $chan Dealer Flips a Queen $nick
if (%randmods == 12) msg $chan Dealer Flips a King $nick
if (%randmods == 13) msg $chan Dealer Flips a Ace $nick

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The number you're generating is for the dealer, not the user. If you want one for the user you need to generate another random number and use that. It's basically the exact same code as you already have, but for the user's card. Then you have two numbers that can be compared.

As for the timeout, right now you have it so every flip creates a 30 second timeout. All you have to do is unset the flood variable if the user wins.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jun 2016
Posts: 3
S
slagga Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Jun 2016
Posts: 3
would you mind helping me out? im stuck on how to right it next to compare dealer and user fliped cards

Joined: Jun 2015
Posts: 84
F
Babel fish
Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
This should work. At least from my testing it did work.
I'll also mention, this will still keep them locked from the command to every 30 seconds to be safe from them alone spamming. (Even with the 10s cooldown on the command itself.)

Code:
 on *:TEXT:!highcard*:#: {
  if ((%floodhighcard) || ($($+(%,floodhighcard.,$nick),2))) { return }
  set -u10 %floodhighcard On
  set -u30 %floodhighcard. $+ $nick On
  var %randdeal = $rand(1,13)
  var %randplayer = $rand(1,13)

  if (%randdeal == 1) { set %dealer 2 }
  if (%randdeal == 2) { set %dealer 3 }
  if (%randdeal == 3) { set %dealer 4 }
  if (%randdeal == 4) { set %dealer 5 }
  if (%randdeal == 5) { set %dealer 6 }
  if (%randdeal == 6) { set %dealer 7 }
  if (%randdeal == 7) { set %dealer 8 }
  if (%randdeal == 8) { set %dealer 9 }
  if (%randdeal == 9) { set %dealer 10 }
  if (%randdeal == 10) { set %dealer Jack }
  if (%randdeal == 11) { set %dealer Queen }
  if (%randdeal == 12) { set %dealer King }
  if (%randdeal == 13) { set %dealer Ace }

  if (%randplayer == 1) { set %player 2 }
  if (%randplayer == 2) { set %player 3 }
  if (%randplayer == 3) { set %player 4 }
  if (%randplayer == 4) { set %player 5 }
  if (%randplayer == 5) { set %player 6 }
  if (%randplayer == 6) { set %player 7 }
  if (%randplayer == 7) { set %player 8 }
  if (%randplayer == 8) { set %player 9 }
  if (%randplayer == 9) { set %player 10 }
  if (%randplayer == 10) { set %player Jack }
  if (%randplayer == 11) { set %player Queen }
  if (%randplayer == 12) { set %player King }
  if (%randplayer == 13) { set %player Ace }

  if (%randdeal > %randplayer) {
    msg # The Dealer wins flipping %dealer over $nick $+ 's %player $+ . Too bad.
    if ($nick !isop #) {
      msg # .timeout $nick 30
    }
  }
  if (%randplayer > %randdeal) {
    msg # $nick wins flipping %player over the Dealer's %dealer $+ . Hooray!
  }
  if (%randplayer == %randdeal) {
    msg # $nick and the Dealer tied, it's an amazing feat with all them cards in the mix. PogChamp
  }
  unset %dealer
  unset %player
}


Reason for unsetting at the end. For some reason, I rolled 3-4 ties when I had it do var %dealer and var %player.

Joined: Jun 2016
Posts: 3
S
slagga Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Jun 2016
Posts: 3
thank you so much it works perfectly, im new to coding is there anywhere i can learn more in depth from for free?

Joined: Jun 2015
Posts: 84
F
Babel fish
Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
Just search through the forums, read help files.
If the files aren't clear, asking here helps as we can clear up things as well.

A good source for help outside some of the help files is WikiChip.


Link Copied to Clipboard