Guild Fort Flag thingy...

I was wondering if any of you could help a noob like me at scripting. I’m trying to create a flag for a guild tower. Where you kill the flag and then your guild owns it, etc. Pretty straight forward. It works fine, but it’s a little glitchy.

When you get it down to 0, if there are two guilds simultaneously slashing it, it will just sit there for a few seconds before setting itself back to 50 hearts. I am thinking that it’s because of the wait 3;, but I want that in there so that it shows that the flag was captured. So, hypothetically, you could have two opposing guilds just slashing at it forever without it actually going back to fullhearts and saying that it is controlled.

If anyone could help me, that would be awesome.

[CODE]if (created){
timereverywhere;
timeout = .05;
}

if (timeout){
message Fort controlled by: (#s(server.guildflag));
timeout = .05;
}

if (washit&&!hearts==0){
hearts -= .5;
}

if (washit&&hearts==0){
setstring server.guildflag,#g;
message Fort captured by: (#s(server.guildflag));
sleep 3;
hearts = 50;
timeout = .05;
}[/CODE]

quick and dirty, but it works :smiley:

if (created) {
  timereverywhere;
  hearts = 50;
  timeout = .05;
}

if (timeout) {
  message Fort controlled by: (#s(server.guildflag));

  if (hearts==0){
    setstring server.guildflag,#g;
    message Fort captured by: (#s(server.guildflag));
    sleep 3;
    hearts = 50;
  }

  timeout = .05;
}

if (washit&&hearts!==0) {
  hearts -= .5;
}

With server.guildflag, one way to make the script more universal and require as little updates as possible when using it on other levels, would be to add #L into the equation when setting it.

Example. Let’s say the guild named Thusly just captured the flag of the fort’s tower. So you’d:
setstring server.guildflag,Thusly;

However, if you add:
setstring server.guildflag-#L,Thusly;

Then the server. string will be made to include the level’s name. Thus, the string it sets will be unique to each level you place the script on. Useful if you have multiple forts, or one fort has multiple segments to capture.

However, if the fort is larger than a couple levels, it might jsut be best to create a unique name for each fort’s string. Like server.guildflag-skullkeep.

What you do is up to you. Just thought I’d throw it out there

Like the guild forts on Classic?

[QUOTE=SolarT;14731]
With server.guildflag, one way to make the script more universal and require as little updates as possible when using it on other levels, would be to add #L into the equation when setting it.

Example. Let’s say the guild named Thusly just captured the flag of the fort’s tower. So you’d:
setstring server.guildflag,Thusly;

However, if you add:
setstring server.guildflag-#L,Thusly;

Then the server. string will be made to include the level’s name. Thus, the string it sets will be unique to each level you place the script on. Useful if you have multiple forts, or one fort has multiple segments to capture.

However, if the fort is larger than a couple levels, it might jsut be best to create a unique name for each fort’s string. Like server.guildflag-skullkeep.

What you do is up to you. Just thought I’d throw it out there
[/QUOTE]

Thanks, I wasn’t aware of the #L adding the level to the string. Additionally, I had just planned different string names for seperate flags, but thanks for the useful info.

[QUOTE=Spooon;14733]
Like the guild forts on Classic?
[/QUOTE]

Pretty much.

[QUOTE=Nalin;14735]
That actually WON’T work. Keep in mind guys that each player has their own copy of this script and each player is executing their own copy. When that if (hearts==0) is hit, multiple players will hit it at the same time because of the timereverywhere. Then you will have everybody in the level spamming the server trying to instate their guild as the owner. What ends up happening is that the last player to call setstring server.guildflag,#g; ends up owning it.

If you want an example of how to make a good clientside NPC that can be used by multiple players, That is a custom baddy I made on Waffles. Use some of the concepts of leader and the save[] variables.

Or, in the original script, modify your if (washit&&hearts==0){ to set the hearts back to 50 before the sleep.
[/QUOTE]

Thanks Nalin. I’m just beginning to really learn how to script more difficult things, so thank you for the directions to your thread for the ghosts. :slight_smile: Let’s see if I can absorb some knowledge.

I made a script identical to this already, it’s a thread called territory claimer or something. I connected it to a custom minimap also, so that if you took over a flag that area on the minimap would turn your nation/guild color.