Jump to content
  • 0
MikZ

inarrary error (help)

Question

Good day!

I need it has something to do with this but honestly I really cant understand it. tried everything. Please help me.

 

 

-	script	WoE Reward	FAKE_NPC,{
OnAgitEnd: callsub S_AgitEnd, 0, 20;
OnAgitEnd2: callsub S_AgitEnd, 20, 30;
S_AgitEnd:
	.@start = getarg(0);
	.@end = getarg(1);
	for ( .@i = .@start; .@i < .@end; ++.@i ) {
		.@guild_id = getcastledata( .castle$[.@i], CD_GUILD_ID );
		if ( .@guild_id ) {
			deletearray .@unique_id;
			getguildmember .@guild_id, 1;
			getguildmember .@guild_id, 2;
			for ( .@j = 0; .@j < $@guildmembercount; ++.@j ) {
				if ( isloggedin( $@guildmemberaid[.@j], $@guildmembercid[.@j] ) ) {
					attachrid $@guildmemberaid[.@j];
					if ( inarray( .@unique_id, get_unique_id() ) == -1 ) {
						dispbottom "Reward given for conquered "+ getcastlename(.castle$[.@i]) +"("+ .castle$[.@i] +")";
						getitem 31509, 1;
						getitem 12103, 1;
						getitem 16770, 1;
						getitem 6380, 15;
						getitem 31510, 1;
						.@unique_id[ getarraysize(.@unique_id) ] = get_unique_id();
					}
				}
			}
		}
	}
	end;
OnInit:
	setarray .castle$[0],
		"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05",
		"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05",
		"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05",
		"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05",
		"arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05",
		"schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
	end;
}

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
29 minutes ago, MikZ said:

Good day!

I need it has something to do with this but honestly I really cant understand it. tried everything. Please help me.

 

 

- script WoE Reward FAKE_NPC,{ OnAgitEnd: callsub S_AgitEnd, 0, 20; OnAgitEnd2: callsub S_AgitEnd, 20, 30; S_AgitEnd: .@start = getarg(0); .@end = getarg(1); for ( .@i = .@start; .@i < .@end; ++.@i ) { .@guild_id = getcastledata( .castle$[.@i], CD_GUILD_ID ); if ( .@guild_id ) { deletearray .@unique_id; getguildmember .@guild_id, 1; getguildmember .@guild_id, 2; for ( .@j = 0; .@j < $@guildmembercount; ++.@j ) { if ( isloggedin( $@guildmemberaid[.@j], $@guildmembercid[.@j] ) ) { attachrid $@guildmemberaid[.@j]; if ( inarray( .@unique_id, get_unique_id() ) == -1 ) { dispbottom "Reward given for conquered "+ getcastlename(.castle$[.@i]) +"("+ .castle$[.@i] +")"; getitem 31509, 1; getitem 12103, 1; getitem 16770, 1; getitem 6380, 15; getitem 31510, 1; .@unique_id[ getarraysize(.@unique_id) ] = get_unique_id(); } } } } } end; OnInit: setarray .castle$[0], "aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05", "gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05", "payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05", "prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05", "arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05", "schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05"; end; }


-	script	WoE Reward	FAKE_NPC,{
OnAgitEnd: callsub S_AgitEnd, 0, 20;
OnAgitEnd2: callsub S_AgitEnd, 20, 30;
S_AgitEnd:
	.@start = getarg(0);
	.@end = getarg(1);
	for ( .@i = .@start; .@i < .@end; ++.@i ) {
		.@guild_id = getcastledata( .castle$[.@i], CD_GUILD_ID );
		if ( .@guild_id ) {
			deletearray .@unique_id;
			getguildmember .@guild_id, 1;
			getguildmember .@guild_id, 2;
			for ( .@j = 0; .@j < $@guildmembercount; ++.@j ) {
				if ( isloggedin( $@guildmemberaid[.@j], $@guildmembercid[.@j] ) ) {
					attachrid $@guildmemberaid[.@j];
					if ( inarray( .@unique_id, get_unique_id() ) == -1 ) {
						dispbottom "Reward given for conquered "+ getcastlename(.castle$[.@i]) +"("+ .castle$[.@i] +")";
						getitem 31509, 1;
						getitem 12103, 1;
						getitem 16770, 1;
						getitem 6380, 15;
						getitem 31510, 1;
						.@unique_id[ getarraysize(.@unique_id) ] = get_unique_id();
					}
				}
			}
		}
	}
	end;
OnInit:
	setarray .castle$[0],
		"aldeg_cas01","aldeg_cas02","aldeg_cas03","aldeg_cas04","aldeg_cas05",
		"gefg_cas01","gefg_cas02","gefg_cas03","gefg_cas04","gefg_cas05",
		"payg_cas01","payg_cas02","payg_cas03","payg_cas04","payg_cas05",
		"prtg_cas01","prtg_cas02","prtg_cas03","prtg_cas04","prtg_cas05",
		"arug_cas01","arug_cas02","arug_cas03","arug_cas04","arug_cas05",
		"schg_cas01","schg_cas02","schg_cas03","schg_cas04","schg_cas05";
	end;
}

 

Check this topic, maybe it will help you

https://herc.ws/board/topic/7296-in_array-for-hercules/

Share this post


Link to post
Share on other sites
  • 0

inarray() is not a script command of Hercules (see the docs in doc/script_commands.txt) and is also not included in the "Array manipulation functions" script

 

You should either replace it with a for() loop or if you want to use Array manipulation functions you should use array_exists() like so:

// with Array manipulation functions:

if (!array_exists(.@unique_id, get_unique_id())) {
	...
}




// with a for() loop:

.@size = getarraysize(.@unique_id);
for (.@k = 0; .@k < .@size; ++.@k) {
	if (.@unique_id[.@k] == get_unique_id()) {
		break;
	}

	...
}

 

Keep in mind that get_unique_id() is also not part of Hercules so if you don't have a plugin that provides it or source mods (not recommended) it will not work

Share this post


Link to post
Share on other sites
  • 0
9 hours ago, MikZ said:

 

sorry but i really cant understand.

please help me with it. 
The error is on this part.


if ( inarray( .@unique_id, get_unique_id() ) == -1 ) {

 

get_unique_id() is a part of gepard modification

Share this post


Link to post
Share on other sites
  • 0
12 hours ago, meko said:

inarray() is not a script command of Hercules (see the docs in doc/script_commands.txt) and is also not included in the "Array manipulation functions" script

 

You should either replace it with a for() loop or if you want to use Array manipulation functions you should use array_exists() like so:

// with Array manipulation functions: if (!array_exists(.@unique_id, get_unique_id())) { ... } // with a for() loop: .@size = getarraysize(.@unique_id); for (.@k = 0; .@k < .@size; ++.@k) { if (.@unique_id[.@k] == get_unique_id()) { break; } ... }


// with Array manipulation functions:

if (!array_exists(.@unique_id, get_unique_id())) {
	...
}




// with a for() loop:

.@size = getarraysize(.@unique_id);
for (.@k = 0; .@k < .@size; ++.@k) {
	if (.@unique_id[.@k] == get_unique_id()) {
		break;
	}

	...
}

 

Keep in mind that get_unique_id() is also not part of Hercules so if you don't have a plugin that provides it or source mods (not recommended) it will not work

Will check on this. once i do server maintenance.

 

 

3 hours ago, Zhao Chow said:

get_unique_id() is a part of gepard modification

Yes have gepard modification. Just don't know on the array thing.

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.