Jump to content
  • 0

Event that spawns a monster every 6 hours


Question

Posted

Hello,

I'm new into scripting and I need some help. I want to create an event for my server that when the script is loaded or the server starts, one monster will be spawned on a random map from an array list of maps. Then a label will be triggered once that monster is killed, like I want to execute an atcommand right after the monster is killed. Then a timer will start and the monster will be spawned again after 6 hours from being killed on a random map again. and the cycle continues.

Could anyone help or create the base script from the details I provided? Thank you guys in advance.

7 answers to this question

Recommended Posts

  • 0
Posted (edited)

There are many ways to do something like this here's one.
 

-	script	Event_Spawn	-1,{                                           // The NPC.
OnEvent:                                                               // The event label.
	atcommand "@doom";                                                 // The atcommand.
	sleep 1000 * 60 * 60 * 6;                                          // The timer.
OnInit:                                                                // The start of the server.
	setarray .@maps$, "prontera", "geffen", "izlude";                  // An array of maps.
	.@map$ = .@maps$[rand(getarraysize(.@maps$))];                     // Shuffle maps. (Thanks Tokei)
	monster .@maps$,0,0,"--ja--",1115,1,"Event_Spawn::OnEvent";        // The monster.
}                                                                      // The curly.

 

Edited by Skorm
Forgot to mix the maps up.
  • 0
Posted
9 minutes ago, Skorm said:

There are many ways to do something like this here's one.
 


-	script	Event_Spawn	-1,{                                           // The NPC.
OnEvent:                                                               // The event label.
	atcommand "@doom";                                                 // The atcommand.
	sleep 1000 * 60 * 60 * 6;                                          // The timer.
OnInit:                                                                // The start of the server.
	setarray .@maps$, "prontera", "geffen", "izlude";                  // An array of maps.
	monster .@maps$,0,0,"--ja--",1115,1,"Event_Spawn::OnEvent";        // The monster.
}                                                                      // The curly.

 

How to randomize the map part? Thanks for responding btw :)

  • 0
Posted

Use

	setarray .@maps$, "prontera", "geffen", "izlude";                  // An array of maps.
	.@map$ = .@maps$[rand(getarraysize(.@maps$))];
	monster .@map$,0,0,"--ja--",1115,1,"Event_Spawn::OnEvent";        // The monster.

for a random map.

  • Upvote 1
  • 0
Posted
22 minutes ago, Tokei said:

Use


	setarray .@maps$, "prontera", "geffen", "izlude";                  // An array of maps.
	.@map$ = .@maps$[rand(getarraysize(.@maps$))];
	monster .@map$,0,0,"--ja--",1115,1,"Event_Spawn::OnEvent";        // The monster.

for a random map.

Thank you @Tokei just got out of the shower and hadn't realized my mistake.

  • Upvote 1
  • 0
Posted (edited)

-	script	sample_npc_mob	-1,{
	
	OnMinute00:
		.@hour = gettime(3);
		if ( .@hour && .@hour % 4 == 0 ) {
			.@maps$ = F_Rand( 
				"prontera",
				"payon",
				"izlude",
				"alberta"
			);
			monster .@maps$,0,0,"--ja--",1115,1,strnpcinfo(3)+"::OnKill";
		}
		end;

	OnKill:
		atcommand "@go 0";
		end;
		
}

use the time label

  • OnClockXXXX
  • OnHourXX
  • etc

avoid the sleep script command.

 

the F_Rand function help you randomize whatever you provided in the arguments.


			.@maps$ = F_Rand( 
				"prontera",
				"payon",
				"izlude",
				"alberta"
			);

 

Edited by Emistry
  • Upvote 1
  • 0
Posted
9 hours ago, Emistry said:


-	script	sample_npc_mob	-1,{
	
	OnMinute00:
		.@hour = gettime(3);
		if ( .@hour && .@hour % 4 == 0 ) {
			.@maps$ = F_Rand( 
				"prontera",
				"payon",
				"izlude",
				"alberta"
			);
			monster .@maps$,0,0,"--ja--",1115,1,strnpcinfo(3)+"::OnKill";
		}
		end;

	OnKill:
		atcommand "@go 0";
		end;
		
}

use the time label

  • OnClockXXXX
  • OnHourXX
  • etc

avoid the sleep script command.

 

the F_Rand function help you randomize whatever you provided in the arguments.



			.@maps$ = F_Rand( 
				"prontera",
				"payon",
				"izlude",
				"alberta"
			);

 

How to set it so that the monster will respawn after 6hours from being killed? Thanks @Emistry!

  • 0
Posted
-	script	sample_npc_mob	-1,{
	
	OnTimer21600000: // 6 hours
	OnInit:
		.@maps$ = F_Rand( 
			"prontera",
			"payon",
			"izlude",
			"alberta"
		);
		monster .@maps$,0,0,"--ja--",1115,1,strnpcinfo(3)+"::OnKill";
		end;

	OnKill:
		initnpctimer;
		atcommand "@go 0";
		end;
}

 

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...