Jump to content
  • 0

Can attack poring only if wearing knife!


caspa

Question


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

hi guys.. i have a code here that if i wear a knife i can't attack anyone or any monster

            if(pc_isequipped(sd, 1202)){
            clif_displaymessage(sd->fd, "Can't attack while on Mount.");
            unit_stop_attack(src);
            return 0;
        }



however i was wondering if its possible to create a similar code but instead of can't attack to anything at all, is if i wear a knife i can only attack the monster poring... this is for GOLD farming purposes! ? thank you guys!
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

Change your code to this:

if (pc_isequipped(sd, 1202) && md->mob_id != 1002) {
	clif_displaymessage(sd->fd, "Can't attack while on Mount.");
	unit_stop_attack(src);
	return 0;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

2 hours ago, MathReaper said:

Change your code to this:


if (pc_isequipped(sd, 1202) && md->mob_id != 1002) {
	clif_displaymessage(sd->fd, "Can't attack while on Mount.");
	unit_stop_attack(src);
	return 0;
}

 

 

1233.PNG

i got this kind of error ?

Edited by caspa
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

4 minutes ago, caspa said:

 

1233.PNG

i got this kind of error ?

In what function are you trying to apply that modification? If it's unit_attack, try to modify it to that:

struct mob_data* md = BL_CAST(BL_MOB, target);
if (pc_isequipped(sd, 1202) && md->mob_id != 1002) {
	clif_displaymessage(sd->fd, "Can't attack while on Mount.");
	unit_stop_attack(src);
	return 0;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

3 minutes ago, MathReaper said:

In what function are you trying to apply that modification? If it's unit_attack, try to modify it to that:


struct mob_data* md = BL_CAST(BL_MOB, target);
if (pc_isequipped(sd, 1202) && md->mob_id != 1002) {
	clif_displaymessage(sd->fd, "Can't attack while on Mount.");
	unit_stop_attack(src);
	return 0;
}

 

its from unit.c

under from this src codes

 
	/*==========================================
 * 攻撃要求
 * typeが1なら継続攻撃
 *------------------------------------------*/
int unit_attack(struct block_list *src,int target_id,int continuous)
{
    struct block_list *target;
    struct unit_data  *ud;
	    nullpo_ret(ud = unit_bl2ud(src));
	    target = map_id2bl(target_id);
    if( target==NULL || status_isdead(target) )
    {
        unit_unattackable(src);
        return 1;
    }
    if( src->type == BL_PC )
    {
        TBL_PC* sd = (TBL_PC*)src;
        if( target->type == BL_NPC )
        { // monster npcs [Valaris]
            npc_click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
            return 0;
        }
        if( pc_is90overweight(sd) )
        { // overweight - stop attacking
            unit_stop_attack(src);
            return 0;
        }
            if (pc_isequipped(sd, 23310)) {
            clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
            unit_stop_attack(src);
            return 0;
        }
    }


BTW this is an eathena emulator ? hope u can help

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

10 minutes ago, caspa said:

its from unit.c

under from this src codes
 


 
	/*==========================================
 * 攻撃要求
 * typeが1なら継続攻撃
 *------------------------------------------*/
int unit_attack(struct block_list *src,int target_id,int continuous)
{
    struct block_list *target;
    struct unit_data  *ud;
	    nullpo_ret(ud = unit_bl2ud(src));
	    target = map_id2bl(target_id);
    if( target==NULL || status_isdead(target) )
    {
        unit_unattackable(src);
        return 1;
    }
    if( src->type == BL_PC )
    {
        TBL_PC* sd = (TBL_PC*)src;
        if( target->type == BL_NPC )
        { // monster npcs [Valaris]
            npc_click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
            return 0;
        }
        if( pc_is90overweight(sd) )
        { // overweight - stop attacking
            unit_stop_attack(src);
            return 0;
        }
            if (pc_isequipped(sd, 23310)) {
            clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
            unit_stop_attack(src);
            return 0;
        }
    }


BTW this is an eathena emulator ? hope u can help

Okay, nothing that I can't do.

Try this, if doesn't work, post here the errors.

int unit_attack(struct block_list *src,int target_id,int continuous)
{
	struct block_list *target;
	struct unit_data  *ud;
	struct mob_data* md;
	nullpo_ret(ud = unit_bl2ud(src));
	target = map_id2bl(target_id);
	md = BL_CAST(BL_MOB, target);
	
	if( target==NULL || status_isdead(target) )
	{
		unit_unattackable(src);
		return 1;
	}
	if( src->type == BL_PC )
	{
		TBL_PC* sd = (TBL_PC*)src;
		if( target->type == BL_NPC )
		{ // monster npcs [Valaris]
			npc_click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
			return 0;
		}
		if( pc_is90overweight(sd) )
		{ // overweight - stop attacking
			unit_stop_attack(src);
			return 0;
		}
		if (pc_isequipped(sd, 23310) && md->mob_id != 1002) {
			clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
			unit_stop_attack(src);
			return 0;
		}
	}
}

 

Edited by MathReaper
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

8 minutes ago, MathReaper said:

Okay, nothing that I can't do.

Try this, if doesn't work, post here the errors.


int unit_attack(struct block_list *src,int target_id,int continuous)
{
    struct block_list *target;
    struct unit_data  *ud;
	struct mob_data* md;
	nullpo_ret(ud = unit_bl2ud(src));
	target = map_id2bl(target_id);
	md = BL_CAST(BL_MOB, target);
	
    if( target==NULL || status_isdead(target) )
    {
        unit_unattackable(src);
        return 1;
    }
    if( src->type == BL_PC )
    {
        TBL_PC* sd = (TBL_PC*)src;
        if( target->type == BL_NPC )
        { // monster npcs [Valaris]
            npc_click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
            return 0;
        }
        if( pc_is90overweight(sd) )
        { // overweight - stop attacking
            unit_stop_attack(src);
            return 0;
        }
        if (pc_isequipped(sd, 23310) && md->mob_id != 1002) {
            clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
            unit_stop_attack(src);
            return 0;
        }
    }

 

 

231313.PNG

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

2 minutes ago, caspa said:

 

231313.PNG

Mismatching '}' in the code xD.

Here: 

int unit_attack(struct block_list *src, int target_id, int continuous)
{
	struct block_list *target;
	struct unit_data  *ud;
	struct mob_data* md;
	nullpo_ret(ud = unit_bl2ud(src));
	target = map_id2bl(target_id);
	md = BL_CAST(BL_MOB, target);

	if (target == NULL || status_isdead(target))
	{
		unit_unattackable(src);
		return 1;
	}
	if (src->type == BL_PC)
	{
		TBL_PC* sd = (TBL_PC*)src;
		if (target->type == BL_NPC)
		{ // monster npcs [Valaris]
			npc_click(sd, (TBL_NPC*)target); // submitted by leinsirk10 [Celest]
			return 0;
		}
		if (pc_is90overweight(sd))
		{ // overweight - stop attacking
			unit_stop_attack(src);
			return 0;
		}
		if (pc_isequipped(sd, 23310) && md->mob_id != 1002) {
			clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
			unit_stop_attack(src);
			return 0;
		}
	}
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

8 minutes ago, MathReaper said:

Mismatching '}' in the code xD.

Here: 


int unit_attack(struct block_list *src, int target_id, int continuous)
{
	struct block_list *target;
	struct unit_data  *ud;
	struct mob_data* md;
	nullpo_ret(ud = unit_bl2ud(src));
	target = map_id2bl(target_id);
	md = BL_CAST(BL_MOB, target);

	if (target == NULL || status_isdead(target))
	{
		unit_unattackable(src);
		return 1;
	}
	if (src->type == BL_PC)
	{
		TBL_PC* sd = (TBL_PC*)src;
		if (target->type == BL_NPC)
		{ // monster npcs [Valaris]
			npc_click(sd, (TBL_NPC*)target); // submitted by leinsirk10 [Celest]
			return 0;
		}
		if (pc_is90overweight(sd))
		{ // overweight - stop attacking
			unit_stop_attack(src);
			return 0;
		}
		if (pc_isequipped(sd, 23310) && md->mob_id != 1002) {
			clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
			unit_stop_attack(src);
			return 0;
		}
	}
}

 

ERROR again brother...

2313123131.PNG

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

Okay, that's the last one:

int unit_attack(struct block_list *src, int target_id, int continuous)
{
	struct block_list *target;
	struct unit_data  *ud;
	struct mob_data* md;
	nullpo_ret(ud = unit_bl2ud(src));
	target = map_id2bl(target_id);
	md = BL_CAST(BL_MOB, target);

	if (target == NULL || status_isdead(target))
	{
		unit_unattackable(src);
		return 1;
	}
	if (src->type == BL_PC)
	{
		TBL_PC* sd = (TBL_PC*)src;
		if (target->type == BL_NPC)
		{ // monster npcs [Valaris]
			npc_click(sd, (TBL_NPC*)target); // submitted by leinsirk10 [Celest]
			return 0;
		}
		if (pc_is90overweight(sd))
		{ // overweight - stop attacking
			unit_stop_attack(src);
			return 0;
		}
		if (pc_isequipped(sd, 23310) && md->class_ != 1002) {
			clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
			unit_stop_attack(src);
			return 0;
		}
	}
}

Note: rewrite manually all that code that I've sended to you, because if you try to copy by here, you'll copy invalid ASCII characters (this forum editor is a bit crazy) and this will cause syntax errors.

Edited by MathReaper
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

20 minutes ago, MathReaper said:

Okay, that's the last one:


int unit_attack(struct block_list *src, int target_id, int continuous)
{
	struct block_list *target;
	struct unit_data  *ud;
	struct mob_data* md;
	nullpo_ret(ud = unit_bl2ud(src));
	target = map_id2bl(target_id);
	md = BL_CAST(BL_MOB, target);

	if (target == NULL || status_isdead(target))
	{
		unit_unattackable(src);
		return 1;
	}
	if (src->type == BL_PC)
	{
		TBL_PC* sd = (TBL_PC*)src;
		if (target->type == BL_NPC)
		{ // monster npcs [Valaris]
			npc_click(sd, (TBL_NPC*)target); // submitted by leinsirk10 [Celest]
			return 0;
		}
		if (pc_is90overweight(sd))
		{ // overweight - stop attacking
			unit_stop_attack(src);
			return 0;
		}
		if (pc_isequipped(sd, 23310) && md->class_ != 1002) {
			clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
			unit_stop_attack(src);
			return 0;
		}
	}
}

Note: rewrite manually all that code that I've sended to you, because if you try to copy by here, you'll copy invalid ASCII characters (this forum editor is a bit crazy) and this will cause syntax errors.

its still doesnt work bro. T_T

anyway thank you so much for your help T_T

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

7 minutes ago, caspa said:

its still doesnt work bro. T_T

anyway thank you so much for your help T_T

Nah, send me your errors, I'll check it for you.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  57
  • Reputation:   14
  • Joined:  09/01/18
  • Last Seen:  

Reverse everything and try only to modify the piece of code that you are asking:

struct mob_data* md = BL_CAST(BL_MOB, target);
if (pc_isequipped(sd, 23310) && md->class_ != 1002) {
	clif_displaymessage(sd->fd, "You can only attack a crystal while on mining form.");
	unit_stop_attack(src);
	return 0;
}

 

Edited by MathReaper
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...