Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///// SUMMARY /////
- //
- // Teamkills stat added to (pstat_score).
- // New native alias "onVoteEnd" - automatically executed when a pending vote passes or fails.
- // New command "curautoteam" - returns the server's "autoteam" state.
- // New command "addpunct" - injects CubeScript punctuation.
- // New command "curplayers" - returns the current number of players - works in singleplayer too.
- // 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.
- // New scripted variable "votepending" - 0 if there is no vote currently pending, 1 if there is.
- // 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.
- // 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.)
- // New stats menu - allows quick access to the target client's stats (team, teamkills, flags, frags, deaths, score, etc.)
- //
- // Screenshots:
- //
- // http://i52.tinypic.com/29zsmf4.jpg // Admin menu (during a team mode)
- // http://i52.tinypic.com/2zqetyu.jpg // Kick/ban/reason menu (during a team mode, without admin status)
- // http://i56.tinypic.com/24fzki8.jpg // Stats menu (during BTDM)
- // http://i56.tinypic.com/30i7q5z.jpg // Kick/ban/reason menu (during a FFA mode, with admin status)
- // http://i55.tinypic.com/52ifmb.jpg // Stats menu (during DM)
- //
- ///// ENTITY.H ADDITIONS /////
- //
- // Line 389 needs to be changed to:
- //
- int frags, flagscore, deaths, points, tks; // Add an integer to count tks
- // Line 416 needs to be changed to:
- //
- 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),
- ///// CLIENTGAME.CPP ADDITIONS/CHANGES /////
- //
- // Line 890 needs to be changed to:
- //
- if(pl==act || isteam(pl->team, act->team)) { act->frags--; act->tks++; } // Counter for pstat_score teamkills
- // Adds this below line 915:
- //
- p_tks = pl->tks;
- // Line 918 needs to be changed to:
- //
- 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 : "\"\"");
- // Line 1,128 needs to be changed to:
- //
- player1->frags = player1->flagscore = player1->deaths = player1->lifesequence = player1->points = player1->tks = 0; // Reset player1's stats
- // Line 1,129 needs to be changed to:
- //
- 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
- // voteresult - Function starting on line 1,440 needs to be changed to:
- //
- void voteresult(int v)
- {
- if(curvote && v >= 0 && v < VOTE_NUM)
- {
- curvote->result = v;
- curvote->millis = totalmillis + 5000;
- conoutf(_("vote %s"), v == VOTE_YES ? _("passed") : _("failed"));
- if(multiplayer(false)) audiomgr.playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH);
- if(identexists("onVoteEnd")) execute("onVoteEnd"); // This is the bit that was added.
- }
- }
- // curautoteam - Returns the current server autoteam state.
- int curautoteam() { return servstate.autoteam; }
- COMMAND(curautoteam, ARG_IVAL);
- ///// COMMAND.CPP ADDITIONS /////
- //
- // addpunct - Easily inject a string into various CubeScript punctuations
- void addpunct(char *s, char *type = "0")
- {
- int t = atoi(type);
- if(t > -1 && t < 6)
- {
- switch(t)
- {
- case 1: defformatstring(o1)("[%s]", s); result(o1); break; // echo (addpunct hello 1) // Output: [hello]
- case 2: defformatstring(o2)("(%s)", s); result(o2); break; // echo (addpunct hello 2) // Output: (hello)
- case 3: defformatstring(o3)("$%s", s); result(o3); break; // echo (addpunct hello 3) // Output: $hello
- case 4: result("\""); break; // echo (addpunct "" 4) // Output: "
- case 5: result("%"); break; // echo (addpunct "" 5) // Output: %
- default: defformatstring(o4)("\"%s\"", s); result(o4); break; // echo (addpunct hello) // Output: "hello"
- }
- }
- }
- // test = (concat echo (addpunct fov 3)); test // Output: 90.0
- // curplayers - Returns the current # of players.
- void curplayers(void)
- {
- defformatstring(output)("%d", (multiplayer(false) ? (players.length() + 1) : players.length()));
- result(output);
- }
- COMMAND(addpunct, ARG_2STR);
- COMMAND(curplayers, ARG_NONE);
- ///// MENUS.CPP ADDITIONS /////
- //
- void delmenu(const char *name)
- {
- if (!name) return;
- gmenu *m = menus.access(name);
- if (!m) return;
- else menureset(m);
- }
- COMMAND(delmenu, ARG_1STR);
- ///// SCRIPTS.CFG ADDITIONS /////
- //
- if (! (checkalias votepending)) [ votepending = 0 ]
- if (! (checkalias onCallVote)) [ onCallVote = "" ]; if (! (strstr $onCallVote votepending)) [ add2alias onCallVote [ votepending = 1 ] ]
- if (! (checkalias onVoteEnd)) [ onVoteEnd = "" ]; if (! (strstr $onVoteEnd votepending)) [ add2alias onVoteEnd [ votepending = 0 ] ]
- ///// SCRIPT /////
- //
- // Use /showmenu ad - against bots or while connected to a server to view the menu.
- //
- if (! (checkalias tmpKBR)) [ tmpKBR = "" ]; if (! (checkalias tmpVic)) [ tmpVic = "" ]; if (! (checkalias tmpKBP)) [ tmpKBP = "" ]; if (! (checkalias tmpKBMM)) [ tmpKBMM = 0 ]
- selKBItem = [ tmpVic = (getalias arg1); tmpKBR = ""; showmenu rs ]
- genKBItem = [
- if (> $numargs 0) [
- tmpArg1 = $arg1; tmpKArg = (concat selKBItem $tmpArg1)
- if (curmodeattr team) [
- 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)
- ] [
- menuitem (concatword (findpn $arg1) (c 2) " (" $arg1 ")" (c 5)) (addpunct $tmpKArg 2)
- ]
- ]
- ]
- genKBMenu = [ loop gbl (curplayers) [ if (&& (! (strcmp (findpn $gbl) "")) (!= (findcn $curname) $gbl)) [ genKBItem $gbl ] ] ]
- refreshKBM = [ if (!= $arg1 0) [ closemenu rs; sleep 0 [ showmenu rs ] ] [ closemenu ad; sleep 0 [ showmenu ad ] ] ]
- hasValidClients = [
- hvcOutput = 0
- loop hvl (curplayers) [ if (&& (! (strcmp (findpn $hvl) "")) (!= $hvl (findcn $curname))) [ hvcOutput = 1; break ] ]
- result $hvcOutput
- ]
- kickBanMenu = [
- newmenu ad
- menuinit [ delmenu; kickBanMenu ]
- menuitem "Refresh list" [ refreshKBM ]
- menuitem "Remove all bans" [ removebans; refreshKBM ]
- menuitemtextinput "Admin password: " "" [ tmpKBP = $arg1 ] 0 256
- menuitem "Toggle admin status" [ if $connected [ if (currole) [ setadmin; echo you dropped admin status ] [ if (&& (strlen $tmpKBP) (! (strcmp $tmpKBP ""))) [ setadmin 1 $tmpKBP ] ]; refreshKBM ] ]
- menuitem "Toggle autoteam" [ if $connected [ if (curautoteam) [ autoteam 0 ] [ autoteam 1 ]; refreshKBM ] ]
- 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
- menuitem "Change mastermode" [ if (&& (< $tmpKBMM 3) (!= (curmastermode) $tmpKBMM)) [ if $connected [ mastermode $tmpKBMM ] ]; refreshKBM ]
- menuitem "" -1
- menuitem "OK" [ closemenu ad ]
- menuitem "" -1
- if (hasValidClients) [ menuitem "Choose a client: " -1 ] [ menuitem "No valid clients available." -1 ]
- menuitem "" -1
- genKBMenu
- ]
- kickBanMenu
- newmenu rs
- menuitemvar [ if (currole) [ concat (c 1)Note: (c 5)You currently have admin status. Your vote will be forced. ] ]
- 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 ]
- menuitemvar [ if (> (strlen $tmpKBR) 3) [ concat (c 9) Current reason: (concatword (c 5) $tmpKBR) ] ]
- 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
- menuitem "" -1
- menuitemvar [ concat (c 9) Use a predefined reason: ]
- menuitem "" -1
- menuitem "Lag" [ tmpKBR = "lagging"; refreshKBM 1 ]
- menuitem "Away from keyboard" [ tmpKBR = "AFK/not playing"; refreshKBM 1 ]
- menuitem "Vote abuse" [ tmpKBR = "kick/ban/other vote abuse"; refreshKBM 1 ]
- menuitem "Avoiding kicks/bans" [ tmpKBR = "avoiding kicks/bans"; refreshKBM 1 ]
- menuitem "Private match" [ tmpKBR = (concat sorry, organizing a private (concatword match ", " (findpn $tmpVic))); refreshKBM 1 ]
- menuitem "Obvious cheat" [ tmpKBR = "blatant cheating"; refreshKBM 1 ]
- 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 ]
- menuitem "Spamming" [ tmpKBR = "spamming chat/voicecoms/etc."; refreshKBM 1 ]
- menuitem "Poor/abusive behavior" [ tmpKBR = "poor/abusive behavior"; refreshKBM 1 ]
- menuitem "Inappropriate language" [ tmpKBR = "inappropriate language"; refreshKBM 1 ]
- menuitem "Inappropriate name" [ tmpKBR = (concat inappropriate name (addpunct (findpn $tmpVic) 2)); refreshKBM 1 ]
- menuitem "" -1
- menuitemvar [ concat (c 9) Action: ]
- menuitem "" -1
- menuitemvar [ concat (c 2)Kick ] [ if (> (strlen $tmpKBR) 3) [ if $votepending [ if (currole) [ vote 2 ]; sleep 250 [ kick $tmpVic $tmpKBR ] ] ] [ kick $tmpVic $tmpKBR ] ]
- menuitemvar [ concat (c 3)Ban ] [ if (> (strlen $tmpKBR) 3) [ if $votepending [ if (currole) [ vote 2 ]; sleep 250 [ ban $tmpVic $tmpKBR ] ] ] [ ban $tmpVic $tmpKBR ] ]
- menuitemvar [ concat (c 9)Forceteam ] [ if (curmodeattr team) [ forceteam $tmpVic ] [ echo (c 3)Error: (c 5) (getmodeacr) is not a team mode. ] ]
- menuitemvar [ concat (c 1)Whois ] [ whois $tmpVic ]
- 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. ] ]
- menuitemvar [ concat (c 0)Refresh] [ refreshKBM 1 ]
- menuitem "" -1
- menuitem "Back" [ closemenu rs ]
- newmenu stats
- menuitemvar [ concat (c 9)Current statistics for client: (c 5) (findpn $tmpVic) (c 2) (addpunct $tmpVic 2) ]
- 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) ] ]
- menuitemvar [ if (curmodeattr team) [ concat Teamkills: (c 3) (at (pstat_score $tmpVic) 5) ] ]
- menuitemvar [ if (curmodeattr flag) [ concat Flags: (at (pstat_score $tmpVic) 0) ] [ concat Flags: N/A ] ]
- menuitemvar [ concat Frags: (at (pstat_score $tmpVic) 1) ]
- menuitemvar [ concat Deaths: (at (pstat_score $tmpVic) 2) ]
- menuitemvar [ if $connected [ concat Score: (at (pstat_score $tmpVic) 3) ] [ concat Score: N/A ] ]
- menuitem "" -1
- menuitem "Refresh" [ closemenu stats; sleep 0 [ showmenu stats ] ]
- menuitem "Back" [ closemenu stats ]
- addListOnQuit "tmpKBP"
Advertisement
Add Comment
Please, Sign In to add comment