// --------------------------------------------------------------------------------------------------
//                                  Notifications Package
// --------------------------------------------------------------------------------------------------

Introduction:

The notification package is to inform players of important events that happened while they were 
(maybe) offline.

// --------------------------------------------------------------------------------------------------
//                  How do I send a global notification message to all players?
// --------------------------------------------------------------------------------------------------

The syntax is not too difficult. First you need to include the proper include file though:

Code:

  include "../pkg/foundations/notification/notification"; 

Now looking at the syntax, the following sample shall explain it

Code:

  // 
  // send a notification message to all enabled accounts 
  // 
  // messageDataArr[1]:   serial - serial sent by the webpage 
  //                              (set it to 0 to skip the serial test) 
  // messageDataArr[2]:   message - array of strings 
  // messageDataArr[3]:   sender - accountname 
  // messageDataArr[4]:   subject - message subject string 
  // messageDataArr[5]:   date - string 
  // 
  // return values: 
  // -1 ... error, messageDataArr is not filled out 
  // -2 ... error, serial was found (message was already sent) 
  // >0 ... message id of the stored message 
  // 

  ns_addGlobalMessage( messageDataArr ); 

But maybe its better understandable with this sample code:

Code:

  use uo; 
  use os; 
  include "../pkg/foundations/notification/notification"; 
  include "../scripts/include/clock"; 

  messageDataArr := {}; 
  messageDataArr[1] := 0; 
  messageDataArr[2] := { "This is a test!", "And this is the 2. line" }; 
  messageDataArr[3] := "omega"; 
  messageDataArr[4] := "Test message"; 
  messageDataArr[5] := readClockAsShortString(); // e.g. "2w 5h 2m 30s" for 2 weeks 5 hours 2 minutes 30 seconds 

  // send a notification message to all enabled accounts 
  ns_addGlobalMessage( messageDataArr ); 

// --------------------------------------------------------------------------------------------------
//               How do I send a private notification message to a single player?
// --------------------------------------------------------------------------------------------------

The syntax is not too difficult. First you need to include the proper include file though:

Code:

  include "../pkg/foundations/notification/notification"; 

Now looking at the syntax, the following sample shall explain it

Code:
  // send a private message to account "accountname" 
  // 
  // accountname:         string - accountname of the user (e.g. who.acct.name) 
  // 
  // messageDataArr[1]:   serial - serial sent by the webpage (set it to 0 to skip the serial test) 
  // messageDataArr[2]:   message - array of strings 
  // messageDataArr[3]:   sender - accountname  
  // messageDataArr[4]:   subject - message subject string 
  // messageDataArr[5]:   date - string 
  // 
  // return values: 
  // -1 ... error, not enough parameter data 
  // -2 ... error, could not assign the stored message to the account 
  // -3 ... error, messageDataArr is not filled out 
  // -4 ... error, serial was found (message was already sent) 
  // >0 ... message id of the stored message 
  // 
 
  ns_addPrivateMessage( accountname, messageDataArr ) 

But maybe its better understandable with this sample code:

  Code:
  
  use uo; 
  use os; 
  include "../pkg/foundations/notification/notification"; 
  include "../scripts/include/clock"; 

  messageDataArr := {}; 
  messageDataArr[1] := 0; 
  messageDataArr[2] := { "This is a test!", "And this is the 2. line" }; 
  messageDataArr[3] := "omega"; 
  messageDataArr[4] := "Test message"; 
  messageDataArr[5] := readClockAsShortString(); // e.g. "2w 5h 2m 30s" for 2 weeks 5 hours 2 minutes 30 seconds 

  // send a notification to account firedancer 
  ns_addPrivateMessage( "firedancer", messageDataArr ); 

