mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-26 10:03:45 +00:00
Adds ability for admins with R_SERVER perms to be able to set a persistant 'news' announcement that works similarly to admin memos, but for the public. This is ideal for telling the public things such as when an event is scheduled, directing people to a forum thread, new lore changes, new policies, etc. The news window allows to define a title, and the body of the text, using an admin verb. The author and date are added automatically. Any players can read the news window in the lobby. The button will bold itself, and display (NEW!), if the player has not seen the news before. This is done by comparing a hash of the body that the client remembers verses a hash the current news body.
42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
#define NEWSFILE "data/news.sav" //where the memos are saved
|
|
|
|
/client/
|
|
var/last_news_hash = null // Stores a hash of the last news window it saw, which gets compared to the current one to see if it is different.
|
|
|
|
// Returns true if news was updated since last seen.
|
|
/client/proc/check_for_new_server_news()
|
|
var/savefile/F = get_server_news()
|
|
if(F)
|
|
if(md5(F["body"]) != last_news_hash)
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/client/proc/modify_server_news()
|
|
set name = "Modify Public News"
|
|
set category = "Server"
|
|
|
|
if(!check_rights(0))
|
|
return
|
|
|
|
var/savefile/F = new(NEWSFILE)
|
|
if(F)
|
|
var/title = F["title"]
|
|
var/body = F["body"]
|
|
var/new_title = sanitize(input(src,"Write a good title for the news update. Note: HTML is NOT supported.","Write News", title) as null|text, extra = 0)
|
|
if(!new_title)
|
|
return
|
|
var/new_body = sanitize(input(src,"Write the body of the news update here. Note: HTML is NOT supported.","Write News", body) as null|message, extra = 0)
|
|
if(findtext(new_body,"<script",1,0) ) // Is this needed with santize()?
|
|
return
|
|
F["title"] << new_title
|
|
F["body"] << new_body
|
|
F["author"] << key
|
|
F["timestamp"] << time2text(world.realtime, "DDD, MMM DD YYYY")
|
|
message_admins("[key] modified the news to read:<br>[new_title]<br>[new_body]")
|
|
|
|
/proc/get_server_news()
|
|
var/savefile/F = new(NEWSFILE)
|
|
if(F)
|
|
return F
|
|
|
|
#undef NEWSFILE |