Bukz

next gen kick/ban menu concept

May 11th, 2011
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.48 KB | None | 0 0
  1. ///// SUMMARY /////
  2. //
  3. // Teamkills stat added to (pstat_score).
  4. // New native alias "onVoteEnd" - automatically executed when a pending vote passes or fails.
  5. // New command "curautoteam" - returns the server's "autoteam" state.
  6. // New command "addpunct" - injects CubeScript punctuation.
  7. // New command "curplayers" - returns the current number of players - works in singleplayer too.
  8. // New command "delmenu" - for deleting the contents of a CubeScript menu. // TODO - needs work, should accept a string argument to determine which menu to delete.
  9. // New scripted variable "votepending" - 0 if there is no vote currently pending, 1 if there is.
  10. // New admin menu - allows quick access to various server admin commands, and lists the current clients names/cn's and gives easy access to kick/ban/stats menus.
  11. // New kick/ban/reason menu - allows for easy voting against a specific target client - lists some basic info, predefined reasons as well as an area to enter custom reasons. (With access to actions such as kick/ban/forceteam/whois/spectate.)
  12. // New stats menu - allows quick access to the target client's stats (team, teamkills, flags, frags, deaths, score, etc.)
  13. //
  14. // Screenshots:
  15. //
  16. // http://i52.tinypic.com/29zsmf4.jpg // Admin menu (during a team mode)
  17. // http://i52.tinypic.com/2zqetyu.jpg // Kick/ban/reason menu (during a team mode, without admin status)
  18. // http://i56.tinypic.com/24fzki8.jpg // Stats menu (during BTDM)
  19. // http://i56.tinypic.com/30i7q5z.jpg // Kick/ban/reason menu (during a FFA mode, with admin status)
  20. // http://i55.tinypic.com/52ifmb.jpg  // Stats menu (during DM)
  21. //
  22.  
  23. ///// ENTITY.H ADDITIONS /////
  24. //
  25. // Line 389 needs to be changed to:
  26. //
  27. int frags, flagscore, deaths, points, tks; // Add an integer to count tks
  28.  
  29. // Line 416 needs to be changed to:
  30. //
  31. playerent() : curskin(0), clientnum(-1), lastupdate(0), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), deaths(0), points(0), tks(0), lastpain(0), lastvoicecom(0), clientrole(CR_DEFAULT),
  32.  
  33. ///// CLIENTGAME.CPP ADDITIONS/CHANGES /////
  34. //
  35. // Line 890 needs to be changed to:
  36. //
  37. if(pl==act || isteam(pl->team, act->team)) { act->frags--; act->tks++; } // Counter for pstat_score teamkills
  38.  
  39. // Adds this below line 915:
  40. //
  41. p_tks = pl->tks;
  42.  
  43. // Line 918 needs to be changed to:
  44. //
  45. formatstring(scorestring)("%d %d %d %d %d %d %s", p_flags, p_frags, p_deaths, p_points, pl ? pl->team : -1, p_tks, pl ? pl->name : "\"\"");
  46.  
  47. // Line 1,128 needs to be changed to:
  48. //
  49. player1->frags = player1->flagscore = player1->deaths = player1->lifesequence = player1->points = player1->tks = 0; // Reset player1's stats
  50.  
  51. // Line 1,129 needs to be changed to:
  52. //
  53. loopv(players) if(players[i]) players[i]->frags = players[i]->flagscore = players[i]->deaths = players[i]->lifesequence = players[i]->points = players[i]->tks = 0; // Reset other player's stats
  54.  
  55.  
  56. // voteresult - Function starting on line 1,440 needs to be changed to:
  57. //
  58. void voteresult(int v)
  59. {
  60.     if(curvote && v >= 0 && v < VOTE_NUM)
  61.     {
  62.         curvote->result = v;
  63.         curvote->millis = totalmillis + 5000;
  64.         conoutf(_("vote %s"), v == VOTE_YES ? _("passed") : _("failed"));
  65.         if(multiplayer(false)) audiomgr.playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH);
  66.         if(identexists("onVoteEnd")) execute("onVoteEnd"); // This is the bit that was added.
  67.     }
  68. }
  69.  
  70. // curautoteam - Returns the current server autoteam state.
  71. int curautoteam()   { return servstate.autoteam; }
  72.  
  73. COMMAND(curautoteam, ARG_IVAL);
  74.  
  75. ///// COMMAND.CPP ADDITIONS /////
  76. //
  77. // addpunct - Easily inject a string into various CubeScript punctuations
  78. void addpunct(char *s, char *type = "0")
  79. {
  80.     int t = atoi(type);
  81.     if(t > -1 && t < 6)
  82.     {
  83.         switch(t)
  84.         {
  85.             case 1:  defformatstring(o1)("[%s]", s);   result(o1); break; // echo (addpunct hello 1) // Output: [hello]
  86.             case 2:  defformatstring(o2)("(%s)", s);   result(o2); break; // echo (addpunct hello 2) // Output: (hello)
  87.             case 3:  defformatstring(o3)("$%s", s);    result(o3); break; // echo (addpunct hello 3) // Output: $hello
  88.             case 4:  result("\""); break;                                 // echo (addpunct "" 4)    // Output: "
  89.             case 5:  result("%");  break;                                 // echo (addpunct "" 5)    // Output: %
  90.             default: defformatstring(o4)("\"%s\"", s); result(o4); break; // echo (addpunct hello)   // Output: "hello"
  91.         }
  92.     }
  93. }
  94. // test = (concat echo (addpunct fov 3)); test // Output: 90.0
  95.  
  96. // curplayers - Returns the current # of players.
  97. void curplayers(void)
  98. {
  99.     defformatstring(output)("%d", (multiplayer(false) ? (players.length() + 1) : players.length()));
  100.     result(output);
  101. }
  102.  
  103. COMMAND(addpunct, ARG_2STR);
  104. COMMAND(curplayers, ARG_NONE);
  105.  
  106. ///// MENUS.CPP ADDITIONS /////
  107. //
  108. void delmenu(const char *name)
  109. {
  110.     if (!name) return;
  111.     gmenu *m = menus.access(name);
  112.     if (!m) return;
  113.     else menureset(m);
  114. }
  115.  
  116. COMMAND(delmenu, ARG_1STR);
  117.  
  118. ///// SCRIPTS.CFG ADDITIONS /////
  119. //
  120. if (! (checkalias votepending)) [ votepending = 0 ]
  121. if (! (checkalias onCallVote)) [ onCallVote = "" ]; if (! (strstr $onCallVote votepending)) [ add2alias onCallVote [ votepending = 1 ] ]
  122. if (! (checkalias onVoteEnd)) [ onVoteEnd = "" ]; if (! (strstr $onVoteEnd votepending)) [ add2alias onVoteEnd [ votepending = 0 ] ]
  123.  
  124. ///// SCRIPT /////
  125. //
  126. // Use /showmenu ad - against bots or while connected to a server to view the menu.
  127. //
  128. if (! (checkalias tmpKBR)) [ tmpKBR = "" ]; if (! (checkalias tmpVic)) [ tmpVic = "" ]; if (! (checkalias tmpKBP)) [ tmpKBP = "" ]; if (! (checkalias tmpKBMM)) [ tmpKBMM = 0 ]
  129.  
  130. selKBItem = [ tmpVic = (getalias arg1); tmpKBR = ""; showmenu rs ]
  131.  
  132. genKBItem = [
  133.   if (> $numargs 0) [
  134.     tmpArg1 = $arg1; tmpKArg = (concat selKBItem $tmpArg1)
  135.     if (curmodeattr team) [
  136.       menuitem (concatword (findpn $arg1) (c 2) " (" $arg1 ")" (c 5) " - " (c 4) (at (concat (concatword (c 3) CLA (c 4)) (concatword (c 1) RVSF (c 4))) (at (pstat_score $arg1) 4)) (c 5)) (addpunct $tmpKArg 2)
  137.     ] [
  138.       menuitem (concatword (findpn $arg1) (c 2) " (" $arg1 ")" (c 5)) (addpunct $tmpKArg 2)
  139.     ]
  140.   ]
  141. ]
  142.  
  143. genKBMenu = [ loop gbl (curplayers) [ if (&& (! (strcmp (findpn $gbl) "")) (!= (findcn $curname) $gbl)) [ genKBItem $gbl ] ] ]
  144.  
  145. refreshKBM = [ if (!= $arg1 0) [ closemenu rs; sleep 0 [ showmenu rs ] ] [ closemenu ad; sleep 0 [ showmenu ad ] ] ]
  146.  
  147. hasValidClients = [
  148.   hvcOutput = 0
  149.   loop hvl (curplayers) [ if (&& (! (strcmp (findpn $hvl) "")) (!= $hvl (findcn $curname))) [ hvcOutput = 1; break ] ]
  150.   result $hvcOutput
  151. ]
  152.  
  153. kickBanMenu = [
  154.   newmenu ad
  155.   menuinit [ delmenu; kickBanMenu ]
  156.   menuitem "Refresh list"    [ refreshKBM ]
  157.   menuitem "Remove all bans" [ removebans; refreshKBM ]
  158.   menuitemtextinput "Admin password: " "" [ tmpKBP = $arg1 ] 0 256
  159.   menuitem "Toggle admin status" [ if $connected [ if (currole) [ setadmin; echo you dropped admin status ] [ if (&& (strlen $tmpKBP) (! (strcmp $tmpKBP ""))) [ setadmin 1 $tmpKBP ] ]; refreshKBM ] ]
  160.   menuitem "Toggle autoteam" [ if $connected [ if (curautoteam) [ autoteam 0 ] [ autoteam 1 ]; refreshKBM ] ]
  161.   menuitemtextinput "Mastermode: " (getalias tmpKBMM) [ if (< $arg1 3) [ tmpKBMM = $arg1 ] [ echo (c 3)Error: (c 5)Valid range for mastermode is 0-2.; tmpKBMM = 0 ] ] 0 1
  162.   menuitem "Change mastermode" [ if (&& (< $tmpKBMM 3) (!= (curmastermode) $tmpKBMM)) [ if $connected [ mastermode $tmpKBMM ] ]; refreshKBM ]
  163.   menuitem "" -1
  164.   menuitem "OK" [ closemenu ad ]
  165.   menuitem "" -1
  166.   if (hasValidClients) [ menuitem "Choose a client: " -1 ] [ menuitem "No valid clients available." -1 ]
  167.   menuitem "" -1
  168.   genKBMenu
  169. ]
  170.  
  171. kickBanMenu
  172.  
  173. newmenu rs
  174. menuitemvar [ if (currole) [ concat (c 1)Note: (c 5)You currently have admin status. Your vote will be forced. ] ]
  175. menuitemvar [ if (! (strcmp (findpn $tmpVic) "")) [ if (curmodeattr team) [ concat (c 9) Target client: " " (concatword (c 5) (findpn $tmpVic) " - cn: " (c 2) $tmpVic (c 5) " - team: " (at (concat (concatword (c 3) CLA) (concatword (c 1) RVSF)) (at (pstat_score $tmpVic) 4)) (c 5) " - tks: " (c 2) (at (pstat_score $tmpVic) 5)) ] [ concat (c 9) Target client: " " (concatword (c 5) (findpn $tmpVic) " - cn: " (c 2) $tmpVic (c 5)) ] ] ] [ showmenu stats ]
  176. menuitemvar [ if (> (strlen $tmpKBR) 3) [ concat (c 9) Current reason: (concatword (c 5) $tmpKBR) ] ]
  177. menuitemtextinput "Enter a reason: " "" [ tmpKStr = ""; loop gkl $numargs [ if (> $numargs 0) [ tmpKStr = (concatword $tmpKStr (getalias (format arg%1 $gkl)) " ") ] ]; if (< $numargs 2) [ tmpKBR = $arg1 ] [ tmpKBR = $tmpKStr ]; refreshKBM 1 ] 0 256
  178. menuitem "" -1
  179. menuitemvar [ concat (c 9) Use a predefined reason: ]
  180. menuitem "" -1
  181. menuitem "Lag"                    [ tmpKBR = "lagging"; refreshKBM 1 ]
  182. menuitem "Away from keyboard"     [ tmpKBR = "AFK/not playing"; refreshKBM 1 ]
  183. menuitem "Vote abuse"             [ tmpKBR = "kick/ban/other vote abuse"; refreshKBM 1 ]
  184. menuitem "Avoiding kicks/bans"    [ tmpKBR = "avoiding kicks/bans"; refreshKBM 1 ]
  185. menuitem "Private match"          [ tmpKBR = (concat sorry, organizing a private (concatword match ", " (findpn $tmpVic))); refreshKBM 1 ]
  186. menuitem "Obvious cheat"          [ tmpKBR = "blatant cheating"; refreshKBM 1 ]
  187. menuitem "Friendly fire/TK"       [ if (curmodeattr team) [ tmpKBR = "intentional teamkills/team damage" ] [ echo (c 3)Error: (c 5) (getmodeacr) is not a team mode. ]; refreshKBM 1 ]
  188. menuitem "Spamming"               [ tmpKBR = "spamming chat/voicecoms/etc."; refreshKBM 1 ]
  189. menuitem "Poor/abusive behavior"  [ tmpKBR = "poor/abusive behavior"; refreshKBM 1 ]
  190. menuitem "Inappropriate language" [ tmpKBR = "inappropriate language"; refreshKBM 1 ]
  191. menuitem "Inappropriate name"     [ tmpKBR = (concat inappropriate name (addpunct (findpn $tmpVic) 2)); refreshKBM 1 ]
  192. menuitem "" -1
  193. menuitemvar [ concat (c 9) Action: ]
  194. menuitem "" -1
  195. menuitemvar [ concat (c 2)Kick ] [ if (> (strlen $tmpKBR) 3) [ if $votepending [ if (currole) [ vote 2 ]; sleep 250 [ kick $tmpVic $tmpKBR ] ] ] [ kick $tmpVic $tmpKBR ] ]
  196. menuitemvar [ concat (c 3)Ban ]  [ if (> (strlen $tmpKBR) 3) [ if $votepending [ if (currole) [ vote 2 ]; sleep 250 [ ban $tmpVic $tmpKBR ] ] ] [ ban $tmpVic $tmpKBR ] ]
  197. menuitemvar [ concat (c 9)Forceteam ] [ if (curmodeattr team) [ forceteam $tmpVic ] [ echo (c 3)Error: (c 5) (getmodeacr) is not a team mode. ] ]
  198. menuitemvar [ concat (c 1)Whois ] [ whois $tmpVic ]
  199. menuitem "Spectate" [ if (&& $connected (> (curplayers) 1)) [ if (alive) [ suicide ]; sleep 50 [ togglespect ]; sleep 100 [ setfollowplayer $tmpVic ] ] [ echo (c 3)Error: (c 5)Not connected or not enough players. ] ]
  200. menuitemvar [ concat (c 0)Refresh] [ refreshKBM 1 ]
  201. menuitem "" -1
  202. menuitem "Back" [ closemenu rs ]
  203.  
  204. newmenu stats
  205. menuitemvar [ concat (c 9)Current statistics for client: (c 5) (findpn $tmpVic) (c 2) (addpunct $tmpVic 2)  ]
  206. menuitemvar [ if (curmodeattr team) [ concat Team: (at (concat (concatword (c 3) CLA) (concatword (c 1) RVSF)) (at (pstat_score $tmpVic) 4)) ] [ concat Mode: (c 2) (getmodeacr) ] ]
  207. menuitemvar [ if (curmodeattr team) [ concat Teamkills: (c 3) (at (pstat_score $tmpVic) 5) ] ]
  208. menuitemvar [ if (curmodeattr flag) [ concat Flags: (at (pstat_score $tmpVic) 0) ] [ concat Flags: N/A ] ]
  209. menuitemvar [ concat Frags: (at (pstat_score $tmpVic) 1) ]
  210. menuitemvar [ concat Deaths: (at (pstat_score $tmpVic) 2) ]
  211. menuitemvar [ if $connected [ concat Score: (at (pstat_score $tmpVic) 3) ] [ concat Score: N/A ] ]
  212. menuitem "" -1
  213. menuitem "Refresh" [ closemenu stats; sleep 0 [ showmenu stats ] ]
  214. menuitem "Back" [ closemenu stats ]
  215.  
  216. addListOnQuit "tmpKBP"
Advertisement
Add Comment
Please, Sign In to add comment