Jump to content
SSForum.net is back!

Recommended Posts

Posted

Ok ive had a request for a plugin using territories.

A region is specified in an ini file and you can conquer a territory by owning all turf flags in that area.

How can i make it determine the places from the flags with mervbot?

I know this was used in the turf Desert Strom as diffrent spawns (this plugin used !setspawn to set a spawn and you only spawned there if you captured all flags).

Posted

aaah yea that was a nice plugin I programmed. Complex though smile.gif

 

Here is a snippet of the plugin code which iterates over all the flags in the arena and checks if the x and y position of each flag matches the position given in the configuration file (flags[] array):

 

_listnode <Flag> *parse;
bool flagCorrect;

//Check flags with settings
for(int i = 0; i < 32; i++) {
	for(int j = 0; j < 32; j++) {
		if(flags[i][j][0] > -1) {
			parse = flaglist->head;
			flagCorrect = false;

			while (parse) {
				Flag *f = parse->item;
				
				if((flags[i][j][0] == (int)f->x) && (flags[i][j][1] == (int)f->y)) {
					flagCorrect = true;
				}
				if(flagCorrect)
					break;
				
				parse = parse->next;
			}
			if(!flagCorrect)
				sendChannel("TURFSPAWN: X or Y position of (area #"+String(i)+") flag #"+String(j+1)+" is incorrect. ("+String(flags[i][j][0])+","+String(flags[i][j][1])+")");
		}
	}
}

 

As you can see, the answer to your question is you can do flag->x and flag->y to get it's x and y position (after instantiating it with a Flag object).

Guest
This topic is now closed to further replies.
×
×
  • Create New...