Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Guild Tag Command (https://forums.graalonline.com/forums/showthread.php?t=134257802)

DustyPorViva 01-29-2010 04:16 AM

Guild Tag Command
 
This little script handles guild tags with a command, "setguild <guild>", much like setnick.

Features:
  • Timer system that works in cooperation with setnick, to avoid abusing the two commands to bypass the 'cooldown'.
  • support for either setguild GUILD NAME or setguild (GUILD NAME) to make it a little more familiar with setnick.
  • Works with local and global guilds. First scanning locally and then globally.
  • Detection for existing local guilds, for proper error output(either guild nonexistent or not being a member). Will omit global guilds if they are disabled on the server.
  • Filtering of error commands made by other players, like default.
  • Checks if the guild is existing or if you're simply not a member. This applies to locally and globally. If global guilds are enabled, it will pass directly onto global checks. For now, there is no way to do this with global guilds. But when it is fixed I will add it on.
  • And possibly other stuff I don't remember!

PHP Code:

function onActionServerside(cmd,acc,guildname) {
  if (
cmd == "removeTag"findplayer(acc).guild "";
  else if (
cmd == "setTag") {
    
temp.checklocaltag getguildnick(guildname,acc);
    if (
checklocaltag != null) {
      
findplayer(acc).nick = (checklocaltag == acc "*" "") @ checklocaltag;
      
findplayer(acc).guild guildname;
    } else {
      if (
serveroptions.globalguilds == false) {
        
temp.scanguilds.loadfolder("levels/guilds/guild*.txt",0);
        
temp.guildcheck "guild" replaceText(guildname" ""_") @ ".txt";
        if (
guildcheck in scanguildsfindplayer(acc).chat "You are not a member of '" guildname "'!";
        
//else findplayer(acc).chat = "The guild '" @ guildname @ "' does not exist or is inactive.";
        
else findplayer(acc).chat "Global guilds are disabled on this server";
      } else 
sendtext("lister""checkinguild", {acc,guildname});
           
//sendtext("lister","checkguildexists",guildname,acc);
    
}
  }
}

function 
replacetext(txt,a,b) {
  if (
txt.pos(a)<0) return txt;
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0,txtpos[0]);
  for (
temp.i=0;i<txtpos.size();i++) {
    
newtxt @= b;
    
newtxt @= txt.substring(txtpos[i]+a.length(),txt.substring(txtpos[i]+a.length()).pos(a));
  }
  return 
newtxt;
}

function 
onReceiveText() {
  if (
params[0] != "lister") return;
  
/*
  if (params[1] == "guildexists") {
    sendtext("lister", "checkinguild", {acc,guildname});
  }
  */
  
if (params[1] == "inguild") {
    
temp.acc params[2][0];
    
temp.guildname params[2][1];
    
temp.guildnick params[2][2];
    
temp.guildrank params[2][3];
    
with (findplayer(acc)) {
      if (
guildnick == null) {
        
chat "You are not a member of '" guildname "', or it does not exist or is inactive.";
        return;
      }
      if (
serveroptions.globalguilds == false) {
        
chat "Global guilds are disabled on this server";
        return;
      }
      
nick = (guildnick == acc "*" "") @ guildnick;
      
guild guildname;
    }
  }
}

//#CLIENTSIDE
function onCreated() {
  
this.cooldown 0;
}

function 
onPlayerChats() {
  if (
player.chat.starts("setnick")) {
    if (
timevar2 this.cooldown+10) {
      
player.chat "Wait " int(((this.cooldown+10)-timevar2)+1.5) @ " seconds before changing your nick or guild again!";
      return;
    }
    
this.cooldown timevar2;
  }
  if (
player.chat.starts("setguild")) {
    if (
timevar2 this.cooldown+10) {
      
player.chat "Wait " int(((this.cooldown+10)-timevar2)+1.5) @ " seconds before changing your nick or guild again!";
      return;
    }
    
this.cooldown timevar2;
    
temp.guildtag player.chat.substring(9);
    if (
guildtag.starts("(") && guildtag.ends(")")) guildtag guildtag.substring(1,guildtag.length()-2);
    if (
guildtag == nulltriggerServer("gui",name,"removeTag",player.account);
    else 
triggerServer("gui",name,"setTag",player.account,guildtag);
  }
}

function 
onRemotePlayerChats(pl,chat) {
  if (
chat.starts("Wait") && chat.ends("seconds before changing your nick or guild again!") ||
      
chat.starts("You are not a member of '") && chat.ends("', or it does not exist or is inactive.") ||
      
chat.starts("You are not a member of '") && chat.ends("'!") ||
      
chat.starts("The guild '") && chat.ends("' does not exist or is inactive.") ||
      
chat == "Global guilds are disabled on this server"pl.chat "";


Please let me know if there are any bugs or oversights!

fowlplay4 01-29-2010 05:13 AM

Looks good, pretty sure you could get rid of the check using a for loop and do something like this instead:

PHP Code:

temp.scanguilds.loadfolder("levels/guilds/guild*.txt",0);
temp.checkguild "guild" replaceText(guildname" ""_") @ ".txt";
if (
checkguild in scanguilds) {
  
// guild found


Maybe a placeholder function for custom guild systems could be added as well.

DustyPorViva 01-29-2010 05:15 AM

Good idea!

PowerProNL 01-30-2010 12:42 PM

nice work ^^

Rufus 02-28-2010 05:32 PM

There's a problem with this where it doesn't really set global guild tags. This means that your "activity" within the global guild system isn't accounted for, and trials can use global guild tags (which I've already brought up).

DustyPorViva 02-28-2010 07:32 PM

Already have a solution to both problems, and will actually make things a lot simpler. Will redo tonight.

cbk1994 02-28-2010 10:05 PM

Quote:

Originally Posted by DustyPorViva (Post 1559632)
Already have a solution to both problems, and will actually make things a lot simpler. Will redo tonight.

Not sure about your solution, but I assume you can just do something like clientside:

PHP Code:

shared.chat("setnick NICKNAME (GUILD)"); 

using the proper values you got from the serverlister

DustyPorViva 03-01-2010 01:08 AM

That's exactly what I was going to do, heh. It would mean I wouldn't have to do setnick checks anymore, or any other insane things(disabling it when players can't change guilds) that I had to do on UN. As well as it automatically deals with the trial thing as well.

DustyPorViva 03-01-2010 05:27 AM

Here's the update, thrown together to fix it fast for UN. It relies pretty much on the default setnick, so if there's any possible abuse it's out of my hands.

PHP Code:

function onActionServerside(cmd,guildname) {
  if (
cmd == "setTag") {
    
temp.checklocaltag getguildnick(guildname,player.account);
    if (
checklocaltag != nullplayer.triggerclient("gui",this,"SetGuildTag",checklocaltag,guildname);
    else {
      if (
serveroptions.globalguilds == false) {
        
temp.player.nick.substring(0,player.nick.pos("("));
        
player.triggerclient("gui",this,"FailedTag",null,guildname);
      } else 
sendtext("lister""checkinguild", {player.account,guildname});
    }
  }
}

function 
replacetext(txt,a,b) {
  if (
txt.pos(a)<0) return txt;
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0,txtpos[0]);
  for (
temp.i=0;i<txtpos.size();i++) {
    
newtxt @= b;
    
newtxt @= txt.substring(txtpos[i]+a.length(),txt.substring(txtpos[i]+a.length()).pos(a));
  }
  return 
newtxt;
}

function 
onReceiveText() {
  if (
params[0] != "lister") return;

  if (
params[1] == "inguild") {
    
temp.acc params[2][0];
    
temp.guildname params[2][1];
    
temp.guildnick params[2][2];
    
temp.guildrank params[2][3];

    if (
guildnick == nullfindplayer(acc).triggerclient("gui",this,"FailedTag",null,guildname);
    else 
findplayer(acc).triggerclient("gui",this,"SetGuildTag",guildnick,guildname);
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("setguild")) {
    
temp.guildtag player.chat.substring(9);
    if (
guildtag.starts("(") && guildtag.ends(")")) guildtag guildtag.substring(1,guildtag.length()-2);
    if (
guildtag == null) {
    
temp.player.nick.substring(0,player.nick.pos("("));
    
shared.chat("setnick" SPC n);
    } else 
triggerServer("gui",name,"setTag",guildtag);
  }
}

function 
onActionClientside(cmd,tag,guild) {
  if (
cmd == "FailedTag") {
    
temp.player.nick.substring(0,player.nick.pos("("));
    
shared.chat("setnick" SPC n SPC "(" guild ")");
  } else if (
cmd == "SetGuildTag"shared.chat("setnick" SPC tag SPC "(" guild ")");
}

function 
onRemotePlayerChats(pl,chat) {
  if (
chat == "Wait 10 seconds before changing your nick again!" ||
      
chat == "That guild does not exist or is inactive" ||
      
chat == "You are not member of the guild or the nickname is wrong" || 
      
chat == "Global guilds are disabled on this server" ||
      
chat.starts("setnick") || chat.starts("setguild")) pl.chat "";



adam 03-03-2010 05:56 AM

so special.

Rufus 03-03-2010 02:33 PM

If my name was *Rufus (US) and I used the "setguild" command on its own, it'll then use "setnick *Rufus" as my name, which simply results in "Rufus" minus asterisks.

DustyPorViva 03-03-2010 09:09 PM

Quote:

Originally Posted by Rufus (Post 1560375)
If my name was *Rufus (US) and I used the "setguild" command on its own, it'll then use "setnick *Rufus" as my name, which simply results in "Rufus" minus asterisks.

Alright I'll fix that.

DustyPorViva 03-04-2010 08:21 AM

Fixed.
PHP Code:

function onActionServerside(cmd,guildname) {
  if (
cmd == "setTag") {
    
temp.checklocaltag getguildnick(guildname,player.account);
    if (
checklocaltag != nullplayer.triggerclient("gui",this,"SetGuildTag",checklocaltag,guildname);
    else {
      if (
serveroptions.globalguilds == false) {
        
temp.player.nick.substring(0,player.nick.pos("("));
        
player.triggerclient("gui",this,"FailedTag",null,guildname);
      } else 
sendtext("lister""checkinguild", {player.account,guildname});
    }
  }
}

function 
replacetext(txt,a,b) {
  if (
txt.pos(a)<0) return txt;
  
temp.txtpos txt.positions(a);
  
temp.newtxt txt.substring(0,txtpos[0]);
  for (
temp.i=0;i<txtpos.size();i++) {
    
newtxt @= b;
    
newtxt @= txt.substring(txtpos[i]+a.length(),txt.substring(txtpos[i]+a.length()).pos(a));
  }
  return 
newtxt;
}

function 
onReceiveText() {
  if (
params[0] != "lister") return;

  if (
params[1] == "inguild") {
    
temp.acc params[2][0];
    
temp.guildname params[2][1];
    
temp.guildnick params[2][2];
    
temp.guildrank params[2][3];

    if (
guildnick == nullfindplayer(acc).triggerclient("gui",this,"FailedTag",null,guildname);
    else 
findplayer(acc).triggerclient("gui",this,"SetGuildTag",guildnick,guildname);
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("setguild")) {
    
temp.guildtag player.chat.substring(9);
    if (
guildtag.starts("(") && guildtag.ends(")")) guildtag guildtag.substring(1,guildtag.length()-2);
    if (
guildtag == null) {
    
temp.player.nick.substring(player.nick.pos("*")+1,player.nick.pos("(")-(player.nick.pos("*")+1));
    
shared.chat("setnick" SPC n);
    } else 
triggerServer("gui",name,"setTag",guildtag);
  }
}

function 
onActionClientside(cmd,tag,guild) {
  if (
cmd == "FailedTag") {
    
temp.player.nick.substring(0,player.nick.pos("("));
    
shared.chat("setnick" SPC n SPC "(" guild ")");
  } else if (
cmd == "SetGuildTag"shared.chat("setnick" SPC tag SPC "(" guild ")");
}

function 
onRemotePlayerChats(pl,chat) {
  if (
chat == "Wait 10 seconds before changing your nick again!" ||
      
chat == "That guild does not exist or is inactive" ||
      
chat == "You are not member of the guild or the nickname is wrong" || 
      
chat == "Global guilds are disabled on this server" ||
      
chat.starts("setnick") || chat.starts("setguild")) pl.chat "";




All times are GMT +2. The time now is 09:45 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.