Jump to content

Votekick Code Not Working


RashedHammad

Recommended Posts

 

 

This code works uncompletely as it starts timers activated , But after 55 seconds from voting no warning message appear and the timers halted and no kicking occure , no %voting counting , so what's the wrong

 

on *:text:!votekick*:*: {
  if $nick isop $chan {
    if %vote != 0 {
      msg $chan There is a voting running already
      halt
    }
    if $2 == $me {
      msg $chan I won't start a votekick on myself, $nick $+ ...
    }
    else {
      if $2 ison $chan {
        set %vote $chan
        msg $chan  $+ $nick has started a votekick against $2
        msg $chan Type !vote yes/no to vote for/against the kick
        msg $chan You can only vote one time and you have [60] seconds to do so

        timer 1 55 _warning $chan
        timer 1 60 _vote $chan
        set %victim $2
      }
      else {
        msg $chan I don't see $2 in $chan $+ ?!
      }
    }
  }
  else {
    msg $chan You do not have permission to do start a votekick!
  }
}

on *:nick: {
  if $nick == %victim && %vote != 0 {
    msg %vote There's no way to hide, $newnick $+ !
    set %victim $newnick
  }
}

on *:text:!vote*:*: {
  if $read(votekick.txt,s,$address) {
    msg $chan You have voted already, $nick $+ !
  }
  else {
    if $2 == $null {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        msg $chan Syntax: !vote yes/no
      }
    }   
    elseif $2 == yes {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        inc %yes
        write votekick.txt $address $address
      }
    }
    elseif $2 == no {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        inc %no
        write votekick.txt $address $address
      }
    }
    else {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        msg $chan Syntax: !vote yes/no
      }
    }
  }
}

on *:text:!victim*:*: {
  if %vote == 0 {
    msg $chan No voting running at the moment
  }
  else {
    msg $chan The current votekick victim is %victim
  }
}

alias _warning {
  if %vote != 0 {
    msg $1 5 seconds remaining
  }
}

alias _vote {
  if %vote != 0 {
    var %total = $calc(%yes + %no)
    var %yes-p = $round($calc(%yes / %total * 100),2)
    var %no-p = $round($calc(%no / %total * 100),2)

    msg $1 The vote is over! The victim was %victim
    msg $1 Total votes: %total - Yes: %yes ( $+ %yes-p $+ $chr(37) $+ ) - No: %no ( $+ %no-p $+ $chr(37) $+ )

    if %yes > %no {
      kick $1 %victim votekicked
    }
    else {
      msg $1 You are lucky this time, %victim;)
    }

    set %vote 0
    set %yes 0
    set %no 0
    unset %all
    remove votekick.txt
  }
}


on *:text:!stopvoting:*: {
  if %vote == 0 {
    msg $chan No voting running at the moment
  }
  else {
    if $nick isop $chan {
      set %vote 0
      set %yes 0
      set %no 0
      unset %all
      remove votekick.txt
      msg $chan The voting has been stopped by $nick
    }
    else {
      msg $chan You do not have permission to stop the voting!
    }
  }
}

Link to comment
Share on other sites

I haven't tested it out, but I did notice you had two on text events pertaining to looking for the text !vote. This could be messing up your code. Try this...

 

on *:nick: {
  if $nick == %victim && %vote != 0 {
    msg %vote There's no way to hide, $newnick $+ !
    set %victim $newnick
  }
}

on *:text:!vote*:*: {
  if $read(votekick.txt,s,$address) {
    msg $chan You have voted already, $nick $+ !
  }
  else {
    if $2 == $null {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        msg $chan Syntax: !vote yes/no
      }
    }  
    elseif $2 == yes {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        inc %yes
        write votekick.txt $address $address
      }
    }
    elseif $2 == no {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        inc %no
        write votekick.txt $address $address
      }
    }
    else {
      if %vote == 0 {
        msg $chan No voting running at the moment
      }
      else {
        msg $chan Syntax: !vote yes/no
      }
    }
  }
  if *kick iswm $1 {
    if $nick isop $chan {
      if %vote != 0 {
        msg $chan There is a voting running already
        halt
      }
      if $2 == $me {
        msg $chan I won't start a votekick on myself, $nick $+ ...
      }
      else {
        if $2 ison $chan {
          set %vote $chan
          msg $chan  $+ $nick has started a votekick against $2
          msg $chan Type !vote yes/no to vote for/against the kick
          msg $chan You can only vote one time and you have [60] seconds to do so
          timer 1 55 _warning $chan
          timer 1 60 _vote $chan
          set %victim $2
        }
        else {
          msg $chan I don't see $2 in $chan $+ ?!
        }
      }
    }
    else {
      msg $chan You do not have permission to do start a votekick!
    }
  }
}

on *:text:!victim*:*: {
  if %vote == 0 {
    msg $chan No voting running at the moment
  }
  else {
    msg $chan The current votekick victim is %victim
  }
}

alias _warning {
  if %vote != 0 {
    msg $1 5 seconds remaining
  }
}

alias _vote {
  if %vote != 0 {
    var %total = $calc(%yes + %no)
    var %yes-p = $round($calc(%yes / %total * 100),2)
    var %no-p = $round($calc(%no / %total * 100),2)

    msg $1 The vote is over! The victim was %victim
    msg $1 Total votes: %total - Yes: %yes ( $+ %yes-p $+ $chr(37) $+ ) - No: %no ( $+ %no-p $+ $chr(37) $+ )

    if %yes > %no {
      kick $1 %victim votekicked
    }
    else {
      msg $1 You are lucky this time, %victim;)
    }

    set %vote 0
    set %yes 0
    set %no 0
    unset %all
    remove votekick.txt
  }
}


on *:text:!stopvoting:*: {
  if %vote == 0 {
    msg $chan No voting running at the moment
  }
  else {
    if $nick isop $chan {
      set %vote 0
      set %yes 0
      set %no 0
      unset %all
      remove votekick.txt
      msg $chan The voting has been stopped by $nick
    }
    else {
      msg $chan You do not have permission to stop the voting!
    }
  }
}

Link to comment
Share on other sites

Naw warrior, the way he had it setup is if it says !votekick the first event will get it. And as you know the second matching text event in the file will not execute at that moment. Only the first.

 

But if it is !vote or !votewhatever, well naturally it wont match the !votekick event but it does match in the next text event !vote.

 

Rashed, I don't see anywhere in your script anything about a 55 second limit.

 

I also don't understand how you start the vote. That is where you should begin. When you start a vote set a timer for 55 seconds that triggers the _vote alias.

 

Can you help me see where you start voting please?

Link to comment
Share on other sites

Naw warrior, the way he had it setup is if it says !votekick the first event will get it. And as you know the second matching text event in the file will not execute at that moment. Only the first.

 

But if it is !vote or !votewhatever, well naturally it wont match the !votekick event but it does match in the next text event !vote.

 

Exactly, lol. That was what I was trying to convey, and is why I merged the !votekick code with the other on text event. I didn't get to look over all the code, but from what I've seen it looks like some things are indeed missing like what Travis said.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...