Jump to content
  • 0

Help in this script


M a p l e

Question


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  271
  • Reputation:   62
  • Joined:  02/04/19
  • Last Seen:  

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 :                .@count = getunits(BL_PC, .@units',' false, "payon");
    10 :                for (.@i = 0; .@i < .@count; .@i++)
    11 :                        addtimer(0,strnpcinfo(0)+"::OnHPBar", .@units[.@i]);
    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;
        .@count = getunits(BL_PC, .@units, false, "payon");
        for (.@i = 0; .@i < .@count; .@i++)
            addtimer(0,strnpcinfo(0)+"::OnHPBar", .@units[.@i]);
    }
    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
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3122
  • Reputation:   1614
  • Joined:  03/26/12
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

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;
		.@count = getmapunits(BL_PC, "payon", .@units);
		for (.@i = 0; .@i < .@count; .@i++)
		{
			attachrid .@units[.@i];
			addtimer(0,strnpcinfo(0)+"::OnHPBar");
		}
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	.@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		.@U_HP = getunitdata (.mobGID,UMOB_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;
}

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  271
  • Reputation:   62
  • Joined:  02/04/19
  • Last Seen:  

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;
		.@count = getmapunits(BL_PC, "payon", .@units);
		for (.@i = 0; .@i < .@count; .@i++)
		{
			attachrid .@units[.@i];
			addtimer(0,strnpcinfo(0)+"::OnHPBar");
		}
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	.@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		.@U_HP = getunitdata (.mobGID,UMOB_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;
}

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)

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  109
  • Reputation:   5
  • Joined:  03/17/16
  • Last Seen:  

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;
		.@count = getmapunits(BL_PC, "payon", .@units);
		for (.@i = 0; .@i < .@count; .@i++)
		{
			attachrid .@units[.@i];
			addtimer(0,strnpcinfo(0)+"::OnHPBar");
		}
	}
	end;

OnDie:
	.HP_Bar = false;
	end;

OnHPBar:
	.@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		.@U_HP = getunitdata (.mobGID,UMOB_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;
}

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

Link to comment
Share on other sites

  • 0

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

        .@count = getunits(BL_PC, .@units, false, "payon");
        for (.@i = 0; .@i < .@count; .@i++)
            addtimer(0,strnpcinfo(0)+"::OnHPBar", .@units[.@i]);

change to

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

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  109
  • Reputation:   5
  • Joined:  03/17/16
  • Last Seen:  

18 hours ago, Emistry said:

        .@count = getunits(BL_PC, .@units, false, "payon");
        for (.@i = 0; .@i < .@count; .@i++)
            addtimer(0,strnpcinfo(0)+"::OnHPBar", .@units[.@i]);

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 :        .@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
    20 :        while (.HP_Bar != false)
    21 :        {
    22 :                .@U_HP = getunitdata (.mobGID,UMOB_HP);
*   23 :                .@P_HP = (@'.'U_HP*100)/.@U_MAXHP;
    24 :
    25 :                cutin(.@P_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:
	.@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		.@U_HP = getunitdata (.mobGID,UMOB_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;
}

TIA

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

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 :        .@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
    20 :        while (.HP_Bar != false)
    21 :        {
    22 :                .@U_HP = getunitdata (.mobGID,UMOB_HP);
*   23 :                .@P_HP = (@'.'U_HP*100)/.@U_MAXHP;
    24 :
    25 :                cutin(.@P_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:
	.@U_MAXHP = getunitdata (.mobGID,UMOB_MAXHP);
	while (.HP_Bar != false)
	{
		.@U_HP = getunitdata (.mobGID,UMOB_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;
}

TIA

.@P_HP = (@'.'U_HP*100)/.@U_MAXHP;

to:

.@P_HP = (.@U_HP*100)/.@U_MAXHP;
  • Upvote 1
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...