bool event_mobile_save(EVENT_DATA *event)
{
  D_MOBILE *dMob;

  /* Check to see if there is an owner of this event.
   * If there is no owner, we return TRUE, because
   * it's the safest - and post a bug message.
   */
  if ((dMob = event->owner.dMob) == NULL)
  {
    bug("event_mobile_save: no owner.");
    return TRUE;
  }

  /* save the actual player file */
  save_player(dMob);

  /* enqueue a new event to save the pfile in 2 minutes */
  event = alloc_event();
  event->fun = &event_mobile_save;
  event->type = EVENT_MOBILE_SAVE;
  add_event_mobile(event, dMob, 2 * 60 * PULSES_PER_SECOND);

  return FALSE;
}
Beispiel #2
0
/* function   :: init_events_mobile()
 * arguments  :: the mobile
 * ======================================================
 * this function should be called when a player is loaded,
 * it will initialize all updating events for that player.
 */
void init_events_player(D_MOBILE *dMob)
{
  EVENT_DATA *event;

  /* save the player every 2 minutes */
  event = alloc_event();
  event->fun = &event_mobile_save;
  event->type = EVENT_MOBILE_SAVE;
  add_event_mobile(event, dMob, 2 * 60 * PULSES_PER_SECOND);
}