This script creates the "/clanwar" command. You have to define 6 parameters.
The command is /clanwar. The syntax is
/clanwar <Team 1> <Team 2> <Amount of players> <Mode> <Map> <Kill all players on start (1 or 0)> <Coerce the clanwar, regardless of master / admin state (opt., 1 or 0)>
The script checks at the start, if you are master / admin, if the syntax is correct, and if there are enough players for each clan. I know, there are still some bugs, but I'll try to fix them.
Have fun!
listclanmembers = [ // List all members in clan $arg1 and define how many players should max listed in $arg2
returnvalue = "";
counter = 0;
looplist i (listclients 1) [ // Check all clients
if (! (strcmp (strreplace (getclientname $i) $arg1 "") (getclientname $i))) [ // Current player has $arg1 in his name
if (< $counter $arg2) [ // Execute as long as the amount of found players is less than $arg2
returnvalue = (concat $returnvalue $i);
counter = (+ $counter 1);
];
];
];
result (substr $returnvalue 1);
];
clanwar = [ // Create command
if (>= $numargs 6) [ // There must be declared 6 params at minimum
if (&& (! (ismaster)) (! (isadmin)) (! $arg7)) [ // Not master and not admin and the player doesn't coerce the clanwar
echo "^f6[ WARNING ]^f7 You are not master or admin. A privileged position is required for this command.";
] [ // Is master or admin or the player coerces the clanwar
if (!= (listlen (listclanmembers $arg1 $arg3)) (listlen (listclanmembers $arg2 $arg3))) [ // Different amount of players in the teams
if (< (listlen (listclanmembers $arg1 $arg3)) (listlen (listclanmembers $arg2 $arg3))) [ // Team 1 has less players than team 2
echo (concatword "^f6[ WARNING ]^f7 Team '^f3" $arg1 "^f7' has not enough players (" $arg3 " players required, " (listlen (listclanmembers $arg1 $arg3)) " online).");
] [ // Team 2 has less players than team 1
echo (concatword "^f6[ WARNING ]^f7 Team '^f3" $arg2 "^f7' has not enough players (" $arg3 " players required, " (listlen (listclanmembers $arg2 $arg3)) " online).");
];
] [ // Everything right, execute the settings now
mastermode 2;
looplist i (listclients 1) [ // Spectate all players
spectator 1 $i;
];
teams = (concat $arg1 $arg2);
loop x 2 [ // Execute this twice
unspectedplayers = 0;
looplist i (listclanmembers (at $teams $x) $arg3) [ // Execute this for the clanmembers in team 1 / team 2
if (< $unspectedplayers $arg3) [ // Unspec the amount of players which is defined in $arg3 for each team
spectator 0 $i;
unspectedplayers = (+ $unspectedplayers 1);
];
];
];
$arg4 $arg5
loop x 2 [ // Execute this twice
looplist i (listclanmembers (at $teams $x) $arg3) [ // Execute this for the clanmembers in team 1 / team 2 who got unspected
if (!= (getclientnum) $i) [ // Current client is not me, use command "setteam"
setteam $i (at "good evil" $x);
] [ // Current client is me, use command "team"
team (at "good evil" $x);
];
];
];
if ($arg6) [ // Kill all players on start?
looplist i (concat (listclanmembers $arg1 $arg3) (listclanmembers $arg2 $arg3)) [ // Kill the players who got unspected
spectator 1 $i;
spectator 0 $i;
];
];
];
];
] [ // There aren't 6 params declared!
echo "^f1[ INFO ]^f7 Right syntax for '^f0/clanwar^f7': <Team 1> <Team 2> <Amount of players> <Mode> <Map> <Kill all players on start (1 or 0)> <Coerce the clanwar, regardless of master / admin state (opt.)>";
];
];