Jump to content
  • 0

spawn mob and cooldown


Question

Posted

How do I get a script or function to release a mob right at my coordinate and after 10 seconds if I don't eliminate it, the mob simply disappears? I tried using getmapxy but no luck

1 answer to this question

Recommended Posts

  • 0
Posted (edited)
prontera,150,150,6	script	Dev	123,{
	// get player coordinates.
	getmapxy(.@map$, .@x, .@y);

	// clear array of mob ids and spawn the mobs at the players coordinates.
	cleararray($@mobid[0], 0, getarraysize($@mobid));
	monster(.@map$, .@x, .@y, "", .mob_id, .mob_amount);

	// add the spawned mobs to the mob queue.
	for(.@i = 0; .@i < getarraysize($@mobid); .@i++) {
		.@next_index = getarraysize(.mob_queue);
		.mob_queue[.@next_index] = $@mobid[.@i];
		.mob_queue[.@next_index + 1] = gettimetick(2);
	}
	end;

	OnInit:
		// config
		.mob_id = 1002;
		.mob_amount = 1;
		.timeout = 10;

		// start a infinite loop that..
		freeloop(1);
		while(true) {
			// checks every second for mobs that have existed for .timeout seconds, kill them and remove them from the mob queue.
			for(.@i = 0; .@i < getarraysize(.mob_queue); .@i += 2) {
				if(gettimetick(2) - .mob_queue[.@i + 1] == .timeout) {
					unitkill(.mob_queue[.@i]);

					deletearray(.mob_queue[.@i], 2);
					.@i -= 2;
				}
			}

			sleep(1000);
		}
		freeloop(0);
}

 

Edited by Winterfox

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...