Could you perhaps add a short example of what a typical news script would look like? I've been thinking of maybe writing some generic articles for the news.

How to create events for the newssystem in XTC
1. First you have to have your script, which can do, whatever you want, but
a) it should not run in a loop (the AL-Event-Handler will do that)
b) it should have several waits included, to prevent timing problems with other tasks
2. To include your script into the AL-Event-Handler, you will have to run plugin.XTC.Lib.Events.GetID.
This will return you an ID for your script.
3. Next step is to add your script with plugin.XTC.Lib.Events.Add
the arguments are
a) the previously obtained id
b) the name of your script (string)
c) the frequency (that can be random, once (for things that be executed only one time), or minutes (int))
Ok, that's all, the AL-Event-Handler will execute now your script as specified in the frequency. Best place to do step 2 and 3 is in the setup-script.
4. To show a fitting GNS-article, your script has to include an own text as article.
a) run plugin.news.getid to get an ID for your article
b) run plugin.news.add.news to add the article (for that you need several things aside from the id, as the sector or the race where the article has to be shown, the title of the article (string), the article itself (string), priority (unused atm), if the article shall vanish as soon the player has read it (show only one time/boolean), the maximum time to show the article (seconds/int) - the other options are optional (used for buttons inside the GNS - refer to the GNS-manual for that)).
The short information given here, doesn't reflect all possibilities, refer to the GNS-documentation in the download for that purpose.
5. [OPTIONAL] eventually your script will want to include bounties for killing one/some specified ship(s). For that purpose an own bounty-lib exists, usage similar easy to the above:
plugin.XTC.Lib.Bounty.GetID to get an specific ID
plugin.XTC.Lib.Bounty.Add to include the bounty, with informations like sector[-array], race, ships[-types/-classes], reward, time period of validity, author of the claiming message
Have a look into plugin.XTC.Event.Invasion to get an example.
Aside from this it should be mentioned, that all three scripts give the ability to remove the included thing by hand (not only automatic)... plugin.news.remove.news, plugin.XTC.Lib.Bounty.Remove and plugin.XTC.Lib.Events.Remove. Usage easy with just one argument: ID.
While it's not necessary to remove by hand, it can be useful for removing included things on specific timing
@moderators: I know, this isn't the right place for that - but I don't see a better fitting one, thus feel free to move or sticky it, if you wish
Last edited by Trickmov; 14-02-2011 at 07:51 AM. Reason: added note about bountysystem
Post Thanks / Like - 6 Thanks, 1 Likes, 0 DislikesSniper101 liked this post
Could you perhaps add a short example of what a typical news script would look like? I've been thinking of maybe writing some generic articles for the news.




Generic articles aren't events. The GNS release topic (findable on txu and ES) should have information on that

Yeah, as Eliah said, generic articles are different from dynamic "event"-ones. For generic ones, in principle all you need is a textfile (in the right format) and a short setup-script to include your textfile.
All described in the GNS-documentation, which I linked above.
Post Thanks / Like - 1 Thanks, 0 Likes, 0 DislikesObi1k thanked for this post
Bookmarks