mIRC Homepage
Posted By: AntiTeal Need help with random number game. - 25/01/16 03:02 AM
So I have this game based on CS:GO case openings, and I can't get it to work. Basically how it should work is that random numbers get selected and they correspond to what you get. However, the script doesn't work when you add the $rand commands to %stattrak and %color. Can you guys help me figure out why?
Click to reveal..

on *:text:!cc:#:{
if (!%comwait) {
set -u6 %comwait 1
var %topic $+($chan,.,$nick)
var %points $iif($readini(Points.ini,%topic,Points) == $null,0,$v1)
var %keys $iif($readini(CaseClicker.ini,%topic,Keys) == $null,0,$v1)
var %cases $iif($readini(CaseClicker.ini,%topic,Cases) == $null,0,$v1)
var %stattrak = $rand(0,100)
var %color = $rand(0,100)

if %cases < 1 { msg $chan You don't have enough cases. | halt }
if %keys < 1 { msg $chan You don't have enough keys. | halt }

%cases = $calc(%cases - 1)
writeini -n CaseClicker.ini %topic Cases %cases

%keys = $calc(%keys - 1)
writeini -n CaseClicker.ini %topic Keys %keys

msg # stattrak is %stattrak
msg # color is %color

/timer 1 3 msg # Opening the case!

if (%stattrak <= 40) {
%st == 1
}
if (%stattrak > 40) {
%st == 0
}
if (%color <= 50) {
%c == 1
}
if (%color <= 75 && > 50) {
%c == 2
}
if (%color <= 90 && > 75) {
%c == 3
}
if (%color <= 96 && > 75) {
%c == 4
}
if (%color <= 100 && > 96) {
%c == 5
}

msg # c is %c
msg # st is %st


/timer 1 6 msg # $nick, you opened the case and got...

if (%c = 1 && %st = 0) {
/timer 1 9 msg # a Mil-Spec Blue Gun! 40 points have been added.
%points = $calc(%points + 40)
writeini -n Points.ini %topic Points %points
return %points
}
if (%c = 2 && %st = 0) {
/timer 1 9 msg # a Restricted Purple Gun! 100 points have been added.
%points = $calc(%points + 100)
writeini -n Points.ini %topic Points %points
return %points
}
if (%c = 3 && %st = 0) {
/timer 1 9 msg # a Classified Pink Gun! 250 points have been added.
%points = $calc(%points + 250)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 4 && %st = 0) {
/timer 1 9 msg # a Covert Red Gun! 525 points have been added.
%points = $calc(%points + 525)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 5 && %st = 0) {
/timer 1 9 msg # a Exceedingly Rare Yellow Knife! Wow! 900 points have been added.
%points = $calc(%points + 900)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 1 && %st = 1) {
/timer 1 9 msg # a StatTrak Mil-Spec Blue Gun! 80 points have been added.
%points = $calc(%points + 80)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 2 && %st = 1) {
/timer 1 9 msg # a StatTrak Restricted Purple Gun! 200 points have been added.
%points = $calc(%points + 200)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 3 && %st = 1) {
/timer 1 9 msg # a StatTrak Classified Pink Gun! 350 points have been added.
%points = $calc(%points + 350)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 4 && %st = 1) {
/timer 1 9 msg # a StatTrak Covert Red Gun! 700 points have been added.
%points = $calc(%points + 700)
writeini -n Points.ini %topic Points %points
return %points
}

if (%c = 5 && %st = 1) {
/timer 1 9 msg # a StatTrak Exceedingly Rare Yellow Knife! WOW! 1200 points have been added.
%points = $calc(%points + 1200)
writeini -n Points.ini %topic Points %points
return %points
}
}
}
else {
msg $chan This command is on cooldown.
}

Thanks so much guys!
Posted By: AntiTeal Re: Need help with random number game. - 25/01/16 03:45 AM
Actually, it seems that if I were to give it any value, it would break. It probably isn't the $rand section, but I still can't figure it out.
Posted By: westor Re: Need help with random number game. - 25/01/16 11:08 AM
Try to use this code:

Php Code:
ON *:TEXT:!cc:#: {
  if (%comwait) { msg $chan This command is on cooldown. | return }

  set -eu6 %comwait 1

  var %topic $+(#,.,$nick)
  var %points $iif($!readini(Points.ini,%topic,Points),0,$v1)
  var %keys $iif($!readini(CaseClicker.ini,%topic,Keys),0,$v1)
  var %cases $iif($!readini(CaseClicker.ini,%topic,Cases),0,$v1)
  var %stattrak = $rand(1,100)
  var %color = $rand(1,100)

  if (%cases < 1) { msg # $nick -> You don't have enough cases! | return }
  if (%keys < 1) { msg # $nick -> You don't have enough keys! | return }

  var %cases = $calc(%cases - 1)
  writeini -n $qt(CaseClicker.ini) %topic Cases %cases

  var %keys = $calc(%keys - 1)
  writeini -n $qt(CaseClicker.ini) %topic Keys %keys

  msg # stattrak is %stattrak
  msg # color is %color

  .timer 1 3 msg # Opening the case!

  if (%stattrak <= 40) { var %st = 1 }
  if (%stattrak > 40) { var %st = 0 }
  if (%color <= 50) { var %c = 1 }
  if (%color <= 75) && (%color > 50) { var %c = 2 }
  if (%color <= 90) && (%color > 75) { var %c = 3 }
  if (%color <= 96) && (%color > 75) { var %c = 4 }
  if (%color <= 100) && (%color > 96) { var %c = 5 }

  msg # c is %c
  msg # st is %st

  .timer 1 6 msg # $nick, you opened the case and got...

  if (%c == 1) && (%st == 0) {
	var %points = $calc(%points + 40)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a Mil-Spec Blue Gun! 40 points have been added.
  }
  elseif (%c == 2) && (%st == 0) {
	var %points = $calc(%points + 100)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a Restricted Purple Gun! 100 points have been added.
  }
  elseif (%c == 3) && (%st == 0) {
	var %points = $calc(%points + 250)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a Classified Pink Gun! 250 points have been added.
  }
  elseif (%c == 4) && (%st == 0) {  
	var %points = $calc(%points + 525)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a Covert Red Gun! 525 points have been added.
  }
  elseif (%c == 5) && (%st == 0) {
	var %points = $calc(%points + 900)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a Exceedingly Rare Yellow Knife! Wow! 900 points have been added.
  }
  elseif (%c == 1) && (%st == 1) {
	var %points = $calc(%points + 80)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a StatTrak Mil-Spec Blue Gun! 80 points have been added.
  }
  elseif (%c == 2) && (%st == 1) {
	var %points = $calc(%points + 200)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a StatTrak Restricted Purple Gun! 200 points have been added.
  }
  elseif (%c == 3) && (%st == 1) {
	%points = $calc(%points + 350)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a StatTrak Classified Pink Gun! 350 points have been added.
  }
  elseif (%c == 4) && (%st == 1) {
	var %points = $calc(%points + 700)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a StatTrak Covert Red Gun! 700 points have been added.
  }
  elseif (%c == 5) && (%st == 1) {
	var %points = $calc(%points + 1200)
	writeini -n $qt(Points.ini) %topic Points %points
	.timer 1 9 msg # a StatTrak Exceedingly Rare Yellow Knife! WOW! 1200 points have been added.
  }
}
 
Posted By: AntiTeal Re: Need help with random number game. - 25/01/16 08:13 PM
Thanks so much man! Ill try it out later.
© mIRC Discussion Forums