This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

CT-VoteKick

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

CT-VoteKick

Post by ComputerTech »

Just wanted to make a fun script, so i made a VoteKick script. :P

Still in Beta

Code: Select all

########################
# CT-Votekick  0.1
########################
# ComputerTech
# 16/03/21
########################

# Set flags of script usage
set ctvk(flag) "ofmn"

# Set trigger 
set ctvk(trig) "!votekick"

# Set X time (in seconds) before Vote times out
set ctvk(time) "180"

# Set Votes needed to kick target
set ctvk(max) "3"

# Set Kick reason
set ctvk(reason) "VoteKick!"



bind pub $ctvk(flag) $ctvk(trig) main:proc

proc main:proc {nick host hand chan text} {
global ctvk
 if {[lindex [split $text] 0] == ""} {
    puthelp "PRIVMSG $chan :\0034Error\003 Syntax: $ctvk(trig) nick"
    return
}
 if {$ctvk(on)} {
  	puthelp "PRIVMSG $chan :\0034Error\003 A Vote is currently happening, please wait"
   	return
 }
 if {$ctvk(left) < $ctvk(max)} {
  incr ctvk(more) -1
  incr ctvk(left) 1
  puthelp "PRIVMSG $chan :Another Vote to Kick $ctvk(target) / $ctvk(more) More Votes Needed!"
 } else {
  puthelp "PRIVMSG $chan :\0039Vote Started\003 \007Target:\0032 $ctvk(target) \003 \0038$ctvk(more) Votes needed\003"
 utimer $ctvk(time) [list reset:vote $text]
 if {![info exists ctvk(left)] && [info exists ctvk(target)]} {
  set ctvk(target) [lindex [split $text] 0]
  set ctvk(left) $ctvk(max)
    }
  }
 if {$ctvk(left) > $ctvk(max)} {
 	putquick "KICK $chan $ctvk(target) :$ctvk(reason)"
 	unset ctvk(left) 
 	unset ctvk(target)
 }
}
proc reset:vote {text} {
unset ctvk(left) 
unset ctvk(ctvk(target) 
puthelp "PRIVMSG $chan :Vote Timed Out"
}
Suggestions are welcome :wink:
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I see different small things...

- What is ctvk(more) ? You increment it, you display it, but it's never defined

- You never check if target is on the chan ?

- You use ctvk(left) but you initialize it after ?

- what happen if I do !votekick foo, !votekick foo, !votekick ComputerTech ? Three votes, but you are kicked, you don't distribute voices to the victim. The third vote is the only one which is important.

- Syntax error @ unset ctvk(ctvk(target) <-- a closing parenthesis lacking or redundant ctvk(
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: CT-VoteKick

Post by willyw »

What is $ctvk(on) ?

I have not tried to run this script. But a text search of this page finds it only once. So that means it is never set.
Are you not getting an error in the partyline ?


Also (again, I haven't run it) , I curious about something.
Suppose enough votes come in quickly to kick a nick.
Then:
unset ctvk(left)
unset ctvk(target)

Now what happens when the utimer triggers?
The proc it calls also tries to unset (see the typo in that proc, already mentioned earlier by CrazyCat) those same variables.
Are you not getting errors in the partyline, because those variables no longer exist?
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: CT-VoteKick

Post by CrazyCat »

willyw wrote:What is $ctvk(on) ?
I missed this one :)
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Still working, but i hope this is better :lol:

Code: Select all

########################
# CT-Votekick  0.2
########################
# ComputerTech
# 16/03/21
########################

# Set flags of script usage
set ctvk(flag) "ofmn"

# Set trigger
set ctvk(trig) "!votekick"

# Set X time (in seconds) before Vote times out
set ctvk(time) "180"

# Set Votes needed to kick target
set ctvk(max) "3"

# Set Kick reason
set ctvk(reason) "VoteKick!"


########################
bind pub $ctvk(flag) $ctvk(trig) main:proc

proc main:proc {nick host hand chan text} {
global ctvk
if {!$ctvk(on) } {
 if {[lindex [split $text] 0] == ""} {
    puthelp "PRIVMSG $chan :\0034Error\003 Syntax: $ctvk(trig) nick"
    return
  }
}
 if {![info exists ctvk(on)]} {
	set ctvk(on) "1"
} elseif {![info exists ctvk(target)]} {
 	set ctvk(target) [lindex [split $text] 0]
} elseif {![info exists ctvk(left)]} {
  set ctvk(left) $ctvk(max)
} elseif {![onchan $ctvk(target) $chan]} {
	return
}
 if {$ctvk(on)} {
     puthelp "PRIVMSG $chan :\0034Error\003 A Vote is currently happening, please wait"
      return
 }
if {!$ctvk} {
 if {$ctvk(on) > 1} {
  incr ctvk(left) -1
  if {$ctvk(on) == 1} {
  puthelp "PRIVMSG $chan :\0039Vote Started\003 \007Target:\0032 $ctvk(target) \003 \0038$ctvk(left) Votes needed\003"
set ctvk($host) 1
 utimer $ctvk(time) [list reset:vote $chan $text]
  set ctvk(on) 2
 } else {
  puthelp "PRIVMSG $chan :Another Vote to Kick $ctvk(target) / $ctvk(left) More Votes Needed!"
set ctvk($host) 1
  }
}
} else {
putserv "PRIVMSG $chan :$nick has already voted"
return
}
 if {$ctvk(left) < 1} {
    putquick "KICK $chan $ctvk(target) :$ctvk(reason)"
    unset ctvk(left)
    unset ctvk(target)
    unset ctvk(on)
    unset ctvk($host)
  }
}
proc reset:vote {host chan text} {
unset ctvk(left)
unset ctvk(target)
unset ctvk(on)
unset ctvk($host)
puthelp "PRIVMSG $chan :Vote Timed Out"
}
Will test when i get home

EDIT

I "Think" this will restrict only one vote per user by $host will need to test after dinner ;)
Last edited by ComputerTech on Tue Mar 16, 2021 6:51 pm, edited 2 times in total.
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Quickly read, it's late...

But you seems to always have your target trouble: the first votant choose a target, others must choose a target too but only the first target is the victim.

This is not a vote.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

CrazyCat, thats how the VoteKick script works, only the first votant can choose the target, but i do see i need to add a way to restrict One vote per $host per Vote :lol:

Ok so i "think" the above code edit should work, will see in a bit :P
ComputerTech
Post Reply