mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
To start of with, this is my first script, so it isn't optimized.
I'm trying to make a sort of First Death, betting system. Where if open, the person could bet on what boss or what exactly could kill me.

Commands:
!fd open
Opens first death "event"
!firstdeath*
Records $2 and $nick into an .ini file
!fd close
Closes bets
!fd*
Declares what killed me and gives points to whoever guess right.

The problem is that it will only add points to the person who typed !fd* (I.E. a moderator) and not for everyone who bet. Is there anyway to make it check every line instead of just one?

Code:
on *:TEXT:!fd open:#:{
  if ($nick isop #) {
    if (%firstdeath == 0) {
      msg $chan First death is open, chose the form of death!
      set %firstdeath 1
      write -c Firstdeath.ini
    }
    else {
      msg $chan First Death is already open. 
    }
  }
  else {
    msg $chan This command is for Mods only.
  }
}

on *:TEXT:!fd close:#:{
  if ($nick isop #) {
    if (%firstdeath == 1) {
      msg $chan First death is now closed.
      set %firstdeath 3
    }
    else {
      msg &chan First Death bets are not open. 
    }
  }
  else {
    msg $chan This command is for Mods only.
  }
}

on *:TEXT:!firstdeath*:#:{
  if (%firstdeath == 1) {
    var %boss = $2
    writeini Firstdeath.ini $nick Boss $2
    msg $chan $nick You chose $readini(Firstdeath.ini, $nick, Boss)
  }
  else {
    msg $chan First death has already been claimed, but bets are still open. 
  }
}

on *:TEXT:!fd*:#:{
  if ($nick isop #) {
    if (%firstdeath == 3) {
      if ($readini(Firstdeath.ini, $nick, Boss) == $2) {
        msg $chan YOU WIN!
        set %firstdeath 0
        writeini -n Dinocoins.ini $+(#,.,$nick) dinocoins $calc($readini(Dinocoins.ini,$+(#,.,$nick),dinocoins) + 50)
        msg $chan $nick now has $readini(Dinocoins.ini,$+(#,.,$nick),dinocoins) Dino coins.
        write -c Firstdeath.ini
      } 
      else {
        msg $chan $nick Sorry
        msg $chan Winning boss is $2
      }
    }
    else {
      msg $chan You must close First Death first. 
    }
  }
  else {
    msg $chan This command is for Mods only
  }
}

Last edited by Newbie; 24/11/14 03:30 PM.
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Can anyone help, the problem is that it only checks for the person who types !fd* and not everyone else. Is there a way to make the $readini read more than one line?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
In your "!fd*" event you're looking for
Code:
      if ($readini(Firstdeath.ini, $nick, Boss) == $2)
which will only be true if the user typing it was the one who wrote it. You're searching for the $nick of the user as the topic as well as the limit to ops only in the script. No other users than ops will be able to trigger that far into the script.

I re-designed your script a bit while still trying to keep to your same style of scripting
Code:
on *:text:!fd &:#: {
  var %file firstdeath.ini
  if (!%firstdeath) {
    if ($2 != open) msg # First Death is currently not active, it needs to be opened first.
    elseif ($nick !isop #) msg # This command is for mods only. 
    else {
      msg # First Death is open, choose the form of first death.
      remini %file #
      set %firstdeath 1
    }
  }
  elseif (%firstdeath == 1) { 
    writeini %file # user $nick
    writeini %file # boss $2
    msg # You chose $2
    set %firstdeath 2
  }
  elseif (%firstdeath == 2) {
    if ($2 != close) msg # First Death is currently not active, it needs to be closed first.
    elseif ($nick !isop #) msg # This command is for mods only. 
    else {
      msg # First Death is now closed
      set %firstdeath 3
    }
  }
  elseif (%firstdeath == 3) { 
    if ($2 == $readini(%file,#,boss)) { 
      msg # YOU WIN! $2 was correct, $readini(%file,#,user) was the one who chose it. 
      unset %firstdeath
      writeini -n Dinocoins.ini $+(#,.,$nick) dinocoins $calc($readini(Dinocoins.ini,$+(#,.,$nick),dinocoins) + 50)
      msg # $nick now has $readini(Dinocoins.ini,$+(#,.,$nick),dinocoins) Dino coins.
    }
    else msg # Sorry, $2 was not correct.
  }
} 

You'll have to tell me what you mean by "reading more than one line" Do you want to add dinocoins to people who guess, even though it's wrong? The way I scripted it now won't check for op status in the channel, so whoever guesses right will receive the dinocoins boost.


Quote:
[19:38] <@nillens> !fd test
[19:38] <@nillensbot> First Death is currently not active, it needs to be opened first.
[19:38] <@nillens> !fd open
[19:38] <@nillensbot> First Death is open, choose the form of first death.
[19:38] <@nillens> !fd Chainsaw
[19:38] <@nillensbot> You chose Chainsaw
[19:38] <@nillens> !fd test
[19:38] <@nillensbot> First Death is currently not active, it needs to be closed first.
[19:38] <@nillens> !fd close
[19:38] <@nillensbot> First Death is now closed
[19:39] <@nillens> !fd guess
[19:39] <@nillensbot> Sorry, guess was not correct.
[19:39] <@nillens> !fd chainsaw
[19:39] <@nillensbot> YOU WIN! chainsaw was correct, nillens was the one who chose it.
[19:39] <@nillensbot> nillens now has 50 Dino coins.
Tested and working.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Thanks for the reply, but no unfortunately this isn't what I was looking for.

So the way I want it to work is that when the event is open, everyone watching can place a bet by typing !fd choice. This will store their $nick and boss into the Firstdeath.ini. Once I have died, I type in !fd killer and if !fd killer = !fd choice then everyone who got it right will get a set amount of Dinocoins (points).

Last edited by Newbie; 28/11/14 07:17 PM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
on *:text:!fd &:#: {
  var %file firstdeath.ini
  if (!%firstdeath) {
    if ($2 != open) msg # First Death is currently not active, it needs to be opened first.
    elseif ($nick !isop #) msg # This command is for mods only. 
    else {
      msg # First Death is open, choose the form of first death.
      write -c %file
      set %firstdeath 1
    }
  }
  elseif (%firstdeath == 1)  {
    if ($2 != close) writeini %file $2 $nick 1
    else { 
      if ($nick !isop #) msg # This command is for mods only.
      else { 
        msg # First Death is closed.
        set %firstdeath 2
      }
    }
  }
  elseif (%firstdeath == 2) { 
    if ($nick !isop #) msg # This command is for mods only 
    else {
      var %winners $ini(%file,$2,0)
      while (%winners) {
        var %winner $ini(%file,$2,%winners)
        var %wins %wins %winner
        writeini -n Dinocoins.ini $+(#,.,%winner) dinocoins $calc($readini(Dinocoins.ini,$+(#,.,%winner),dinocoins) + 50)
        dec %winners
      }
      msg # The winners are: %wins - All received 50 dinocoins.
      unset %firstdeath
    }
  } 
}


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Thank you so much! I guess I never thought about setting the topic as the form of death instead of the nickname. Thanks again!


Link Copied to Clipboard