Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-29-2010, 04:16 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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!

Last edited by DustyPorViva; 01-29-2010 at 05:16 AM..
Reply With Quote
  #2  
Old 01-29-2010, 05:13 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #3  
Old 01-29-2010, 05:15 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Good idea!
Reply With Quote
  #4  
Old 01-30-2010, 12:42 PM
PowerProNL PowerProNL is offline
Retired Zone Manager
PowerProNL's Avatar
Join Date: Feb 2008
Location: Holland
Posts: 266
PowerProNL can only hope to improve
Send a message via AIM to PowerProNL
nice work
__________________
Graal Mail: [email protected]
McPowerProNL, I'm loving it
Reply With Quote
  #5  
Old 02-28-2010, 05:32 PM
Rufus Rufus is offline
Registered User
Join Date: Jun 2004
Location: United Kingdom
Posts: 4,698
Rufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud of
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).
__________________
Quote:
Originally Posted by Loriel View Post
Seriously, you have ****-all for content and you're not exactly pulling in new developer talent, angling for prestigious titles should be your last concern.
Reply With Quote
  #6  
Old 02-28-2010, 07:32 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Already have a solution to both problems, and will actually make things a lot simpler. Will redo tonight.
Reply With Quote
  #7  
Old 02-28-2010, 10:05 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DustyPorViva View Post
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
__________________
Reply With Quote
  #8  
Old 03-01-2010, 01:08 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #9  
Old 03-01-2010, 05:27 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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 "";


Last edited by DustyPorViva; 03-01-2010 at 07:36 AM..
Reply With Quote
  #10  
Old 03-03-2010, 05:56 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
so special.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #11  
Old 03-03-2010, 02:33 PM
Rufus Rufus is offline
Registered User
Join Date: Jun 2004
Location: United Kingdom
Posts: 4,698
Rufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud of
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.
__________________
Quote:
Originally Posted by Loriel View Post
Seriously, you have ****-all for content and you're not exactly pulling in new developer talent, angling for prestigious titles should be your last concern.
Reply With Quote
  #12  
Old 03-03-2010, 09:09 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Rufus View Post
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.
Reply With Quote
  #13  
Old 03-04-2010, 08:21 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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 "";

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:52 PM.


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