Cancel a Single Event

  • WhiskyTest
  • WhiskyTest's Avatar Topic Author
  • Offline
  • Gold Boarder
  • Gold Boarder
More
3 years 10 months ago #4950 by WhiskyTest
WhiskyTest created the topic: Cancel a Single Event
A function to cancel a single specific event, I used Ripley's change_duration as the model :)

I also added an "interrupt_events" function which I call in "command_interpreter", so you can have events interrupted or canceled just like how you become un-hidden if you hit enter or do anything else.
void event_cancel_specific(struct char_data *ch, event_id iId)
{

  struct event * pEvent;
  struct mud_event_data * pMudEvent = NULL;
  bool found = FALSE;

  if (ch->events == NULL)
    return;

  if (ch->events->iSize == 0)
    return;

  clear_simple_list();  

  while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
    if (!pEvent->isMudEvent)
      continue;
     pMudEvent = (struct mud_event_data * ) pEvent->event_obj;
    if (pMudEvent->iId == iId) {
     found = TRUE;
     break;
    }
  }

  if (found) 
      event_cancel(pEvent);
  
  return;
} 
void interrupt_events(struct char_data *ch)
{
    /* Cancel events that require player to wait before completion..
     * Replace 'eREPAIR' with your own events    
     */
    event_cancel_specific(ch, eREPAIR); 
   
}

Please Log in or Create an account to join the conversation.

Time to create page: 0.780 seconds