egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CT-VoteKick

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Mon Mar 15, 2021 8:00 pm    Post subject: CT-VoteKick Reply with quote

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

Still in Beta
Code:

########################
# 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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Tue Mar 16, 2021 3:27 am    Post subject: Reply with quote

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(
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1138

PostPosted: Tue Mar 16, 2021 10:08 am    Post subject: Re: CT-VoteKick Reply with quote

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 !
Back to top
View user's profile Send private message
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Tue Mar 16, 2021 10:10 am    Post subject: Re: CT-VoteKick Reply with quote

willyw wrote:
What is $ctvk(on) ?

I missed this one Smile
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Tue Mar 16, 2021 2:12 pm    Post subject: Reply with quote

Still working, but i hope this is better Laughing
Code:

########################
# 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 Wink
_________________
ComputerTech


Last edited by ComputerTech on Tue Mar 16, 2021 6:51 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Tue Mar 16, 2021 6:39 pm    Post subject: Reply with quote

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.
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Tue Mar 16, 2021 6:43 pm    Post subject: Reply with quote

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 Laughing

Ok so i "think" the above code edit should work, will see in a bit Razz
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber