Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var memberarr = [GG.config.user.alias.toLowerCase(),"madhank","kauhut","thermodust","phanakapan","nvidia"];
- var adminarr = [GG.config.user.alias.toLowerCase(),"madhank","thermodust","phanakapan","nvidia"];
- var banarr = [];
- var pass = 'mudkipz';
- function extract0(command){
- //Checks for any spaces in front of the command, and removes them
- while (command.indexOf(' ') == 0) command = command.substring(1,command.length);
- return {command: command};
- }
- function extract1(command){
- //Checks for any spaces in front of the command, and removes them
- command = extract0(command).command;
- //Checks for spaces in the command, and returns default if there are none
- if (command.indexOf(' ') == -1) return {command: command, modifier: ''};
- return {
- command: command.substring(0,command.indexOf(' ')),
- modifier: command.substring(command.indexOf(' ')+1,command.length)
- }
- }
- function extract2(command){
- //Checks for any spaces in front of the command, and removes them
- command = extract0(command).command;
- //Checks for spaces in the command, and returns default if there are none
- if (command.indexOf(' ') == -1) return {command: command, modifier: '',args: []};
- //Checks for commas in the command, and returns extract1 if there are none
- if (command.indexOf(',') < command.indexOf(' '))
- return {command: extract1(command).command, modifier: extract1(command).modifier, args: []};
- var modifier = command.substring(command.indexOf(' ')+1,command.length);
- return {
- command: command.substring(0,command.indexOf(' ')),
- modifier: modifier.substring(0,modifier.indexOf(' ')),
- args: modifier.substring(modifier.indexOf(' ')+1,modifier.length).replace(/ /g,'').split(',')
- }
- }
- function parseCommand(slashcommand,user){
- command = extract2(slashcommand).command;
- modifier = extract2(slashcommand).modifier;
- args = extract2(slashcommand).args;
- //alert(command+', '+modifier+', '+args.join(','));
- //Member commands
- if(memberarr.join('|').search(user) > -1 || adminarr.toString().search(user) > -1){
- switch(command){
- case 'start':
- GG.jabber.chat.send(GG.IA.party.id, "Starting Game...");
- GG.jabber.chat.send(GG.IA.party.id, "Good Luck!");
- setTimeout(function() {GG.game.domain.start();},2000);
- break;
- case 'invite':
- invitearr = slashcommand.substring(slashcommand.indexOf(' ')+1,slashcommand.length).replace(/ /g,'').split(',');
- for(m=0;m<=invitearr.length;m++) GG.IA.party.sendInvite(invitearr[m]);
- GG.jabber.chat.send(GG.IA.party.id, "Invite(s) sent to "+invitearr.join(', '));
- break;
- default:
- //Do nothing
- break;
- }
- }
- //Admin commands
- if(adminarr.join('|').search(user) > -1){
- switch(command){
- case 'end':
- GG.jabber.chat.send(GG.IA.party.id, "Ending current game...");
- GG.game.domain.end();
- break;
- case 'kick':
- GG.IA.party.kick(modifier);
- GG.jabber.chat.send(GG.IA.party.id, modifier+" was kicked from the server by "+user);
- break;
- case 'ban':
- if(banarr.join('|').search(modifier) == -1){
- GG.IA.party.kick(modifier);
- banarr.push(modifier.toLowerCase());
- GG.jabber.chat.send(GG.IA.party.id, modifier+" was banned from the server by "+user);
- }else{
- GG.jabber.chat.send(modifier+" is already on the ban list");
- }
- break;
- case 'get':
- switch(modifier){
- case 'members':
- GG.jabber.chat.send(GG.IA.party.id, "Server Members:");
- GG.jabber.chat.send(GG.IA.party.id, memberarr.join(', '));
- break;
- case 'admins':
- GG.jabber.chat.send(GG.IA.party.id, "Server Admins:");
- GG.jabber.chat.send(GG.IA.party.id, adminarr.join(', '));
- break;
- case 'banned':
- if (banarr.length>=1){
- GG.jabber.chat.send(GG.IA.party.id, "Banned Users:");
- GG.jabber.chat.send(GG.IA.party.id, banarr.join(', '));
- }else{
- GG.jabber.chat.send(GG.IA.party.id, "The list of banned users is currently empty");
- }
- break;
- default:
- GG.jabber.chat.send(GG.IA.party.id, "Current /get parameters are limited to userlists");
- break;
- }
- break;
- case 'add':
- addarr = modifier.toLowerCase().substring(modifier.indexOf(' '),modifier.length).replace(/ /g,'').split(',');
- modifier = modifier.toLowercase().substring(0,modifier.indexOf(' '));
- alert(addarr);
- alert(modifier);
- switch(modifier){
- case 'members':
- alert('this far');
- memberarr.concat(addarr);
- GG.jabber.chat.send(GG.IA.party.id, addarr.slice(1,addarr.length-1).join(', ')+" added to Server Members.");
- break;
- case 'admins':
- for(m=0;m<=addarr.length;m++) adminarr.push(addarr[m].toLowercase());
- GG.jabber.chat.send(GG.IA.party.id, addarr.slice(1,addarr.length-1).join(', ')+" added to Server Admins.");
- break;
- case 'banned':
- for(m=0;m<=addarr.length;m++) banarr.push(addarr[m].toLowercase());
- GG.jabber.chat.send(GG.IA.party.id, addarr.slice(1,addarr.length).join(', ')+" added to Banned Users.");
- break;
- default:
- GG.jabber.chat.send(GG.IA.party.id, "Current /add parameters are limited to userlists");
- break;
- }
- break;
- default:
- //Do nothing
- break;
- }
- }
- }
- GG.plugin.game.options.onPacket = function(e){
- if(e.type == 'message'){
- xml = String.parseXML(e.message);
- if(xml.firstChild.getAttribute('type')=='headline'){
- //alert('It\'s a headline!');
- var element;
- if (element = xml.getElementsByTagName('inbox')[0]){
- //alert('New Inbox Message!');
- new Ajax.Request('/messages/inbox',{
- method:'get',
- onSuccess: function(transport){
- html = transport.responseText;
- name = html.split('"msg_from"')[1].split('viewProfile(\'')[1].split('\'')[0];
- title = html.split('"msg_subject"')[1].split('clearCSSTabs(\'messagesNavigation\'); return false;">')[1].split('</a>')[0];
- //alert(name+', '+title);
- if(title==pass) GG.IA.party.sendInvite(name);
- }
- });
- }
- }else if(xml.firstChild.getAttribute('type')=='groupchat' && (element = xml.getElementsByTagName('body')[0])){
- from = GG.jabber.splitJID(xml.firstChild.getAttribute('from'));
- user = from.resource;
- chat = GG.jabber.chat.encode(element.firstChild.nodeValue);
- if(chat.indexOf('/') == 0){
- slashcommand = chat.substring(1,chat.length);
- parseCommand(slashcommand,user);
- }
- }
- }else if(e.type == 'presence'){
- xml = String.parseXML(e.message);
- //alert(xml.firstChild.getAttribute('from'));
- from = xml.firstChild.getAttribute('from').split('/')[1];
- if (banarr.join('|').search(from) > -1) GG.IA.party.kick(from);
- }
- GG.jabber.switcher(e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement