Hello, i'm still new to Ragnarok coding and have decided to fiddle with Battlegrounds.
The current server im looking at is using modified bg and has a @reportafk command that kicks and afk player.
It does work, but the on the kicked-player's client it is black screen/or current BG map with all the NPC's on the main town.
below is the code at src/custom/atcommand.inc
ACMD_FUNC(reportafk)
{
map_session_data *pl_sd;
nullpo_retr(-1,sd);
if( !sd->bg_id )
clif_displaymessage(fd, msg_txt(sd, 2029)); // This command is reserved for Battleground
else if( !sd->bmaster_flag && battle_config.bg_reportafk_leaderonly )
clif_displaymessage(fd, msg_txt(sd, 2014)); // This command is reserved for Team Leaders.
else if( !message || !*message )
clif_displaymessage(fd, msg_txt(sd, 2030)); // Please enter the AFK player's nick (usage: @reportafk <name>).
else if( (pl_sd = map_nick2sd((char *)message,false)) == NULL )
clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
else if( sd->bg_id != pl_sd->bg_id )
clif_displaymessage(fd, msg_txt(sd,2026)); // The player is not part of your Team.
else if( sd == pl_sd )
clif_displaymessage(fd, msg_txt(sd,2031)); // You cannot report yourself.
else if( pl_sd->state.bg_afk == 0 )
clif_displaymessage(fd, msg_txt(sd,2032)); // The player is not AFK in this Battleground
else { // Everytest OK!
std::shared_ptr<s_battleground_data> bg = util::umap_find(bg_team_db, sd->bg_id);
if(!bg)
return -1;
bg_team_leave(pl_sd, true, true);
clif_displaymessage(pl_sd->fd, msg_txt(sd,2001)); // You have been kicked from Battleground for your AFK status
pc_setpos(pl_sd,mapindex_name2id(pl_sd->status.save_point.map),pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_OUTSIGHT);
clif_refresh(pl_sd);
sprintf(atcmd_output, msg_txt(sd, 2034), pl_sd->status.name); // - AFK [%s] Kicked -
clif_broadcast2(&sd->bl, atcmd_output, (int)strlen(atcmd_output)+1, bg->color, 0x190, 20, 0, 0, BG);
return 0;
}
return -1;
}
A. [Kicked player's Client]
B. Kicked player's Client vs Another player's view
Any ideas why this is happening? any help will be much appreciated