Jump to content
  • 0

Event that spawns a monster every 6 hours


Fily

Question


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.01
  • Content Count:  51
  • Reputation:   4
  • Joined:  10/23/16
  • Last Seen:  

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.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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.
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.01
  • Content Count:  51
  • Reputation:   4
  • Joined:  10/23/16
  • Last Seen:  

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 :)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  663
  • Reputation:   671
  • Joined:  11/12/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  


-	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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.01
  • Content Count:  51
  • Reputation:   4
  • Joined:  10/23/16
  • Last Seen:  

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!

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

-	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;
}

 

Link to comment
Share on other sites

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.

×
×
  • Create New...