Jump to content
  • 0
MikZ

Autopots to hercules

Question

Good day!

Requesting to convert this to Hercules please.}

error found in this line script inarray

if(inarray(.blackList[0],[email protected]) != -1){ 

Full script below. thanks!

//===== rAthena Script =======================================
//= Auto-Potion
//===== Description: =========================================
//= Provides an @autopot command to automatically use potions.
//===== Changelogs: ==========================================
//= 1.0 First version. [Euphy]
//= 2.0 rewrite and adding SP option. [sader1992]
//============================================================
-	script	#autopot	-1,{
OnInit:
	.HP_Option = true;	//Allow HP option
	.SP_Option = true;	//Allow SP option
	.MinDelay = 100;	//Minimum Delay Allowed in milliseconds (Default and Recommended: 100) [lower values will increase server strain]
	setarray .blackList[0],0;	//Array of black listed item ID

	if(!.HP_Option && !.SP_Option){
		debugmes "Warning: @autopot both hp and sp are Disabled";
		debugmes "Warning: @autopot script has been Disabled!";
		end;
	}
	bindatcmd("autopot",strnpcinfo(0)+"::OnCommand",0,99);
end;

L_Help:
	dispbottom "Available commands:";
	if(.HP_Option && .SP_Option){
		dispbottom "    @autopot <hp|sp> <item id> {<min hp|sp % [1..100]> {<delay [" + .MinDelay + "..1000]>}}";
		dispbottom "    @autopot <hp|sp> list";
		dispbottom "    @autopot <hp|sp> <on|off>";
	}else{
		dispbottom "    @autopot <" + (.HP_Option?"hp":"sp") + "> <item id> {<min " + (.HP_Option?"hp":"sp") + " % [1..100]> {<delay [" + .MinDelay + "..1000]>}}";
		dispbottom "    @autopot <" + (.HP_Option?"hp":"sp") + "> list";
		dispbottom "    @autopot <" + (.HP_Option?"hp":"sp") + "> <on|off>";
	}
	dispbottom "    @autopot info";
	dispbottom "    @autopot help";
	dispbottom "    @autopot blacklist";
	return;

L_Info:
	dispbottom "----------Auto-Potion Information-----------";
	if(.HP_Option){
		dispbottom "HP POTION:  " + getitemname(@autopot_hp_ID) + " (" + @autopot_hp_ID + ")";
		dispbottom "MIN HP:   " + @autopot_hp_Min + " %";
	}
	if(.SP_Option){
		dispbottom "SP POTION:  " + getitemname(@autopot_sp_ID) + " (" + @autopot_sp_ID + ")";
		dispbottom "MIN SP:   " + @autopot_sp_Min + " %";
	}
	dispbottom "DELAY:    " + @autopot_delay + " ms";
	dispbottom "---------------------------------------------";
	return;

L_Start:
	deltimer strnpcinfo(3) + "::OnStart";
	[email protected]$  = getarg(0,0);
	[email protected] = getarg(1,0);
	setd "@autopot_" + [email protected]$ + "_Min",getarg(2,0);
	@autopot_delay = getarg(3,0);

	if (getd("@autopot_" + [email protected]$ + "_Min")   < 1  || getd("@autopot_" + [email protected]$ + "_Min") > 100)  setd "@autopot_" + [email protected]$ + "_Min",90;
	if (@autopot_delay < 50 || @autopot_delay > 1000) @autopot_delay = .MinDelay;
	if (getiteminfo([email protected],2) != IT_HEALING) {
		dispbottom getitemname([email protected]) + " is not a healing item.";
		end;
	}
	if(inarray(.blackList[0],[email protected]) != -1){
		message strcharinfo(0), "'" + getitemname([email protected]) + "' is black listed and cannot be used.";
		end;
	}
	if (BaseLevel < getiteminfo([email protected],12)) {
		message strcharinfo(0), "Your base level is too low to use '" + getitemname([email protected]) + "'.";
		end;
	}
	setd "@autopot_" + [email protected]$ + "_ID",[email protected];
	setd "@autopot_" + [email protected]$ + "_Active",true;
	addtimer [email protected],strnpcinfo(3) + "::OnStart";
	message strcharinfo(0), "Auto-Potion " + strtoupper([email protected]$) + " enabled.";
	callsub L_Info;
	return;

OnCommand:
	if (!getarraysize([email protected]_parameters$)) {
		message strcharinfo(0), "Invalid syntax.";
		callsub L_Help;
		end;
	}
	[email protected]$[0] = strtolower([email protected]_parameters$[0]);
	[email protected]$[1] = strtolower([email protected]_parameters$[1]);
	
	if([email protected]$[0] == "hp" || [email protected]$[0] == "sp"){
		if((!.HP_Option && [email protected]$[0] == "hp") || (!.SP_Option && [email protected]$[0] == "sp")){
			message strcharinfo(0), "Auto-Potion " + strtoupper([email protected]$[0]) + " is Disabled from The Server.";
			end;
		}
		if([email protected]$[1] == "on"){
			if(getd("@autopot_" + [email protected]$[0] + "_Active")){
				message strcharinfo(0), "Auto-Potion " + strtoupper([email protected]$[0]) + " is already on.";
				end;
			}
			if(!getd("@autopot_" + [email protected]$[0] + "_ID")){
				dispbottom "You need to set a " + strtoupper([email protected]$[0]) + " Potion to be used.";
				callsub L_Help;
				end;
			}
			callsub L_Start,[email protected]$[0],getd("@autopot_" + [email protected]$[0] + "_ID");
			end;
		}
		if([email protected]$[1] == "off"){
			message strcharinfo(0), "Auto-Potion " + strtoupper([email protected]$[0]) + " disabled.";
			setd "@autopot_" + [email protected]$[0] + "_Active",false;
			if([email protected]_hp_Active || [email protected]_sp_Active)
				deltimer strnpcinfo(3) + "::OnStart";
			end;
		}
		if([email protected]$[1] == "list"){
			getinventorylist;
			for([email protected] = 0;[email protected] < @inventorylist_count;[email protected]++){
				if (getiteminfo(@inventorylist_id[[email protected]],2) == IT_HEALING) {
					[email protected][[email protected]] = @inventorylist_id[[email protected]];
					[email protected]$ = [email protected]$ + sprintf("~ ^0055FF%s^000000 (%dx)" + (inarray(.blackList[0],@inventorylist_id[[email protected]]) != -1? " ^364022Black Listed^000000":"") + (BaseLevel < getiteminfo(@inventorylist_id[[email protected]],12)? " ^E82C0CNeed Higher Level^000000":"") + ":", getitemname(@inventorylist_id[[email protected]]), countitem(@inventorylist_id[[email protected]]));
					[email protected]++;
				}
			}
			if([email protected]){
				mes "[ Auto-Potion ]";
				mes "Select a " + strtoupper([email protected]$[0]) + " item.";
				[email protected] = select([email protected]$ + "   ^777777Cancel^000000") - 1;
				if ([email protected] != [email protected])
					callsub L_Start,[email protected]$[0],[email protected][[email protected]];
				close2;
			}else{
				message strcharinfo(0), "There are no healing items in your inventory.";
			}
			end;
		}
		[email protected] = atoi([email protected]$[1]);
		[email protected] = atoi([email protected]_parameters$[2]);
		[email protected] = atoi([email protected]_parameters$[3]);
		if(getitemname([email protected]) != "null"){
			callsub L_Start,[email protected]$[0],[email protected],[email protected],[email protected];
			end;
		}
		message strcharinfo(0), "Auto-Potion : something went wrong!";
		callsub L_Help;
		end;
	}
	if([email protected]$[0] == "blacklist"){
		dispbottom "--------------Black Listed Items--------------";
		for([email protected]=0;[email protected]<getarraysize(.blackList);[email protected]++){
			dispbottom "    " + getitemname(.blackList[[email protected]]) + " (" + .blackList[[email protected]] + ")";
		}
		dispbottom "---------------------------------------------";
		end;
	}
	if([email protected]$[0] == "info"){
		if(@autopot_hp_Active || @autopot_sp_Active){
			message strcharinfo(0), "Auto-Potion information is displayed below.";
			callsub L_Info;
		}else{
			message strcharinfo(0), "Auto-Potion is not enabled.";
		}
		end;
	}
	if([email protected]$[0] == "help"){
		message strcharinfo(0), "List of commands is displayed below.";
		callsub L_Help;
		end;
	}
	
	message strcharinfo(0), "Invalid syntax.";
	callsub L_Help;
end;

OnStart:
	if (!getstatus(SC_BERSERK) && !getstatus(SC_SATURDAYNIGHTFEVER) && !getstatus(SC_GRAVITATION) &&
	    !getstatus(SC_TRICKDEAD) && !getstatus(SC_HIDING) && !getstatus(SC__SHADOWFORM) && !getstatus(SC__INVISIBILITY) &&
	    !getstatus(SC__MANHOLE) && !getstatus(SC_KAGEHUMI) && !getstatus(SC_HEAT_BARREL_AFTER) &&
		!getstatus(SC_STONE) && !getstatus(SC_FREEZE) && !getstatus(SC_STUN) && !getstatus(SC_SLEEP))
		{
		if(Hp){
			if(@autopot_hp_Active && Hp * 100 / MaxHp < @autopot_hp_Min) {
				if (countitem(@autopot_hp_ID)) {
					delitem @autopot_hp_ID,1;
					consumeitem @autopot_hp_ID;
					specialeffect2 207;
				}
			}
			if(@autopot_sp_Active && Sp * 100 / MaxSp < @autopot_sp_Min) {
				if (countitem(@autopot_sp_ID)) {
					delitem @autopot_sp_ID,1;
					consumeitem @autopot_sp_ID;
					specialeffect2 208;
				}
			}
		}
	}
	if(@autopot_hp_Active || @autopot_sp_Active)
		addtimer @autopot_delay,strnpcinfo(3) + "::OnStart";
end;
}

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

for inarray() you can use array_find() from Array manipulation functions, which behaves the same way:

if (array_find(.blackList[0], .@potion) != -1) {

for debugmes you should use consolemes:

consolemes(CONSOLEMES_DEBUG, "message");

 

Share this post


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

for inarray() you can use array_find() from Array manipulation functions, which behaves the same way:

if (array_find(.blackList[0], [email protected]) != -1) {

if (array_find(.blackList[0], .@potion) != -1) {

 

Hi @meko

 

Good day!
I did check in https://haru.ws/scriptchecker/#output and got this error. Haven't tried in my server yet.

 

image.png.18be65e13a59568b3a9580e3201d770f.png

Share this post


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

Hi @meko

 

Good day!
I did check in https://haru.ws/scriptchecker/#output and got this error. Haven't tried in my server yet.

 

image.png.18be65e13a59568b3a9580e3201d770f.png

Did you include the array_find function? It's a custom function so you need to copy the function script and include it either inside the script or any script that will make the function load.

Share this post


Link to post
Share on other sites
  • 0
19 minutes ago, Samuel said:

Did you include the array_find function? It's a custom function so you need to copy the function script and include it either inside the script or any script that will make the function load.

Hi Samuel,

I see. wait let me try.

Edited by MikZ

Share this post


Link to post
Share on other sites
  • 0
On 10/22/2020 at 11:47 PM, Astronom said:

Hi, help, how did you fix the script?



simply add the array_find and the array_find script from here 

 

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.