mIRC Home    About    Download    Register    News    Help

Print Thread
/writeini issue #249771 14/12/14 11:34 PM
Joined: Sep 2014
Posts: 83
H
HappyFappy Offline OP
Babel fish
OP Offline
Babel fish
H
Joined: Sep 2014
Posts: 83
idk whats happening...

i converted this scrypt to use ini instead of roully...

this is the code:

under "alias spin" down at the payout areas... the /writeini doesnt seem to register (there are three areas this is happening in the payout area)

Code:
on *:text:!roulette*:#: {  
  if ($readini( xmg.ini, $nick, Money ) == $null) { msg $chan $nick you don't have credits! | halt }
  if ($3 !isnum) { msg $chan You can only bet numerical values. | Halt }
  if ($left($3,1) == $chr(45)) { msg $chan You can not use negative numbers $nick | halt }
  if ($3 <= 0) { msg $chan Please use a positive number. | halt }
  if ($3) && ($readini( xmg.ini, $nick, Money ) < $3) { msg $chan You can not wager that much $nick as you only have $chr(36) $+ ($readini( xmg.ini, $nick, Money ) $+ . | halt }
  if ($2 == Red || $2 == Black || $2 == Odd || $2 == Even || $2 == Row1 || $2 == Row2 || $2 == Row3 || $2 == Column1 || $2 == Column2 || $2 == Column3 || $2 isnum) {
    if ($2 != num || $2 < 27 && $2 >= 0) {
      if (%rltimer != on) { 
        set %rltimer on 
        msg # You now have 60 seconds to place your bets 
        timer 1 60 msg # Betting is now off 
        timer 1 60 unset %rltimer
        timer 1 60 /spin $chan
      }
      msg $chan Your bet has been added to the table!
      write bets.txt $address($nick, 2) $nick $2 $3
      /set %money.bet $calc( $readini( xmg.ini, $nick , Money ) - $3)
      /writeini xmg.ini $nick Money %money.bet
      /unset %money.bet
    }
  }
  else { msg $chan That is not a valid bet, try !roulette red 1000 }
}
alias spin { 
  var %num = $rand(0,36)
  msg $1 The Roulette spins and lands on %num
  if (%num == 0) { var %bets = 0 }
  if (%num == 1) { var %bets = 1 red odd row1 column1 }
  if (%num == 2) { var %bets = 2 black even row2 column1 }
  if (%num == 3) { var %bets = 3 red odd row3 column1 }
  if (%num == 4) { var %bets = 4 black even row1 column1 }
  if (%num == 5) { var %bets = 5 red odd row2 column1 }
  if (%num == 6) { var %bets = 6 black even row3 column1 }
  if (%num == 7) { var %bets = 7 red odd row1 column1 }
  if (%num == 8) { var %bets = 8 black even row2 column1 }
  if (%num == 9) { var %bets = 9 red odd row3 column1 }
  if (%num == 10) { var %bets = 10 black even row1 column1 }
  if (%num == 11) { var %bets = 11 black odd row2 column1 }
  if (%num == 12) { var %bets = 12 red even row3 column1 }
  if (%num == 13) { var %bets = 13 black odd row1 column2 }
  if (%num == 14) { var %bets = 14 red even row2 column2 }
  if (%num == 15) { var %bets = 15 black odd row3 column2 }
  if (%num == 16) { var %bets = 16 red even row1 column2 }
  if (%num == 17) { var %bets = 17 black odd row2 column2 }
  if (%num == 18) { var %bets = 18 red even row3 column2 }
  if (%num == 19) { var %bets = 19 red odd row1 column2 }
  if (%num == 20) { var %bets = 20 black even row2 column2 }
  if (%num == 21) { var %bets = 21 red odd row3 column2 }
  if (%num == 22) { var %bets = 22 black even row1 column2 }
  if (%num == 23) { var %bets = 23 red odd row2 column2 }
  if (%num == 24) { var %bets = 24 black even row3 column2 }
  if (%num == 25) { var %bets = 25 red odd row1 column3 }
  if (%num == 26) { var %bets = 26 black even row2 column3 }
  if (%num == 27) { var %bets = 27 red odd row3 column3 }
  if (%num == 28) { var %bets = 28 black even row1 column3 }
  if (%num == 29) { var %bets = 29 black odd row2 column3 }
  if (%num == 30) { var %bets = 30 red even row3 column3 }
  if (%num == 31) { var %bets = 31 black odd row1 column3 }
  if (%num == 32) { var %bets = 32 red even row2 column3 }
  if (%num == 33) { var %bets = 33 black odd row3 column3 }
  if (%num == 34) { var %bets = 34 red even row1 column3 }
  if (%num == 35) { var %bets = 35 black odd row2 column3 }
  if (%num == 36) { var %bets = 36 red even row3 column3 }
  var %count = 1
  while ($read(bets.txt, %count) != $null) {
    var %add = $wildtok($read(bets.txt, %count), *, 1, 32)
    var %nick = $wildtok($read(bets.txt, %count), *, 2, 32)
    var %bet = $wildtok($read(bets.txt, %count), *, 3, 32)
    var %ammount = $wildtok($read(bets.txt, %count), *, 4, 32)
    if (%bet isin %bets) {
      if (%bet == Red || %bet == Black || %bet == Odd || %bet == Even) {
        msg $1 %nick has won %ammount with their bet on %bet
        [b]/set %money.win $calc( $readini( xmg.ini, $nick , Money ) + %ammount )
        /writeini xmg.ini $nick Money %money.win
        /unset %money.win[/b]
      }
      if (%bet == Row1 || %bet == Row2 || %bet == Row3 || %bet == Column1 || %bet == Column2 || %bet == Column3) { 
        msg $1 %nick has won $calc(%ammount * 2) with their bet on %bet 
        [b]/set %money.win $calc( $readini( xmg.ini, $nick , Money ) + %ammount )
        /writeini xmg.ini $nick Money %money.win
        /unset %money.win[/b]
      }
      if (%bet == 0 || %bet == 1 || %bet == 2 || %bet == 3 || %bet == 4 || %bet == 5 || %bet == 6 || %bet == 7 || %bet == 8 || %bet == 9 || %bet == 10 || %bet == 11 || %bet == 12 || %bet == 13 || %bet == 14 || %bet == 15 || %bet == 16 || %bet == 17 || %bet == 18 || %bet == 19 || %bet == 20 || %bet == 21 || %bet == 22 || %bet == 23 || %bet == 24 || %bet == 25 || %bet == 26 || %bet == 27 || %bet == 28 || %bet == 29 || %bet == 30 || %bet == 31 || %bet == 32 || %bet == 33 || %bet == 34 || %bet == 35 || %bet == 36) {
        msg $1 %nick has won $calc(%ammount * 36) with their bet on %bet 
        /set %money.win $calc( $readini( xmg.ini, $nick , Money ) + %ammount )
        /writeini xmg.ini $nick Money %money.win
        /unset %money.win
      }
    }
    inc %count
  }
  msg $1 All other bets were lost, better luck next time!
  remove bets.txt
}

Re: /writeini issue [Re: HappyFappy] #249773 14/12/14 11:40 PM
Joined: Oct 2009
Posts: 24
Scakk Offline
Ameglian cow
Offline
Ameglian cow
Joined: Oct 2009
Posts: 24
$nick is not being filled via the alias.

Change this bit "timer 1 60 /spin $chan" to have $nick after $chan as such

"timer 1 60 /spin $chan $nick" and then where you have $nick in the writeini use $2 instead of $nick.

Re: /writeini issue [Re: Scakk] #249774 14/12/14 11:42 PM
Joined: Sep 2014
Posts: 83
H
HappyFappy Offline OP
Babel fish
OP Offline
Babel fish
H
Joined: Sep 2014
Posts: 83
Originally Posted By: Scakk
$nick is not being filled via the alias.

Change this bit "timer 1 60 /spin $chan" to have $nick after $chan as such

"timer 1 60 /spin $chan $nick" and then where you have $nick in the writeini use $2 instead of $nick.


worked... thank you

Last edited by HappyFappy; 14/12/14 11:56 PM.
Re: /writeini issue [Re: HappyFappy] #249789 15/12/14 11:42 AM
Joined: Jul 2006
Posts: 3,881
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,881
You have unknown content passed to timer which can be dangerous.
Consider reading this and using $safe() on $chan here because since your on text event listen on any channel, the value of $chan cannot be known beforehand and that can be exploited.

You should also use the 'n' switch on your $read and $readini, otherwise mIRC actually evaluates the content of the line being read as code, that can be dangerous as well.

Last edited by Wims; 15/12/14 11:43 AM.
Re: /writeini issue [Re: HappyFappy] #255598 08/11/15 12:19 PM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
I applogize for digging up an old topic. I am currently having issues getting the writeini to function properly within this script, even when following the advice given in this thread. I have even changed the writeini in the code to use the exact name and numbers rather than variables, just to see if it would work, but it still does not actually write to the .ini. The writeini at the beginning of the script does work, but it's the " writeini rouldata.ini %nick Money %money.win " that does not seem to want to write to the file at all, even when I change both %nick and %money.win to actual data rather than the variables that I want to write. Any help would be appreciated.

Code:
on *:text:!roulette*:#mychannel: {  
  if ($readini( rouldata.ini, $nick, Money ) == $null) { msg $chan $nick you don't have credits! | halt }
  if ($3 !isnum) { msg $chan You can only bet numerical values. | Halt }
  if ($left($3,1) == $chr(45)) { msg $chan You can not use negative numbers $nick | halt }
  if ($3 <= 0) { msg $chan Please use a positive number. | halt }
  if ($3) && ($readini( rouldata.ini, $nick, Money ) < $3) { msg $chan You can not wager that much $nick as you only have $chr(36) $+ ($readini( rouldata.ini, $nick, Money ) $+ . | halt }
  if ($2 == Red || $2 == Black || $2 == Odd || $2 == Even || $2 == Row1 || $2 == Row2 || $2 == Row3 || $2 == Column1 || $2 == Column2 || $2 == Column3 || $2 isnum 0-36) {
    {
      if (%rltimer != on) { 
        set %rltimer on 
        msg # You now have 60 seconds to place your bets 
        timer 1 60 msg # Betting is now off 
        timer 1 60 unset %rltimer
        timer 1 60 /spin $chan $nick
      }
      msg $chan Your bet has been added to the table!
      write bets.txt $nick $2 $3
      set %money.bet $calc( $readini( rouldata.ini, $nick , Money ) - $3)
      writeini rouldata.ini $nick Money %money.bet
      unset %money.bet
    }
  }
  else { msg $chan That is not a valid bet, try !roulette red 1000 }
}
alias spin { 
  set %num = $rand(0,36)
  msg $1 The Roulette spins and lands on %num
  if (%num == 0) { var %bets = 0 }
  if (%num == 1) { var %bets = 1 red odd row1 column1 }
  if (%num == 2) { var %bets = 2 black even row2 column1 }
  if (%num == 3) { var %bets = 3 red odd row3 column1 }
  if (%num == 4) { var %bets = 4 black even row1 column1 }
  if (%num == 5) { var %bets = 5 red odd row2 column1 }
  if (%num == 6) { var %bets = 6 black even row3 column1 }
  if (%num == 7) { var %bets = 7 red odd row1 column1 }
  if (%num == 8) { var %bets = 8 black even row2 column1 }
  if (%num == 9) { var %bets = 9 red odd row3 column1 }
  if (%num == 10) { var %bets = 10 black even row1 column1 }
  if (%num == 11) { var %bets = 11 black odd row2 column1 }
  if (%num == 12) { var %bets = 12 red even row3 column1 }
  if (%num == 13) { var %bets = 13 black odd row1 column2 }
  if (%num == 14) { var %bets = 14 red even row2 column2 }
  if (%num == 15) { var %bets = 15 black odd row3 column2 }
  if (%num == 16) { var %bets = 16 red even row1 column2 }
  if (%num == 17) { var %bets = 17 black odd row2 column2 }
  if (%num == 18) { var %bets = 18 red even row3 column2 }
  if (%num == 19) { var %bets = 19 red odd row1 column2 }
  if (%num == 20) { var %bets = 20 black even row2 column2 }
  if (%num == 21) { var %bets = 21 red odd row3 column2 }
  if (%num == 22) { var %bets = 22 black even row1 column2 }
  if (%num == 23) { var %bets = 23 red odd row2 column2 }
  if (%num == 24) { var %bets = 24 black even row3 column2 }
  if (%num == 25) { var %bets = 25 red odd row1 column3 }
  if (%num == 26) { var %bets = 26 black even row2 column3 }
  if (%num == 27) { var %bets = 27 red odd row3 column3 }
  if (%num == 28) { var %bets = 28 black even row1 column3 }
  if (%num == 29) { var %bets = 29 black odd row2 column3 }
  if (%num == 30) { var %bets = 30 red even row3 column3 }
  if (%num == 31) { var %bets = 31 black odd row1 column3 }
  if (%num == 32) { var %bets = 32 red even row2 column3 }
  if (%num == 33) { var %bets = 33 black odd row3 column3 }
  if (%num == 34) { var %bets = 34 red even row1 column3 }
  if (%num == 35) { var %bets = 35 black odd row2 column3 }
  if (%num == 36) { var %bets = 36 red even row3 column3 }
  var %count = 1
  while ($read(bets.txt, %count) != $null) {
    var %nick = $wildtok($read(bets.txt, %count), *, 1, 32)
    var %bet = $wildtok($read(bets.txt, %count), *, 2, 32)
    var %ammount = $wildtok($read(bets.txt, %count), *, 3, 32)
    if (%bet isin %bets) {
      if (%bet == red || %bet == black || %bet == Odd || %bet == Even) {
        set %money.win $calc( $readini( rouldata.ini, %nick , Money ) + (%ammount *2))
        writeini rouldata.ini %nick Money %money.win
        unset %money.win
      }
      if (%bet == Row1 || %bet == Row2 || %bet == Row3 || %bet == Column1 || %bet == Column2 || %bet == Column3) { 
        set %money.win $calc( $readini( rouldata.ini, %nick , Money ) + (%ammount * 3))
        writeini rouldata.ini %nick Money %money.win
        unset %money.win
      }
      if (%bet == 0 || %bet == 1 || %bet == 2 || %bet == 3 || %bet == 4 || %bet == 5 || %bet == 6 || %bet == 7 || %bet == 8 || %bet == 9 || %bet == 10 || %bet == 11 || %bet == 12 || %bet == 13 || %bet == 14 || %bet == 15 || %bet == 16 || %bet == 17 || %bet == 18 || %bet == 19 || %bet == 20 || %bet == 21 || %bet == 22 || %bet == 23 || %bet == 24 || %bet == 25 || %bet == 26 || %bet == 27 || %bet == 28 || %bet == 29 || %bet == 30 || %bet == 31 || %bet == 32 || %bet == 33 || %bet == 34 || %bet == 35 || %bet == 36) {
        set %money.win $calc( $readini( rouldata.ini, %nick , Money ) + (%ammount * 37))
        writeini rouldata.ini %nick Money %money.win
        unset %money.win
      }
    }
    inc %count
  }
  msg $1 All other bets were lost, better luck next time!
  remove bets.txt
}