# Minecraft Server Scripts by enfyrneaux

# The Spam Contest

# Requires the screen utility, make sure the server is running

# with "mcserver" as the screen process handle.

# This script is designed to be called as a cron job every 12 hours, for twice daily contests.

duration =$ [ ( $RANDOM % ( 12 * 60 * 60 ) ) ]

hours =$ [ $duration / 3600 ]

echo Approximately $hours hours to spam contest...

sleep $duration

#Change "mcserver" to the appropriate screen process handle if need be

process = ` screen -ls | grep -o "[0-9].*mcserver" `

duration =$ [ ( $RANDOM % 20 ) + 20 ]

screen -x $process -X stuff " `printf "say NOTICE: Impending spam contest.\r"` "

sleep 120

screen -x $process -X stuff " `printf "save-all\r"` "

screen -x $process -X stuff " `printf "say !!!SPAM CONTEST TIME!!!.\r"` "

sleep 5

screen -x $process -X stuff " `printf "say !!!SPAM CONTEST TIME!!!.\r"` "

sleep 5

screen -x $process -X stuff " `printf "say !!!SPAM CONTEST TIME!!!.\r"` "

sleep 5

screen -x $process -X stuff " `printf "say Say stuff in chat, win random prizes! You have $duration seconds!\r"` "

sleep $duration

# Only tallies user chats

winners = ` tail -n 100 server.log | grep -o "<.*>" | sed "s/<//" | sed "s/>//" `

echo $winners

screen -x $process -X stuff " `printf "say Time is up! Contest is twice daily at random!\r"` "

# loop through the winners, dangerously doling out random items.

for x in $winners

do

prize =$ [ ( $RANDOM % 357 ) + 14 ] #To avoid handing out obsidian or adminium, or records

screen -x $process -X stuff " `printf "give $x $prize\r"` "

#echo give $x $prize