mIRC Home    About    Download    Register    News    Help

Print Thread
My own Numberguess - need a little Fix! #247399 01/08/14 09:20 AM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
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!

Last edited by Krawalli; 01/08/14 10:15 AM.
Re: My own Numberguess - need a little Fix! [Re: Krawalli] #247400 01/08/14 09:51 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: My own Numberguess - need a little Fix! [Re: Nillen] #247401 01/08/14 10:14 AM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
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 }

Last edited by Krawalli; 01/08/14 10:19 AM.
Re: My own Numberguess - need a little Fix! [Re: Krawalli] #247402 01/08/14 10:35 AM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
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)
}


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: My own Numberguess - need a little Fix! [Re: Nillen] #247403 01/08/14 10:40 AM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Jup, my "if statements" now working perfect! smile
Thanks for your idea!

Last edited by Krawalli; 01/08/14 10:41 AM.