Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. /**
  2. * Timer function for revealing/hiding mini map positions.
  3. * Also handles player AFK mechanic.
  4. * @see DBApply
  5. * @see hBG_send_xy_timer
  6. * @param data battleground data pointer.
  7. * @return int
  8. */
  9. int hBG_send_xy_timer_sub(union DBKey key, struct DBData *data, va_list ap)
  10. {
  11. struct battleground_data *bgd = DB->data2ptr(data);
  12. struct hBG_data *hBGd = getFromBGDATA(bgd, 0);
  13. char output[128];
  14. int i, m, idle_announce = hBG_config_get("battle_configuration/hBG_idle_announce"),
  15. idle_autokick = hBG_config_get("battle_configuration/hBG_idle_autokick");
  16.  
  17. nullpo_ret(bgd);
  18. nullpo_ret(hBGd);
  19.  
  20. m = map->mapindex2mapid(bgd->mapindex);
  21. hBGd->reveal_flag = !hBGd->reveal_flag; // Switch
  22.  
  23. for (i = 0; i < MAX_BG_MEMBERS; i++) {
  24. struct map_session_data *sd = bgd->members[i].sd;
  25. struct hBG_map_session_data *hBGsd = NULL;
  26.  
  27. if (sd == NULL || (hBGsd = getFromMSD(sd, 1)) == NULL)
  28. continue;
  29.  
  30. if (idle_autokick && DIFF_TICK(sockt->last_tick, sd->idletime) >= idle_autokick
  31. && hBGd->g && map->list[sd->bl.m].flag.battleground)
  32. {
  33. sprintf(output, "[Battlegrounds] %s has been kicked for being AFK.", sd->status.name);
  34. clif->broadcast2(&sd->bl, output, (int)strlen(output)+1, hBGd->color, 0x190, 20, 0, 0, BG);
  35.  
  36. hBG_team_leave(sd,3);
  37.  
  38. clif->message(sd->fd, "You have been kicked from the battleground because of your AFK status.");
  39. pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 3);
  40. continue;
  41. } else if (sd->bl.x != bgd->members[i].x || sd->bl.y != bgd->members[i].y) { // xy update
  42. bgd->members[i].x = sd->bl.x;
  43. bgd->members[i].y = sd->bl.y;
  44. clif->bg_xy(sd);
  45. }
  46.  
  47. if (hBGd->reveal_pos && hBGd->reveal_flag && sd->bl.m == m)
  48. map->foreachinmap(hBG_reveal_pos, m, BL_PC, sd, 1, hBGd->color);
  49.  
  50. // Message for AFK Idling
  51. if (idle_announce && DIFF_TICK(sockt->last_tick, sd->idletime) >= idle_announce && !hBGsd->state.afk && hBGd->g)
  52. { // Set AFK status and announce to the team.
  53. hBGsd->state.afk = 1;
  54. sprintf(output, "%s : %s seems to be away. AFK Warning - Can be kicked out with @reportafk.", hBGd->g->name, sd->status.name);
  55. hBG_send_chat_message(bgd, sd->bl.id, sd->status.name, output, (int)strlen(output) + 1);
  56. }
  57. }
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement