• 0
KeyMaster

Help in this script

Question

I'm trying this script I found in herc, it's an hp system for monster, the script below is a test on a monster Poporing, but my intention is to let only all mvps appear on that bar when they attack them.

Screenshots

screenHercules021.jpg

screenHercules022.jpg

screenHercules023.jpg

screenHercules024.jpg

screenHercules025.jpg

screenHercules026.jpg

Error

script error on npc/custom/hpbar.txt line 9
    parse_callfunc: expected ')' to close argument list
     4 :        {
     5 :                .HP_Bar = 1;
     6 :                .mobGID = monster ("payon",148,226,"[T] HP Test",POPORING,1,strnpcinfo(0)+"::OnDie");
     7 :                        setunitdata .mobGID,UDT_MAXHP,4000;
     8 :                        setunitdata .mobGID,UDT_HP,4000;
*    9 :                [email protected] = getunits(BL_PC, [email protected]',' false, "payon");
    10 :                for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
    11 :                        addtimer(0,strnpcinfo(0)+"::OnHPBar", [email protected][[email protected]]);
    12 :        }
    13 :        end;
    14 :

Script

payon,147,229,4    script    Test#HPbar    1_F_MARIA,{

    if (.HP_Bar == 0)
    {
        .HP_Bar = 1;
        .mobGID = monster ("payon",148,226,"[T] HP Test",POPORING,1,strnpcinfo(0)+"::OnDie");
            setunitdata .mobGID,UDT_MAXHP,4000;
            setunitdata .mobGID,UDT_HP,4000;
        [email protected] = getunits(BL_PC, [email protected], false, "payon");
        for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
            addtimer(0,strnpcinfo(0)+"::OnHPBar", [email protected][[email protected]]);
    }
    end;
    
OnDie:
.HP_Bar = 0;
end;
    
OnHPBar:
.U_MAXHP = getunitdata (.mobGID,UDT_MAXHP);
while (.HP_Bar != 0)
{
    .U_HP = getunitdata (.mobGID,UDT_HP);
    .P_HP = (.U_HP*100)/.U_MAXHP;

    cutin(""+.P_HP+"", 1);
     
    sleep2 100;
}
cutin("0_hpbar", 1);
sleep2 5000; //Delay to hide HP Bar
cutin("", 255);
end;

}


 

 

Edited by KeyMaster

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

You can't use Hercules scripts and expect them to work in rAthena.

Look at the error and cross-reference with our script_commands.txt file and you'll see exactly what's wrong.

Share this post


Link to post
Share on other sites
  • 0
payon,147,229,4    script    Test#HPbar    1_F_MARIA,{

	if (.HP_Bar == false)
	{
		.HP_Bar = true;
		.mobGID = monster ("payon",148,226,"[T] HP Test",1031,1,strnpcinfo(0)+"::OnDie");
		setunitdata .mobGID,UMOB_MAXHP,4000;
		setunitdata .mobGID,UMOB_HP,4000;
		[email protected] = getmapunits(BL_PC, "payon", [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
		{
			attachrid [email protected][[email protected]];
			addtimer(0,strnpcinfo(0)+"::OnHPBar");
		}
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	[email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		[email protected]_HP = getunitdata (.mobGID,UMOB_HP);
		[email protected]_HP = (@.U_HP*100)/[email protected]_MAXHP;

		cutin([email protected]_HP+"", 1);

		sleep2 100;
	}
	cutin("0_hpbar", 1);
	sleep2 5000; //Delay to hide HP Bar
	cutin("", 255);
	end;
}

This could be done for every MvP, but the way it's done (by adding a script and an attach every player on the map, adding new players on the map, and show them the HP every 100ms) would generate a lot of lag. I'd recommend using this for a special event mostly, and even that would be resource-intensive. Another way could be adding only the characters who attack the MvP with a custom label like OnAttack. I think there's such a label floating around boards.

Share this post


Link to post
Share on other sites
  • 0
6 hours ago, n0tttt said:
payon,147,229,4    script    Test#HPbar    1_F_MARIA,{

	if (.HP_Bar == false)
	{
		.HP_Bar = true;
		.mobGID = monster ("payon",148,226,"[T] HP Test",1031,1,strnpcinfo(0)+"::OnDie");
		setunitdata .mobGID,UMOB_MAXHP,4000;
		setunitdata .mobGID,UMOB_HP,4000;
		[email protected] = getmapunits(BL_PC, "payon", [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
		{
			attachrid [email protected][[email protected]];
			addtimer(0,strnpcinfo(0)+"::OnHPBar");
		}
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	[email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		[email protected]_HP = getunitdata (.mobGID,UMOB_HP);
		[email protected]_HP = (@.U_HP*100)/[email protected]_MAXHP;

		cutin([email protected]_HP+"", 1);

		sleep2 100;
	}
	cutin("0_hpbar", 1);
	sleep2 5000; //Delay to hide HP Bar
	cutin("", 255);
	end;
}

This could be done for every MvP, but the way it's done (by adding a script and an attach every player on the map, adding new players on the map, and show them the HP every 100ms) would generate a lot of lag. I'd recommend using this for a special event mostly, and even that would be resource-intensive. Another way could be adding only the characters who attack the MvP with a custom label like OnAttack. I think there's such a label floating around boards.

This is what I intend to do...
I tested it here and it is giving this when it clicks on npc.

[Error]: buildin_setunitdata: Invalid object!
[Debug]: Source (NPC): Test#HPbar at payon (147,229)
[Error]: buildin_setunitdata: Invalid object!
[Debug]: Source (NPC): Test#HPbar at payon (147,229)
[Warning]: buildin_getunitdata: Error in argument! Please give a variable to store values in.
[Debug]: Source (NPC): Test#HPbar at payon (147,229)
[Warning]: buildin_getunitdata: Error in argument! Please give a variable to store values in.
[Debug]: Source (NPC): Test#HPbar at payon (147,229)
[Error]: script:op_2num: division by zero detected op=C_DIV i1=0 i2=0
[Debug]: Source (NPC): Test#HPbar at payon (147,229)

 

Share this post


Link to post
Share on other sites
  • 0
On 2/12/2019 at 8:39 PM, n0tttt said:
payon,147,229,4    script    Test#HPbar    1_F_MARIA,{

	if (.HP_Bar == false)
	{
		.HP_Bar = true;
		.mobGID = monster ("payon",148,226,"[T] HP Test",1031,1,strnpcinfo(0)+"::OnDie");
		setunitdata .mobGID,UMOB_MAXHP,4000;
		setunitdata .mobGID,UMOB_HP,4000;
		[email protected] = getmapunits(BL_PC, "payon", [email protected]);
		for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
		{
			attachrid [email protected][[email protected]];
			addtimer(0,strnpcinfo(0)+"::OnHPBar");
		}
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	[email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		[email protected]_HP = getunitdata (.mobGID,UMOB_HP);
		[email protected]_HP = (@.U_HP*100)/[email protected]_MAXHP;

		cutin([email protected]_HP+"", 1);

		sleep2 100;
	}
	cutin("0_hpbar", 1);
	sleep2 5000; //Delay to hide HP Bar
	cutin("", 255);
	end;
}

This could be done for every MvP, but the way it's done (by adding a script and an attach every player on the map, adding new players on the map, and show them the HP every 100ms) would generate a lot of lag. I'd recommend using this for a special event mostly, and even that would be resource-intensive. Another way could be adding only the characters who attack the MvP with a custom label like OnAttack. I think there's such a label floating around boards.

 

123123123123.png

Share this post


Link to post
Share on other sites
  • 0
        [email protected] = getunits(BL_PC, [email protected], false, "payon");
        for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
            addtimer(0,strnpcinfo(0)+"::OnHPBar", [email protected][[email protected]]);

change to

		addrid(5, "payon");
		addtimer(1000, strnpcinfo(0)+"::OnHPBar");

 

Share this post


Link to post
Share on other sites
  • 0
18 hours ago, Emistry said:
        [email protected] = getunits(BL_PC, [email protected], false, "payon");
        for ([email protected] = 0; [email protected] < [email protected]; [email protected]++)
            addtimer(0,strnpcinfo(0)+"::OnHPBar", [email protected][[email protected]]);

change to

		addrid(5, "payon");
		addtimer(1000, strnpcinfo(0)+"::OnHPBar");

 

error

script error on npc/custom/wbosshp.txt line 23
    parse_simpleexpr: unmatched ')'
    18 : OnHPBar:
    19 :        [email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
    20 :        while (.HP_Bar != false)
    21 :        {
    22 :                [email protected]_HP = getunitdata (.mobGID,UMOB_HP);
*   23 :                [email protected]_HP = (@'.'U_HP*100)/[email protected]_MAXHP;
    24 :
    25 :                cutin([email protected]_HP+"", 1);
    26 :
    27 :                sleep2 100;
    28 :        }
[Info]: Done loading '12340' NPCs:
        -'2929' Warps
        -'188' Shops
        -'9223' Scripts
        -'3876' Spawn sets
        -'39591' Mobs Cached
        -'0' Mobs Not Cached

code:

payon,147,229,4	script	Test#HPbar	1_F_MARIA,{

	if (.HP_Bar == false)
	{
		.HP_Bar = true;
		.mobGID = monster ("payon",148,226,"[T] HP Test",1031,1,strnpcinfo(0)+"::OnDie");
		setunitdata .mobGID,UMOB_MAXHP,4000;
		setunitdata .mobGID,UMOB_HP,4000;
		addrid(5, "payon");
		addtimer(1000, strnpcinfo(0)+"::OnHPBar");
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	[email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		[email protected]_HP = getunitdata (.mobGID,UMOB_HP);
		[email protected]_HP = (@.U_HP*100)/[email protected]_MAXHP;

		cutin([email protected]_HP+"", 1);

		sleep2 100;
	}
	cutin("0_hpbar", 1);
	sleep2 5000; //Delay to hide HP Bar
	cutin("", 255);
	end;
}

TIA

Share this post


Link to post
Share on other sites
  • 0
On 10/27/2019 at 11:35 AM, noobzter003 said:

error

script error on npc/custom/wbosshp.txt line 23
    parse_simpleexpr: unmatched ')'
    18 : OnHPBar:
    19 :        [email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
    20 :        while (.HP_Bar != false)
    21 :        {
    22 :                [email protected]_HP = getunitdata (.mobGID,UMOB_HP);
*   23 :                [email protected]_HP = (@'.'U_HP*100)/[email protected]_MAXHP;
    24 :
    25 :                cutin([email protected]_HP+"", 1);
    26 :
    27 :                sleep2 100;
    28 :        }
[Info]: Done loading '12340' NPCs:
        -'2929' Warps
        -'188' Shops
        -'9223' Scripts
        -'3876' Spawn sets
        -'39591' Mobs Cached
        -'0' Mobs Not Cached

code:

payon,147,229,4	script	Test#HPbar	1_F_MARIA,{

	if (.HP_Bar == false)
	{
		.HP_Bar = true;
		.mobGID = monster ("payon",148,226,"[T] HP Test",1031,1,strnpcinfo(0)+"::OnDie");
		setunitdata .mobGID,UMOB_MAXHP,4000;
		setunitdata .mobGID,UMOB_HP,4000;
		addrid(5, "payon");
		addtimer(1000, strnpcinfo(0)+"::OnHPBar");
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	[email protected]_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		[email protected]_HP = getunitdata (.mobGID,UMOB_HP);
		[email protected]_HP = (@.U_HP*100)/[email protected]_MAXHP;

		cutin([email protected]_HP+"", 1);

		sleep2 100;
	}
	cutin("0_hpbar", 1);
	sleep2 5000; //Delay to hide HP Bar
	cutin("", 255);
	end;
}

TIA

[email protected]_HP = (@'.'U_HP*100)/[email protected]_MAXHP;

to:

[email protected]_HP = ([email protected]_HP*100)/[email protected]_MAXHP;
  • Upvote 1

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

Loading...