aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-04 14:26:57 +0200
committerpiernov <piernov@piernov.org>2016-05-04 14:26:57 +0200
commit40b0d42dee76bc62517801aa746371a9ce2895a1 (patch)
treebff87016f7dd875b1c7d793cfa5835c5fb233733 /inc
parent036d5a2e88232e966cfd0cc82277d5fba13e71ff (diff)
downloadcandybox-40b0d42dee76bc62517801aa746371a9ce2895a1.tar.gz
candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.tar.bz2
candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.tar.xz
candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.zip
Now possible to add format to sendMessage() strings
Diffstat (limited to 'inc')
-rw-r--r--inc/messages.inc11
1 files changed, 6 insertions, 5 deletions
diff --git a/inc/messages.inc b/inc/messages.inc
index 4938fa1..7b952b8 100644
--- a/inc/messages.inc
+++ b/inc/messages.inc
@@ -14,18 +14,19 @@ $messages = array(
"gamesave_delete_success" => "Game save successfully removed from server",
);
-function sendMessage($type, $msg) {
+function sendMessage($type, $msg, $fmt = null) {
global $messages;
$text = $messages[$msg];
+ if($fmt) $text = vsprintf($text, $fmt);
echo json_encode(array($type => $text));
}
-function sendError($msg) {
- sendMessage("error", $msg);
+function sendError($msg, $fmt = null) {
+ sendMessage("error", $msg, $fmt);
}
-function sendInfo($msg) {
- sendMessage("info", $msg);
+function sendInfo($msg, $fmt = null) {
+ sendMessage("info", $msg, $fmt);
}
?>