Jump to content
  • 0

Talking with fakename


Evelynn

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  93
  • Reputation:   14
  • Joined:  12/12/11
  • Last Seen:  

Hi, I would like to request making whenever you talk with a fakename, it'll show that name instead of your own.

@fakename Poring

When you talk it will be

Poring : Hi!

Thanks!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  22
  • Reputation:   2
  • Joined:  01/08/12
  • Last Seen:  

Try:

/nlb Poring: Hi!

(for local map)

or

/nb Poring: Hi!

(for global)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

Since you're using rA newest version, it's already implemented in main chat.

If you need it to PM, party, guild etc, follow these changes:

In clif.c

Find:

/// Validates and processes whispered messages (CZ_WHISPER).
/// 0096 <packet len>.W <nick>.24B <message>.?B
void clif_parse_WisMessage(int fd, struct map_session_data* sd)
{
struct map_session_data* dstsd;
int i;

char *target, *message;
int namelen, messagelen;

// validate packet and retrieve name and message
if( !clif_process_message(sd, 1, &target, &namelen, &message, &messagelen) )
return;

if (is_atcommand(fd, sd, message, 1)  )
return;

if (sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT))
return;

if (battle_config.min_chat_delay)
{ //[skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) {
return;
}
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

// Chat logging type 'W' / Whisper
log_chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);

//-------------------------------------------------------//
//   Lordalfa - Paperboy - To whisper NPC commands	   //
//-------------------------------------------------------//
if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4))
{
char* str = target+4; //Skip the NPC: string part.
struct npc_data* npc;
if ((npc = npc_name2id(str)))
{
char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX];
char *split;
char output[256];

str = message;
// skip codepage indicator, if detected
if( str[0] == '|' && strlen(str) >= 4 )
str += 3;
for( i = 0; i < NUM_WHISPER_VAR; ++i )
{// Splits the message using '#' as separators
split = strchr(str,'#');
if( split == NULL )
{ // use the remaining string
safestrncpy(split_data[i], str, ARRAYLENGTH(split_data[i]));
for( ++i; i < NUM_WHISPER_VAR; ++i )
split_data[i][0] = '\0';
break;
}
*split = '\0';
safestrncpy(split_data[i], str, ARRAYLENGTH(split_data[i]));
str = split+1;
}

for( i = 0; i < NUM_WHISPER_VAR; ++i )
{
sprintf(output, "@whispervar%d$", i);
set_var(sd,output,(char *) split_data[i]);
}

sprintf(output, "%s::OnWhisperGlobal", npc->exname);
npc_event(sd,output,0); // Calls the NPC label

return;
}
}

// Main chat [LuzZza]
if(strcmpi(target, main_chat_nick) == 0)
{
if(!sd->state.mainchat)
clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
else {
// send the main message using inter-server system
intif_main_message( sd, message );
}

return;
}

// searching destination character
dstsd = map_nick2sd(target);

if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0)
{
// player is not on this map-server
// At this point, don't send wisp/page if it's not exactly the same name, because (example)
// if there are 'Test' player on an other map-server and 'test' player on this map-server,
// and if we ask for 'Test', we must not contact 'test' player
// so, we send information to inter-server, which is the only one which decide (and copy correct name).
intif_wis_message(sd, target, message, messagelen);
return;
}

// if player ignores everyone
if (dstsd->state.ignoreAll)
{
if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd))
clif_wis_end(fd, 1); // 1: target character is not loged in
else
clif_wis_end(fd, 3); // 3: everyone ignored by target
return;
}
// if player ignores the source character
ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->status.name) == 0);
if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0')
{ // source char present in ignore list
clif_wis_end(fd, 2); // 2: ignored by target
return;
}

// if player is autotrading
if( dstsd->state.autotrade == 1 )
{
char output[256];
sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
clif_wis_message(fd, wisp_server_name, output, strlen(output) + 1);
return;
}

// notify sender of success
clif_wis_end(fd, 0); // 0: success to send wisper

// Normal message
clif_wis_message(dstsd->fd, sd->status.name, message, messagelen);
}

Change to:

/// Validates and processes whispered messages (CZ_WHISPER).
/// 0096 <packet len>.W <nick>.24B <message>.?B
void clif_parse_WisMessage(int fd, struct map_session_data* sd)
{
struct map_session_data* dstsd;
int i;

char *target, *message;
int namelen, messagelen;

// validate packet and retrieve name and message
if( !clif_process_message(sd, 1, &target, &namelen, &message, &messagelen) )
return;

if (is_atcommand(fd, sd, message, 1)  )
return;

if (sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT))
return;

if (battle_config.min_chat_delay)
{ //[skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) {
return;
}
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

// Chat logging type 'W' / Whisper
log_chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);

//-------------------------------------------------------//
//   Lordalfa - Paperboy - To whisper NPC commands	   //
//-------------------------------------------------------//
if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4))
{
char* str = target+4; //Skip the NPC: string part.
struct npc_data* npc;
if ((npc = npc_name2id(str)))
{
char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX];
char *split;
char output[256];

str = message;
// skip codepage indicator, if detected
if( str[0] == '|' && strlen(str) >= 4 )
str += 3;
for( i = 0; i < NUM_WHISPER_VAR; ++i )
{// Splits the message using '#' as separators
split = strchr(str,'#');
if( split == NULL )
{ // use the remaining string
safestrncpy(split_data[i], str, ARRAYLENGTH(split_data[i]));
for( ++i; i < NUM_WHISPER_VAR; ++i )
split_data[i][0] = '\0';
break;
}
*split = '\0';
safestrncpy(split_data[i], str, ARRAYLENGTH(split_data[i]));
str = split+1;
}

for( i = 0; i < NUM_WHISPER_VAR; ++i )
{
sprintf(output, "@whispervar%d$", i);
set_var(sd,output,(char *) split_data[i]);
}

sprintf(output, "%s::OnWhisperGlobal", npc->exname);
npc_event(sd,output,0); // Calls the NPC label

return;
}
}

// Main chat [LuzZza]
if(strcmpi(target, main_chat_nick) == 0)
{
if(!sd->state.mainchat)
clif_displaymessage(fd, msg_txt(388)); // You should enable main chat with "@main on" command.
else {
// send the main message using inter-server system
intif_main_message( sd, message );
}

return;
}

// searching destination character
dstsd = map_nick2sd(target);

if (dstsd == NULL || strcmp(dstsd->fakename[0] ? dstsd->fakename : dstsd->status.name, target) != 0)
{
// player is not on this map-server
// At this point, don't send wisp/page if it's not exactly the same name, because (example)
// if there are 'Test' player on an other map-server and 'test' player on this map-server,
// and if we ask for 'Test', we must not contact 'test' player
// so, we send information to inter-server, which is the only one which decide (and copy correct name).
intif_wis_message(sd, target, message, messagelen);
return;
}

// if player ignores everyone
if (dstsd->state.ignoreAll)
{
if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd))
clif_wis_end(fd, 1); // 1: target character is not loged in
else
clif_wis_end(fd, 3); // 3: everyone ignored by target
return;
}
// if player ignores the source character
ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->fakename[0] ? sd->fakename : sd->status.name) == 0);
if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0')
{ // source char present in ignore list
clif_wis_end(fd, 2); // 2: ignored by target
return;
}

// if player is autotrading
if( dstsd->state.autotrade == 1 )
{
char output[256];
sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->fakename[0] ? dstsd->fakename : dstsd->status.name);
clif_wis_message(fd, wisp_server_name, output, strlen(output) + 1);
return;
}

// notify sender of success
clif_wis_end(fd, 0); // 0: success to send wisper

// Normal message
clif_wis_message(dstsd->fd, sd->fakename[0] ? sd->fakename : sd->status.name, message, messagelen);
}

Find:

/// Validates and processes party messages (CZ_REQUEST_CHAT_PARTY).
/// 0108 <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
int textlen = RFIFOW(fd,2) - 4;

char *name, *message;
int namelen, messagelen;

// validate packet and retrieve name and message
if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;

if( is_atcommand(fd, sd, message, 1)  )
return;

if( sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) )
return;

if( battle_config.min_chat_delay )
{ //[skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

party_send_message(sd, text, textlen);
}

Change to:

/// Validates and processes party messages (CZ_REQUEST_CHAT_PARTY).
/// 0108 <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
int textlen = RFIFOW(fd,2) - 4;

char *name, *message, *fakename;
int namelen, messagelen;

// validate packet and retrieve name and message
if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;

if( is_atcommand(fd, sd, message, 1)  )
return;

if( sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) )
return;

if( battle_config.min_chat_delay )
{ //[skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

if (sd->fakename[0])
{
fakename = (char*) malloc(strlen(sd->fakename) + messagelen + 3);
strcpy(fakename, sd->fakename);
strcat(fakename, " : ");
strcat(fakename, message);
textlen = strlen(fakename) + 1;
}

party_send_message(sd, sd->fakename[0] ? fakename : text, textlen);
}

Find:

/// Validates and processes guild messages (CZ_GUILD_CHAT).
/// 017e <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
int textlen = RFIFOW(fd,2) - 4;

char *name, *message;
int namelen, messagelen;

// validate packet and retrieve name and message
if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;

if( is_atcommand(fd, sd, message, 1) )
return;

if( sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) )
return;

if( battle_config.min_chat_delay )
{ //[skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

if( sd->bg_id )
bg_send_message(sd, text, textlen);
else
guild_send_message(sd, text, textlen);
}

Change to:

/// Validates and processes guild messages (CZ_GUILD_CHAT).
/// 017e <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
int textlen = RFIFOW(fd,2) - 4;

char *name, *message, *fakename;
int namelen, messagelen;

// validate packet and retrieve name and message
if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;

if( is_atcommand(fd, sd, message, 1) )
return;

if( sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) )
return;

if( battle_config.min_chat_delay )
{ //[skotlex]
if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

if (sd->fakename[0])
{
fakename = (char*) malloc(strlen(sd->fakename) + messagelen + 3);
strcpy(fakename, sd->fakename);
strcat(fakename, " : ");
strcat(fakename, message);
textlen = strlen(fakename) + 1;
}

if( sd->bg_id )
bg_send_message(sd, sd->fakename[0] ? fakename : text, textlen);
else
guild_send_message(sd, sd->fakename[0] ? fakename : text, textlen);
}

Find:

/// Validates and processes battlechat messages [pakpil] (CZ_BATTLEFIELD_CHAT).
/// 0x2db <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_BattleChat(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
int textlen = RFIFOW(fd,2) - 4;

char *name, *message;
int namelen, messagelen;

if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;

if( is_atcommand(fd, sd, message, 1) )
return;

if( sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) )
return;

if( battle_config.min_chat_delay )
{
if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

bg_send_message(sd, text, textlen);
}

Change to:

/// Validates and processes battlechat messages [pakpil] (CZ_BATTLEFIELD_CHAT).
/// 0x2db <packet len>.W <text>.?B (<name> : <message>) 00
void clif_parse_BattleChat(int fd, struct map_session_data* sd)
{
const char* text = (char*)RFIFOP(fd,4);
int textlen = RFIFOW(fd,2) - 4;

char *name, *message;
int namelen, messagelen;

if( !clif_process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;

if( is_atcommand(fd, sd, message, 1) )
return;

if( sd->sc.data[sC_BERSERK] || (sd->sc.data[sC_NOCHAT] && sd->sc.data[sC_NOCHAT]->val1&MANNER_NOCHAT) )
return;

if( battle_config.min_chat_delay )
{
if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
return;
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
}

if (sd->fakename[0])
{
fakename = (char*) malloc(strlen(sd->fakename) + messagelen + 3);
strcpy(fakename, sd->fakename);
strcat(fakename, " : ");
strcat(fakename, message);
textlen = strlen(fakename) + 1;
}

bg_send_message(sd, sd->fakename[0] ? fakename : text, textlen);
}

In intif.c

Find:

/// send a message using the main chat system
/// <sd>		 the source of message
/// <message>	the message that was sent
int intif_main_message(struct map_session_data* sd, const char* message)
{
char output[256];

nullpo_ret(sd);

// format the message for main broadcasting
snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message );

// send the message using the inter-server broadcast service
intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );

// log the chat message
log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );

return 0;
}

Change to:

/// send a message using the main chat system
/// <sd>		 the source of message
/// <message>	the message that was sent
int intif_main_message(struct map_session_data* sd, const char* message)
{
char output[256];

nullpo_ret(sd);

// format the message for main broadcasting
snprintf( output, sizeof(output), msg_txt(386), sd->fakename[0] ? sd->fakename : sd->status.name, message );

// send the message using the inter-server broadcast service
intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );

// log the chat message
log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );

return 0;
}

In map.c

Find:

/*==========================================
* Search session data from a nick name
* (without sensitive case if necessary)
* return map_session_data pointer or NULL
*------------------------------------------*/
struct map_session_data * map_nick2sd(const char *nick)
{
struct map_session_data* sd;
struct map_session_data* found_sd;
struct s_mapiterator* iter;
size_t nicklen;
int qty = 0;

if( nick == NULL )
return NULL;

nicklen = strlen(nick);
iter = mapit_getallusers();

found_sd = NULL;
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
{
if( battle_config.partial_name_scan )
{// partial name search
if( strnicmp(sd->status.name, nick, nicklen) == 0 )
{
found_sd = sd;

if( strcmp(sd->status.name, nick) == 0 )
{// Perfect Match
qty = 1;
break;
}

qty++;
}
}
else if( strcasecmp(sd->status.name, nick) == 0 )
{// exact search only
found_sd = sd;
break;
}
}
mapit_free(iter);

if( battle_config.partial_name_scan && qty != 1 )
found_sd = NULL;

return found_sd;
}

Change to:

/*==========================================
* Search session data from a nick name
* (without sensitive case if necessary)
* return map_session_data pointer or NULL
*------------------------------------------*/
struct map_session_data * map_nick2sd(const char *nick)
{
struct map_session_data* sd;
struct map_session_data* found_sd;
struct s_mapiterator* iter;
size_t nicklen;
int qty = 0;

if( nick == NULL )
return NULL;

nicklen = strlen(nick);
iter = mapit_getallusers();

found_sd = NULL;
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
{
if( battle_config.partial_name_scan )
{// partial name search
if( strnicmp(sd->fakename[0] ? sd->fakename : sd->status.name, nick, nicklen) == 0 )
{
found_sd = sd;

if( strcmp(sd->fakename[0] ? sd->fakename : sd->status.name, nick) == 0 )
{// Perfect Match
qty = 1;
break;
}

qty++;
}
}
else if( strcasecmp(sd->fakename[0] ? sd->fakename : sd->status.name, nick) == 0 )
{// exact search only
found_sd = sd;
break;
}
}
mapit_free(iter);

if( battle_config.partial_name_scan && qty != 1 )
found_sd = NULL;

return found_sd;
}

Some credits go to Cretino from Cronus Emulator, as I readapted his changes to rA.

With these changes, when fakename is enabled on the target and you send him a pm, it will find for fakename not for his real nick.

I didn't tested everything yet(but I'll), but if you need something different or any error occurs, I'll try helping.

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