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.

One game at a time; disabling text triggers

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
M
MMushroom
Voice
Posts: 2
Joined: Mon Feb 28, 2011 4:28 pm

One game at a time; disabling text triggers

Post by MMushroom »

Hello,

Sometime ago I had great success running different irc games like Trivia and Uno so I've decided to make it full time uptime by setting up an eggdrop with such scripts.
Since our channel is public, lately we had a couple of trolls coming and ruining our fun by triggering multiple games at once - when we played trivia they triggered uno or hangman, etc.
It got me so frustrated that I had to revert back to mIrc scripts and only enable single game at a time.

My request is if it's possible to make a script that would disable triggering the other games while a certain one is played.

I was thinking about something like this:
When bot says the words " Starting the trivia...." it would set a counter. Then when another trigger is typed (!uno) it would do nothing, because a counter is set. Then when bot finishes a game by saying " Stopping the trivia..." the counter is set to 0 and other triggers to start the games can be used again.
Is that possible?

My TCL and MSL scripting knowledge is pretty much null and I failed miserably when I tried to make this script for mIrc at least.
Thank you for all your help in advance.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

With a simple 'setudef int game' and define 0 = no game is active, 1 = trivia, 2 = hangman and 3 = uno (or whatever order you wish) you can achieve this goal.

Get the active running game (if any) with '[channel get #channel game]' you get an integer number representing the current running game (if any).

Then in trivia for instance, at the '!start' proc add a line like:

Code: Select all

# will block the start of the game
if {[channel get $chan game] != 1} return

# since no game is active, we let them start this game
if {![channel get $chan game]} {
channel set $chan game 1
}
and at the '!stop' proc:

Code: Select all

# if the 'trivia' game is the current game running we stop it and allow other games to be started
if {[channel get $chan game] == 1} {
channel set $chan game 0
}
And similar lines added to other games, the only difference is the number defining the game. Be sure to replace '$chan' with the actual variable representing the channel and drop a message if you get stuck or you don't understand anything from what I wrote above. :D
Once the game is over, the king and the pawn go back in the same box.
M
MMushroom
Voice
Posts: 2
Joined: Mon Feb 28, 2011 4:28 pm

Post by MMushroom »

Hey caesar, thanks for your quick reply.
If I understood it right I have to write "setudef int game" somewhere in the script too? Now, I've tried this with around 3 different trivias, Marky's color uno and Crack the code script, before I gave up. Nothing worked for me and I don't know what I was doing wrong. I searched for the start and stop processes and inserted the code there, but when I started my bot the scripts suddenly stopped working and did not want to start even. Basically they weren't responding to !trivia nor !uno nor !ctc nor any start command.

I'll copy-paste the part of Marky's color uno script code and please correct me what I am doing wrong. :)
(notice: the start proc is after the stop so I've put setudef here)

Code: Select all

#
# stop a game
#
setudef int game
proc UnoStop {nick uhost hand chan txt} {
 global UnoOn UnoPaused UnPlayedRounds UnoStartTimer UnoSkipTimer UnoCycleTimer UnoLastWinner UnoWinsInARow
 
 if {(![uno_ischan $chan])||($UnoOn == 0)} {return}
# if the 'trivia' game is the current game running we stop it and allow other games to be started 
 if {[channel get $UnoChan game] == 1} { 
 channel set $UnoChan game 0 
 }

 catch {killutimer $UnoStartTimer}
 catch {killtimer $UnoSkipTimer}
 catch {killutimer $UnoCycleTimer}

 # remove player dcc list
 uno_removedccplayers

 set UnoOn 0
 set UnoPaused 0
 set UnPlayedRounds 0
 set UnoLastWinner ""
 set UnoWinsInARow 0

 UnoUnbindCmds

 UnoReset

 unochanmsg "stopped by $nick"

 return
}
And the start proc:

Code: Select all

#
# first entry
#
proc UnoInit {nick uhost hand chan txt} {
 global UnoOn

 if {(![uno_ischan $chan])||($UnoOn > 0)} {return}

# will block the start of the game 
 if {[channel get $UnoChan game] != 1} return 

# since no game is active, we let them start this game 
 if {![channel get $UnoChan game]} { 
 channel set $UnoChan game 1 
 }
 #unochanmsg "$nick\!$uhost"
 set UnoOn 1
 UnoBindCmds
 UnoNext
 return
}


Desperate call for help.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Put the

Code: Select all

setudef int game
line in just one of the files at the top, then in the 'uno' game (defined as 1st game):

Code: Select all

proc UnoStart {nick uhost hand chan txt} {
# will block the start of the game cos another game is already running
if {![channel get $chan game]} return

# no game is started so we start this one
channel set $chan game 1
[...]
as for stop:

Code: Select all

proc UnoStop {nick uhost hand chan txt} {
# will block the stop of the game cos this game isn't the one that's currently running
if {[channel get $chan game] != 1} return

# will stop the game and allow any (including this one) game to be started
channel set $chan game 0
[...]
At 'trivia' game (defined as 2nd game):

Code: Select all

proc TriviaStart {nick uhost hand chan txt} {
# will block the start of the game cos another game is already running
if {![channel get $chan game]} return

# no game is started so we start this one
channel set $chan game 2
[...]
as for stop:

Code: Select all

proc TriviaStop {nick uhost hand chan txt} {
# will block the stop of the game cos this game isn't the one that's currently running
if {[channel get $chan game] != 2} return

# will stop the game and allow any (including this one) game to be started
channel set $chan game 0
[...]
Hope it makes more sense now. :)
Once the game is over, the king and the pawn go back in the same box.
Post Reply