@dpt command

Alexandria

New member
Messages
341
Points
0
Location
localhost
Hello guys,

I'm moving from rAthena to Hercules. I'm trying to add this custom command to my server but when i recompile it gives this error:

<anonymous>’ has no member named 

This is the command that imtrying to add to src/map/atcommand.c

ACMD(dpt){ nullpo_retr(-1, sd); if (!sd->state.pet_no_talk) { sd->state.pet_no_talk = 1; } else { sd->state.pet_no_talk = 0; } sprintf(atcmd_output, "%s pet talk.", (sd->state.pet_no_talk? "Disabled" : "Enabled")); clif_displaymessage(fd, atcmd_output); return 0;}
@dpt or @petmute: mutes/unmutes the pet.

Thank you.

 

 
Last edited by a moderator:
seems like the error is not in atcommand.c, can you please post more info about the command code itself?

 
if you updated the structs then i can't see any problem in the code but clif_displaymessage it should be changed to clif->message.

 
if you updated the structs then i can't see any problem in the code but clif_displaymessage it should be changed to clif->message.
Sorry, what does "if you updated the structs then i can't see any problem in the code" mean? I dont understand, Im so sorry.

 
if you updated the structs then i can't see any problem in the code but clif_displaymessage it should be changed to clif->message.
Sorry, what does "if you updated the structs then i can't see any problem in the code" mean? I dont understand, Im so sorry.
He Just mean, change

clif_displaymessage

to 

clif->message

 
Post the full code behind pet no talk. Just like @evilpuncker your problem is not in atcommand.c 

 
Last edited by a moderator:
if you updated the structs then i can't see any problem in the code but clif_displaymessage it should be changed to clif->message.
Sorry, what does "if you updated the structs then i can't see any problem in the code" mean? I dont understand, Im so sorry.
sorry, i wrote it in sucks way using mobile phone
default_smile.png


as i see here :

if (!sd->state.pet_no_talk) { sd->state.pet_no_talk = 1; } else { sd->state.pet_no_talk = 0; }
you have some custom variables added to state struct so make sure you have pet_no_talk in your struct

if you don't have it then you should add it.

you can find struct code at pc.h

also in your code you use clif_displaymessage and you can't call this function anymore after interface updates.

so you should call it from the interface.

simply change it to.

clif->message(fd, atcmd_output); 
 that all.

@Dastgir Pojee thank you explain what i meant
default_smile.png


 
But in-game the command gives error ("@dpt failed") and the pet keeps talking, so it doesn't work. Any idea what is going on and how to ffix it ? Thanks.

ss.jpg

 
Last edited by a moderator:
your code is not enough to make pet muted.

so i think you don't have full code. so simple it will not work.

 
your code is not enough to make pet muted.

so i think you don't have full code. so simple it will not work.
Do you mind if you help me to complete it? please? thanks
try this one.

atcommand.c

ACMD(dpt){ struct pet_data *pd; if(!sd->status.pet_id || !(pd=sd->pd)) { clif->message(fd, msg_txt(184)); return false; } if (!pd->pet_no_talk) { pd->pet_no_talk = 1; } else { pd->pet_no_talk = 0; } sprintf(atcmd_output, "%s pet talk.", (pd->pet_no_talk? "Disabled" : "Enabled")); clif->message(fd, atcmd_output); return 1;}
pet.h pet_data

int pet_no_talk : 1;
pet.c clif_pet_emotion after nullpo_retv(pd);

if(pd->pet_no_talk) { return; }
If you want to mute pet when their master use @pettalk just add this code at ACMD(pettalk)

Code:
	if(pd->pet_no_talk)	{		return false;	}
 
Last edited by a moderator:
I'm sorry for my late answer.

@bahbi

It didn't give any error when I was recompiling.

but it doesn't work, the pet still talks =[

I have done what you said but i'm not sure If i edit the files in the right way.

Do you mind if you check it? please

Thank you!

others.rar

 

Attachments

Last edited by a moderator:
atcommand.c

ACMD(dpt){ struct pet_data *pd; if(!sd->status.pet_id || !(pd=sd->pd)) { clif->message(fd, msg_txt(184)); return false; } if (!pd->pet_no_talk) { pd->pet_no_talk = 1; } else { pd->pet_no_talk = 0; } sprintf(atcmd_output, "%s pet talk.", (pd->pet_no_talk? "Disabled" : "Enabled")); clif->message(fd, atcmd_output); return 1;}


Code:
ACMD(pettalk){    char mes[100],temp[100];    struct pet_data *pd;+    if(sd->pd->pet_no_talk) {+  	 clif->message(fd, "pet muted.");+   	 return false;+    }    if ( battle_config.min_chat_delay ) {        if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 )            return true;        sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay;    } 
pet.h

struct pet_data {  struct block_list bl;  struct unit_data ud;  struct view_data vd;  struct s_pet pet;  struct status_data status;  struct mob_db *db;  struct s_pet_db *petDB;  int pet_hungry_timer;  int target_id;+   int pet_no_talk : 1;  struct {    unsigned skillbonus : 1;  } state;  int move_fail_count;  int64 next_walktime, last_thinktime;  short rate_fix;  //Support rate as modified by intimacy (1000 = 100%) [Skotlex]  struct pet_recovery* recovery;  struct pet_bonus* bonus;  struct pet_skill_attack* a_skill;  struct pet_skill_support* s_skill;  struct pet_loot* loot;  struct map_session_data *msd;};

clif.c

Code:
/// Notification about a pet's emotion/talk (ZC_PET_ACT)./// 01aa <id>.L <data>.L/// data:///	 @see CZ_PET_ACT.void clif_pet_emotion(struct pet_data *pd,int param){    unsigned char buf[16];    nullpo_retv(pd);    +    if(pd->pet_no_talk)+   	 return;            memset(buf,0,packet_len(0x1aa));    WBUFW(buf,0)=0x1aa;    WBUFL(buf,2)=pd->bl.id;    if(param >= 100 && pd->petDB->talk_convert_class) {        if(pd->petDB->talk_convert_class < 0)            return;        else if(pd->petDB->talk_convert_class > 0) {            // replace mob_id component of talk/act data            param -= (pd->pet.class_ - 100)*100;            param += (pd->petDB->talk_convert_class - 100)*100;        }    }            WBUFL(buf,6)=param;    clif->send(buf,packet_len(0x1aa),&pd->bl,AREA);}
 
Last edited by a moderator:
Back
Top