Add server announcements/global broadcasts
Chat messages with NULL uuid are now server announcements, and null lat/long messages are broadcast globally.
This commit is contained in:
parent
cc59866fcc
commit
66f598d5d2
30
chat.php
30
chat.php
@ -47,15 +47,35 @@ if (is_empty($VARS['msg'])) {
|
||||
//echo $searchbounds[1]->getLatitudeInDegrees();
|
||||
//echo $searchbounds[1]->getLongitudeInDegrees();
|
||||
|
||||
$msgs = $database->select('messages', ["[>]players" => ["uuid" => "uuid"]], ['messages.uuid', 'messages.message', 'messages.time', 'players.nickname'], ['AND' => [
|
||||
'lat[>]' => $searchbounds[0]->getLatitudeInDegrees(),
|
||||
'lat[<]' => $searchbounds[1]->getLatitudeInDegrees(),
|
||||
'long[>]' => $searchbounds[0]->getLongitudeInDegrees(),
|
||||
'long[<]' => $searchbounds[1]->getLongitudeInDegrees()],
|
||||
$msgs = $database->select('messages', ["[>]players" => ["uuid" => "uuid"]], ['messages.uuid', 'messages.message', 'messages.time', 'players.nickname'], ['AND' =>
|
||||
["OR" =>
|
||||
[
|
||||
"AND #regular messages" =>
|
||||
[
|
||||
'lat[>]' => $searchbounds[0]->getLatitudeInDegrees(), 'lat[<]' => $searchbounds[1]->getLatitudeInDegrees(), 'long[>]' => $searchbounds[0]->getLongitudeInDegrees(), 'long[<]' => $searchbounds[1]->getLongitudeInDegrees()
|
||||
],
|
||||
"AND #global announcement messages" =>
|
||||
[
|
||||
'lat' => null, 'long' => null
|
||||
]
|
||||
]
|
||||
],
|
||||
"ORDER" => "messages.time DESC",
|
||||
"LIMIT" => 30
|
||||
]);
|
||||
|
||||
foreach ($msgs as $key => $msg) {
|
||||
if (is_null($msg['uuid'])) {
|
||||
$msgs[$key]['uuid'] = "0";
|
||||
$msgs[$key]['nickname'] = "SERVER MESSAGE";
|
||||
$msgs[$key]['color'] = CHAT_ADMIN_COLOR;
|
||||
} else if (in_array($msg['nickname'], CHAT_ADMINS)) {
|
||||
$msgs[$key]['color'] = CHAT_ADMIN_COLOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo json_encode($msgs);
|
||||
} else {
|
||||
// Post message
|
||||
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -26,6 +26,12 @@ define("APP_STORE_SANDBOX", true);
|
||||
|
||||
define("DARKSKY_APIKEY", "");
|
||||
|
||||
// List of players with special chat colors.
|
||||
// Server messages (from the admin panel) are always special.
|
||||
define("CHAT_ADMINS", ["admin"]);
|
||||
// Color for chat admin names. Accepts any HTML named color or hexcode (#ff0000)
|
||||
define("CHAT_ADMIN_COLOR", "red");
|
||||
|
||||
// Admin control panel login
|
||||
define("ADMIN_USER", "");
|
||||
define("ADMIN_PASS", "");
|
||||
|
Reference in New Issue
Block a user