Jump to content
  • 0
Like it~*

Script don't work properly.

Question

Hi. I'm having trouble with this script. It's really cool though, it does not work properly, I just modified the summoned monsters, it's practically the original script of the author. The problems are:
  • When you kill all the monsters, the event does not end.
  • When killing the winning monsters, the item configured(7711) in the NPC is not being received.

@edit

No errors presented in the map-server

 

 

 

/*=========================================================
Hercules Invasion Prized
by Mumbles
===========================================================
Description:
A completely revamped and optimised variation of the widely
popular "Poring Invasion" event.

Configuration settings are dynamic and easily modifiable.
Customizable parameters include normal monsters, "prized"
monsters, each respective monster amounts, monster tiers,
invasion map,NPC name, and server name.

NPC can be triggered by staff using the command @invasion.
===========================================================
Compatibility:
Optimised for Hercules emulators.
===========================================================
Changelog:
v1.0 - First version.
	v1.0.1 - Removed support for backwards compatibility.
	v1.0.2 - Optimised announcements.
=========================================================*/

-	script	invasion	-1,{

	OnInit:
		// Configuration
		.npc_name$ = "[^0000FFHercules Invasion^000000]";
		.server_name$ = "Hercules";	// Server name
		.map_name$ = "Mapa sofisticado";		// Invasion map name
		.map$ = "guild_vs2";	// Invasion map
		.reward = 7711;	// Event Ticket
		.tiers = 3;		// Amount of tiers //Níveis de monstros, como se fosse andares..
		.limit = 22;	// Kill limit
		.delay = 5;		// Announcement delay in seconds
		.auth = 60;		// GM level to access staff panel
		
		// Normal mob IDs
		setarray .normal[0],	1916,	1918,	1919,	1920,	1921;
		
		// Normal mob amounts
		setarray .n_mobs[0],		1,		3,		3,		3,		3;
		
		// Prized mob IDs
		setarray .prized[0],	1916,	1918,	1919,	1920,	1921;
					
		// Prized mob amounts			
		setarray .p_mobs[0],	   0,	   1,	   1,	   1,	   1;
		
		// Define announcements
		setarray .announce$[0],
			"Porings of the world seem to have started an uprising because they continue to be hunted...",
			"It appears that they plan to raid the city of "+ .map_name$ +" today!",
			"They've feared "+ .map_name$ +" for ages, and are sick of it!",
			"Prepare yourself, Warriors of "+ .server_name$ +"!",
			"They're approaching...",
			"The "+ .map_name$ +" Soldiers are unable to fight!",
			"They need assistance!";
		
		// Create @invasion command
		bindatcmd "invasion", strnpcinfo(3) +"::OnInvasion", .auth, .auth;
		
		end;
	
	
	OnInvasion:
		mes .npc_name$;
		mes "Hey there, "+ strcharinfo(0) +"!";
		mes "What would you like to do?";
		mes " ";
		
		while (true) {
			switch(select("Start invasion:Stop invasion")) {
				case 1:
					// Check invasion status
					if(.state) {
						mes "^FF0000The invasion is already in progress!^000000";
						break;
					}
					
					close2;
					
					OnEnable:
						// Set invasion status
						.state++;
						.wave++;
			
						// Announcements
						for (.@i = 0; .@i < getarraysize(.announce$); .@i++) {
							announce .announce$[.@i], bc_all;
							sleep .delay * 1000;
						}
						
						announce "Wave "+ .wave +" of the Poring forces presses onward!", bc_all;
			
						// Normal mobs
						for (.@i = 0; .@i < getarraysize(.normal); .@i++) {
							monster .map$, 0, 0, getmonsterinfo(.normal[.@i], 0), .normal[.@i], .n_mobs[.@i], "";
						}
							
						// Prized mobs
						for (.@i = 0; .@i < getarraysize(.prized); .@i++) {
							monster .map$, 0, 0, getmonsterinfo(.prized[.@i], 0), .prized[.@i], .p_mobs[.@i], strnpcinfo(3) +"::OnMobKilled";
						}
							
						setmapflag .map$, mf_nomobloot;
						initnpctimer;
						.state++;
					
					end;

				case 2:
					// Check invasion status
					if(.state < 2) {
						mes "^FF0000There is no invasion in progress!^000000";
						break;
					}
					
					// End invasion
					donpcevent strnpcinfo(3) +"::OnTimer3600000";
					close;
			}
		}
		
		
	OnClock0100:
	OnClock2100:
		// Start invasion
		donpcevent strnpcinfo(3) +"::OnEnable";
		end;
		
		
	OnMobKilled:
		// Tier 1
		setarray .@tier1[0], 1918;
		
		// Tier 2
		setarray .@tier2[0], 1919;
		
		// Tier 3
		setarray .@tier3[0], 1920;
		
		// Tier 4
		setarray .@tier4[0], 1921;
		
		// Tier 5
		setarray .@tier5[0], 1916;
		
		// Check if monster killed is listed in tiers
		for (.@t = 0; .@t < .@tiers; .@t++) {
			for (.@i = 0; .@i < getarraysize(getd(".@tier"+ (.@t + 1))); .@i++) {
				if (.state && killedrid == .@tier1[.@i]) {
					.@amount = .@t + 1;
					.@winner++;
				}
			}
		}
		
		// Reward and announce winner; increment count
		if (.@winner) {
			announce .@tier +" "+ getitemname(.reward) +" won by "+ strcharinfo(0) + ".", bc_map | bc_blue;
			getitem .reward, .@amount;
			.count++;
		}
		
		if (.count > .limit) {
			OnTimer3600000:
				// Kill all monsters and reset invasion status
				killmonster .map$,"All";
				announce "Poring forces have been overcome. They're retreating!",0;
				removemapflag .map$, mf_nomobloot;
				stopnpctimer;
				.count = 0;
				.state = 0;
		}
		
		end;

} 

 

 

Edited by Like it~*

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

error and script doesn't seem to be connected though..

 

[SQL]: DB error - Duplicate entry '1428' for key 'PRIMARY'

 

Basically what that SQL error means, there is already an entry in the table  atcommandlog with  atcommand_id = 1428

 

 

 

Perhapss, a good start would be to run this SQL query on your database, to get more information about that record:

SELECT * FROM atcommandlog WHERE atcommand_id=1428;

 

Other than that, I don't know, maybe review the script.

 

I don't have time right now, need to do my school homework...

Edited by Habilis

Share this post


Link to post
Share on other sites
  • 0

error and script doesn't seem to be connected though..

 

[SQL]: DB error - Duplicate entry '1428' for key 'PRIMARY'

 

Basically what that SQL error means, there is already an entry in the table  atcommandlog with  atcommand_id = 1428

 

 

 

Perhapss, a good start would be to run this SQL query on your database, to get more information about that record:

SELECT * FROM atcommandlog WHERE atcommand_id=1428;

 

Other than that, I don't know, maybe review the script.

 

I don't have time right now, need to do my school homework...

 

There really is no connection of this error with the script. I'm sorry, I got confused. In fact there are no errors presented in the map-server. I'll update the main post.

Share this post


Link to post
Share on other sites
  • 0

I just gave a quick look(there can be more error), but just change this

for (.@t = 0; .@t < .@tiers; .@t++) {

to

for (.@t = 0; .@t < .tiers; .@t++) {

and check if it works.

Share this post


Link to post
Share on other sites
  • 0
18 hours ago, Dastgir said:

I just gave a quick look(there can be more error), but just change this


for (.@t = 0; .@t < .@tiers; .@t++) {

to


for (.@t = 0; .@t < .tiers; .@t++) {

and check if it works.

I tested, but don't work master.

Share this post


Link to post
Share on other sites
  • 0

Well not quite sure everything should work, but try this one:

https://pastebin.com/QQCi8TLu

If this doesn't work either, it's probably an issue with the array's size evaluation. I've included a debugmes line, try to uncomment it and paste the map server log output, so we'll know what's happening.

Share this post


Link to post
Share on other sites
  • 0
On 03/07/2017 at 4:48 AM, Alayne said:

Well not quite sure everything should work, but try this one:

https://pastebin.com/QQCi8TLu

If this doesn't work either, it's probably an issue with the array's size evaluation. I've included a debugmes line, try to uncomment it and paste the map server log output, so we'll know what's happening.

Hello, sorry for the delay. Thank you very much for your help so far.

See the errors shown on the map-server.

Spoiler

[Warning]: Unexpected type for argument 1. Expected variable, got C_STR.
[Debug]: Data: string value=".@tier1"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Error]: script:getelementofarray: not a variable
[Debug]: Data: string value=".@tier1"
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Warning]: Unexpected type for argument 1. Expected variable, got C_STR.
[Debug]: Data: string value=".@tier1"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Error]: script:getelementofarray: not a variable
[Debug]: Data: string value=".@tier1"
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Warning]: Unexpected type for argument 1. Expected variable, got C_STR.
[Debug]: Data: string value=".@tier1"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Error]: script:getelementofarray: not a variable
[Debug]: Data: string value=".@tier1"
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Warning]: Unexpected type for argument 1. Expected variable, got C_STR.
[Debug]: Data: string value=".@tier1"
[Debug]: Function: getelementofarray
[Debug]: Source (NPC): invasion (invisible/not on a map)
[Error]: script:getelementofarray: not a variable
[Debug]: Data: string value=".@tier1"
[Debug]: Source (NPC): invasion (invisible/not on a map)

 

 

Share this post


Link to post
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.   Restore formatting

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.