//ServBot GUI by erik //idea by DeathStar editbind q [showgui ServBot] bind q [showgui ServBot] //---DEFINITIONS---// commands = ["takemaster" "test" "commands" "mmvote" "register" "savetemp" "deltemp" "listtemps" "sendtemp"] registerclients = [] tempmaplist = "" tempvar = -2 uvar = "" mmvote = "" votes0 = 0 votes1 = 0 votes2 = 0 votes3 = 0 delclientvar = -2 addclientvar = -2 mmvotereset = [ votes0 = 0 votes1 = 0 votes2 = 0 votes3 = 0 ] docommand = [ if (&& (strcmp $uvar) (>= (indexof $commands (getclientname $arg2)) 0)) [ tempvar = @arg2;do [namecmd_@@arg1 @@arg2];uvar = -1 ] [ if (= (indexof $commands (getclientname $tempvar)) -1) [uvar = "";tempvar = -2] ] ] clientsave = [ if (strcmp 1 1) [ loop a (listlen (listclients)) [ docommand (indexof $commands (getclientname (at (listclients) $a))) (at (listclients) $a) loop b (listlen $trustedclients) [ loop c (listlen $registerclients) [ if (strcmp (at $trustedclients @b) (at $registerclients $c)) [ registerclients = (strreplace $registerclients (concatword (at $registerclients @c) " ")) ] ] if (&& (&& (> (getmastermode) 1) (ismaster (getclientnum))) (&& (strcmp (getclientname (at (listclients) @a)) (at $trustedclients $b)) (isspectator (at (listclients) @a)))) [ say (concatword "Unspecing trusted client ^"" (getclientname (at (listclients) @@a)) "^"" (if (strcmp (at $modenames (getmode)) coop) [result " and sending map"]) ".^n") spectator 0 (at (listclients) @@a) if (strcmp (at $modenames (getmode)) coop) [sleep 500 [sendmap]] ] ] loop b (listlen $registerclients) [ if (&& (&& (> (getmastermode) 1) (ismaster (getclientnum))) (&& (strcmp (getclientname (at (listclients) @a)) (at $registerclients $b)) (isspectator (at (listclients) @a)))) [ say (concatword "Unspecing registered client ^"" (getclientname (at (listclients) @@a)) "^".^n") spectator 0 (at (listclients) @@a) ] ] ] ] sleep 500 [ if (! (isconnected)) [connect 24.19.240.84 28785 TurboForceTableFan!;sleep 1000[say "Please do not disconnect the server bot.^n"]] //spectator 1 //for a hidden serverbot clientsave ] ] loopmsg = [ say "This is a temperary test of the cubescript ServerBot, An alternative to modded servers for people who cannot run mods on their servers for whatever reason." sleep 8000 [say "If you would like to be unspeced, use the command: '/name register'"] sleep 68000 [loopmsg] ] //---DEFINITIONS---// //----TRUSTED CLIENT CONTROLL----\\ addtrusted = [ if (strcmp $arg1 $addclientvar) [ addclientvar = -1 trustedclients = (concatword $trustedclients @arg1 " ") echo (concatword "^f2Client ^f0^"" @arg1 "^" ^f2has been confirmed, and has been added to the trusted clients list.") ] [ addclientvar = -2 ] if (= $addclientvar -2) [ loop a (listlen $trustedclients) [ if (strcmp (at $trustedclients $a) @@arg1) [ addclientvar = -1 echo (concatword "^f3Error: ^f2cannot add client ^f0^"" @@@arg1 "^" ^f2to the list because s/he is already there.") ] ] ] if (= $addclientvar -2) [ loop a (listlen $trustedclients) [ if (strcmp (at $trustedclients $a) (getclientname @@arg1)) [ addclientvar = -1 echo (concatword "^f3Error: ^f2cannot add client ^f0^"" (getclientname @@arg1) "^" ^f2to the list because s/he is already there.") ] ] ] if (= $addclientvar -2) [ loop a (listlen (listclients)) [ if (strcmp (getclientname (at (listclients) $a)) @@arg1) [ addclientvar = -1 trustedclients = (concatword $trustedclients @@@arg1 " ") echo (concatword "^f2Added ^f0^"" @@@arg1 "^" ^f2to the trusted clients list.") say (concatword "Added ^"" @@@arg1 "^" to the trusted clients list.^n") ] ] ] if (= $addclientvar -2) [ loop a (listlen (listclients)) [ if (strcmp (at (listclients) $a) @@arg1) [ addclientvar = -1 trustedclients = (concatword $trustedclients (getclientname @@@arg1) " ") echo (concatword "^f2Added ^f0^"" (getclientname @@@arg1) "^" ^f2to the trusted clients list.") say (concatword "Added ^"" (getclientname @@@arg1) "^" to the trusted clients list.^n") ] ] ] if (= $addclientvar -2) [ echo (concatword "^f2The client ^f0^"" @arg1 "^" ^f2is not on this server.^nType ^f7^"/addtrusted " @arg1 "^" ^f2again to confirm.") addclientvar = @arg1 sleep 2000 [ if (= $addclientvar @@arg1) [ addclientvar = -2 ] ] ] ] cleartrusted = [ if (> (listlen $trustedclients) 0) [ echo (concatword "^f2Removed all ^f0^(" (listlen $trustedclients) "^) ^f2trusted clients from the list.") trustedclients = [] ] [ echo "^f3Error: ^f2there are no trusted clients on the list." ] ] trusted = [ if (> (listlen $trustedclients) 0) [ echo (concatword "^f2Trusted clients are: ^f0" $trustedclients "^f2.") ] [ echo "^f3Error: ^f2there are no trusted clients on the list." ] ] deltrusted = [ if (strcmp $arg1 $delclientvar) [ echo (concatword "^f0" (at $trustedclients (- @arg1 1)) " ^f2has been removed from the trusted clients list.") say (concatword (at $trustedclients (- @arg1 1)) " has been removed from the trusted clients list.^n") trustedclients = (strreplace $trustedclients (concatword (at $trustedclients (- @arg1 1)) " ")) delclientvar = -1 ] [ delclientvar = -2 ] if (= $delclientvar -2) [ loop a (listlen $trustedclients) [ if (strcmp @@arg1 (at $trustedclients $a)) [ echo (concatword "^f0" @@@arg1 " ^f2has been removed from the trusted clients list.") say (concatword @@@arg1 " has been removed from the trusted clients list.^n") trustedclients = (strreplace $trustedclients (concatword @@@arg1 " ")) delclientvar = -1 ] ] ] if (= $delclientvar -2) [ loop a (listlen $trustedclients) [ if (strcmp @@arg1 (+ $a 1)) [ echo (concatword "^f2Are you sure you wan to remove client ^f7#" (+ @a 1) " ^f0^(" (at $trustedclients @a) "^) ^f2from the trusted clients?^nType ^f7 ^"/deltrusted " (+ @a 1) "^" ^f2to confirm.") delclientvar = @@@arg1 sleep 2000 [ if (= $delclientvar @@@@arg1) [ delclientvar = -2 ] ] ] ] ] ] //----TRUSTED CLIENT CONTROLL----\\ //---COMMANDS---// namecmd_0 = [ if (&& (&& (= (isspectator $arg1) 0) (= $takemastertoggle 1)) (ismaster (getclientnum))) [ //say (concatword "Please confirm your identity, client #" @arg1 ".") sleep 500 [ if (>= (indexof $trustedclients (getclientname @@arg1)) 0) [ tempvar = -1 say (concatword "Identity confirmed as ^"" (getclientname @@@arg1) "^".^n") //saycommand (concatword "/setmaster 0;say ^"Take master " (getclientname @@@arg1) ".^"") setmaster 0 ] [ say (concatword "Could not confirm your identity, client #" @@arg1 ".^n") ] tempvar = -2 ] ] ] namecmd_1 = [ if (= $testtoggle 1) [say (concatword "This is a command test started by client #" @arg1 "^n") ]] namecmd_2 = [ if (= $commandstoggle 1) [say (concatword "Current server commands are: " $commands "^n") ]] namecmd_3 = [ if (|| (! (= $mmvotetoggle 1)) (! (ismaster (getclientnum)))) [arg1 = -2] sleep 500 [ if (> (indexof $mmvote (concatword "c" @arg1)) -1) [ mmvote = (strreplace $mmvote (concatword (at $mmvote (indexof $mmvote (concatword "c" @@arg1))) " " (at $mmvote (+ (indexof $mmvote (concatword "c" @@arg1)) 1)) " ")) ] if (|| (|| (strcmp (getclientname @arg1) 0) (strcmp (getclientname @arg1) 1)) (|| (strcmp (getclientname @arg1) 2) (strcmp (getclientname @arg1) 3))) [ say (concatword "Client #" @@arg1 " voted for mastermode " (getclientname @@arg1) " ^(" (if (= (getclientname @@arg1) 0) [result "open"] [ if (= (getclientname @@@arg1) 1) [result "veto"] [ if (= (getclientname @@@@arg1) 2) [result "locked"] [ if (= (getclientname @@@@@arg1) 3) [result "private"] ] ] ]) "^)") mmvote = (concatword $mmvote "c" @@arg1 " " (getclientname @@arg1) " ") loop i (div (listlen $mmvote) 2) [ loop a 4 [ if (strcmp (at $mmvote (+ (* @i 2) 1)) $a) [ (concatword "votes" @a) = (+ (getalias (concatword "votes" @a)) 1) ] ] ] echo (concatword "^f2Votes for mastermode 0 are ^f0" $votes0 "^n^f2Votes for mastermode 1 are ^f0" $votes1 "^n^f2Votes for mastermode 2 are ^f0" $votes2 "^n^f2Votes for mastermode 3 are ^f3" $votes3 ) echo $mmvote loop a 4 [ if (>f (divf (getalias (concatword "votes" $a)) (listlen (listclients))) 0.5) [ mastermode @a mmvotereset mmvote = "" ] ] mmvotereset ] ] ] namecmd_4 = [ //say (concatword "Registry started for client #" $arg1 " Return your original name and wait for the registry process to be completed ^(up to 20 seconds^)^n") sleep 500 [ if (= (indexof $commands (getclientname @arg1)) -1) [ registerclients = (concatword $registerclients (getclientname @@arg1) " ") say (concatword (getclientname @@arg1) " has registered successfully.^n") ] [ say "Registry error, please try again^n" ] ] ] namecmd_5 = [ if (&& (&& (! (isspectator $arg1)) (= $savetemptoggle 1)) (strcmp (at $modenames (getmode)) "coop")) [ if (= (indexof $tempmaplist tempmap1) -1) [ savemap temp/tempmap1 say "Saved map as ^"tempmap1^"^n" tempmaplist = (concatword $tempmaplist "tempmap1 ") ] [ if (= (indexof $tempmaplist tempmap2) -1) [ savemap temp/tempmap2 say "Saved map as ^"tempmap2^"^n" tempmaplist = (concatword $tempmaplist "tempmap2 ") ] [ if (= (indexof $tempmaplist tempmap3) -1) [ savemap temp/tempmap3 say "Saved map as ^"tempmap3^"^n" tempmaplist = (concatword $tempmaplist "tempmap3 ") ] [ if (= (indexof $tempmaplist tempmap4) -1) [ savemap temp/tempmap4 say "Saved map as ^"tempmap4^"^n" tempmaplist = (concatword $tempmaplist "tempmap4 ") ] [ if (= (indexof $tempmaplist tempmap5) -1) [ savemap temp/tempmap5 say "Saved map as ^"tempmap5^"^n" tempmaplist = (concatword $tempmaplist "tempmap5 ") ] [ say "Could not save map ^(temp maps full^)^n" ] ] ] ] ] ] ] namecmd_6 = [ if (&& (= $deltemptoggle 1) (strcmp (at $modenames (getmode)) "coop")) [ sleep 500 [ if (< (indexof $tempmaplist (concatword tempmap (getclientname @@arg1))) 0) [ say (concatword "Error: Could not delete ^"tempmap" (getclientname @@@arg1) "^" ^(It does not exist?^)^n") ] [ tempmaplist = (strreplace $tempmaplist (concatword "tempmap" (getclientname @@@arg1) " ")) say (concatword "Deleted map ^"tempmap" (getclientname @@@arg1) "^"^n") ] ] ] ] namecmd_7 = [ if (&& (= $deltemptoggle 1) (strcmp (at $modenames (getmode)) "coop")) [ if (= (listlen $tempmaplist) 0) [ say "Error, no tempmaps saved on this server.^n" ] [ say (concatword "Client #" $arg1 ", maps are: " $tempmaplist "^n") ] ] ] namecmd_8 = [ if (&& (= $deltemptoggle 1) (strcmp (at $modenames (getmode)) "coop")) [ if (= (indexof $tempmaplist (mapname)) -1) [ if (= (listlen $tempmaplist) 0) [ say "Error, no tempmaps saved on this server.^n" ] [ say (concatword "Error, this map is not on the server. Try one of these: " $templist "^n") ] ] [ say (concatword "Sending " (mapname) "^n") sendmap ] ] ] //---COMMANDS---// //---GUI CONTROL---// commanddesc = [ " Allows trusted clients to take master from the server bot." " Just a one line command test." " Lists the current commands on the server." " Allows voting and tallies votes for mastermode." " Allows clients to register their name for limited privelages (such as unspec)." " Saves a temperary map in packages/temp (limit 5)." " Removes a temperary map. Warning: Will not delete the actual file (leads to backup files)." " Lists the temperary map files in packages/temp." " Sends the temperary map if it is on the tempmap list." ] help = 0 loop i (listlen $commands) [ (concatword (at $commands $i) "toggle") = 1 ] newgui "ServBot" [ guistayopen [ guitextbox "^t ^f2Servbot Control" 40 2 loop i (listlen $commands) [ guilist [ guitext "" cube guitextbox (at $commands @i) if (= (getalias (concatword (at $commands @i) "toggle")) 1) [ guibutton "^f0Enabled" [(concatword (at $commands @@i) "toggle") = 0] radio_on ] [ guibutton "^f4Disabled" [(concatword (at $commands @@i) "toggle") = 1] radio_off ] ] ] guitab "Clients" guilist [ guilist [ guitextbox "^f2^t Trusted^n" 19 loop i (listlen $trustedclients) [ guilist [ guibutton "^f7" [deltrusted (at $trustedclients @@i)] exit guitextbox (at $trustedclients @i) 17 ] ] ] guibar guilist [ guitextbox "^f2^t Registered^n" 19 loop i (listlen $registerclients) [ guilist [ guibutton "^f7" [addtrusted (at $registerclients @@i)] arrow_bw guibutton "^f7" [deltrusted (at $registerclients @@i)] exit guitextbox (at $registerclients @i) 17 ] ] ] ] guitab "Help" guitextbox "^t^t^f2Servbot Help" 40 2 guilist [ guilist [ loop i (listlen $commands) [ guibutton (concatword (if (= $help $i) [result "^f7"] [result "^f4"]) (at $commands $i)) $i cube ] ] guibar guitextbox (at $commanddesc $help) 16 help = (substr $guirolloveraction 0) ] ] ] //---GUI CONTROL---//