mIRC Homepage
Posted By: Krawalli My own Numberguess - need a little Fix! - 01/08/14 09:20 AM
Hey,
i wrote a number guessing game for my casino.

The Problem:
> every guess costs "150 coins" > the Script sometimes "buggs" and dont take any coins from the users! Sometimes its working fine! (the script is too slow/bad written?)

The random hint is working fine. (Chance 50/50 that a hint is given)


Script:
Code:
ON *:TEXT:!number*:#:{ 
  if ($2 == %number) { msg # /me WOW! $nick : $2 +500 CC's! | writeini -n casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) + 500) | set %ratenaus 1 }  
  elseif ($2 < %number) { writeini casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) -150) | set %hint1 $rand(1,2) }
  if (%hint1 == 1) { msg # Number under $2 } | unset %ausgeben1 }
  elseif ($2 > %number) { writeini casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) -150) | set %hint2 $rand(1,2) }
  if (%hint2 == 1) { msg # Number over $2 } | unset %hint2 }
}  



Would be awesome if someone can help me!
Posted By: Nillen Re: My own Numberguess - need a little Fix! - 01/08/14 09:51 AM
Add a space between "- 150"

Also, your if statments are placed wrong.
Code:
  elseif ($2 < %number) { writeini casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) -150) | set %hint1 $rand(1,2) }
  if (%hint1 == 1) { msg # Number under $2 } | unset %ausgeben1 }
  elseif ($2 > %number) { writeini casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) -150) | set %hint2 $rand(1,2) }
The third line will only work when %hint1 isn't 1.

Line 2 and 4 (not shown in above snippet) are wrong as well. You're closing the bracket and then adding another | and closing it again.

You're unsetting the %ausgeben1 variable instead of %hint1.
Posted By: Krawalli Re: My own Numberguess - need a little Fix! - 01/08/14 10:14 AM
Thanks for the ideas / help nillen.
The unsetting %ausgeben was wrong because i wrote the script fast in engl. to post it in this board x)

Thats my new if version:
Code:
if ($2 == %number) { msg # /me WOW! $nick : $2 +500 CC's! | writeini -n casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) + 500) | set %ratenaus 1 }  
if ($2 < %number) { writeini casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) - 150) | set %hint1 $rand(1,2) | if (%hint1 == 1) msg # Number under $2 | unset %hint1 }
if ($2 > %number) { writeini casino.ini $nick Money $calc($readini(casino.ini,$nick,Money) - 150) | set %hint2 $rand(1,2) | if (%hint2 == 1) msg # Number over $2 | unset %hint2 }
Posted By: Nillen Re: My own Numberguess - need a little Fix! - 01/08/14 10:35 AM
No idea if that actually works.
Here's how I would do it.

Code:
on *:text:!number*:#: { 
  if ($nick isop #) && (!$2) { set %number $rand(1,20) | return }
  if (!$2) || (!%number) { echo 3 # Something went wrong. | return }
  if ($2 == %number) { msg # Correct! | casino $nick + 500 | unset %number }
  elseif ($2 != %number) { 
    casino $nick - 150
    var %hint $rand(1,2)
    msg # Wrong! $iif(%hint == 1,The number is $iif(%number < $2,lower,higher) than $2 $+ .,$null)
  }
}

alias -l casino {
  if ($0 == 3) writeini casino.ini $1 money $calc($readini(casino.ini,$1,money) $iif($2 == +,+,-) $3)
  elseif ($0 == 2) writeini casino.ini $1 money $2
  elseif ($0 == 1) return $readini(casino.ini,$1,money)
}
Posted By: Krawalli Re: My own Numberguess - need a little Fix! - 01/08/14 10:40 AM
Jup, my "if statements" now working perfect! smile
Thanks for your idea!
© mIRC Discussion Forums