CreateTrayNotification: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added note)
(Fix spacing.)
 
(12 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
{{Needs Checking|Check function arguments and make example}}
This function creates a notification balloon on the desktop.
{{Needs_Example}}
 
This functions creates a notification ballon on the desktop.
{{Note|MTA won't show any tray notifications if the MTA window is focused, because there is no reason to show tray notifications if you are in-game. If you want to test this function you should use a Timer and switch to your desktop.}}
{{Note|MTA won't show any tray notifications if the MTA window is focused, because there is no reason to show tray notifications if you are ingame.
{{Note|You can only show a tray notification every 30 seconds.}}
If you want to test this function you should use a Timer and switch to your desktop.}}
 
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool createTrayNotification ( string notificationText, [ string eType, bool useSound ] )</syntaxhighlight>
<syntaxhighlight lang="lua">bool createTrayNotification ( string notificationText [, string iconType = "default", bool useSound = true ] )</syntaxhighlight>
 
[[File:TrayNotification.gif|301px|thumb|right|alt=GIF preview of a tray notification|Tray Notification GIF]]
 
===Required Arguments===
===Required Arguments===
*'''notificationText:''' The text to send in the notification.
*'''notificationText:''' The text to send in the notification.
===Optional Arguments===
===Optional Arguments===
*'''eType:''' The notification icon. Possible values are: '''"default", "info", "warning", "error"'''
*'''iconType:''' The notification icon type. Possible values are: '''"default" (the MTA icon), "info", "warning", "error"'''
*'''useSound:''' A boolean value indicating whether or not to play a sound when receiving the notification.
*'''useSound:''' A boolean value indicating whether or not to play a sound when receiving the notification.
==Returns==
 
===Returns===
Returns ''true'' if the notification is correctly created, ''false'' otherwise.
Returns ''true'' if the notification is correctly created, ''false'' otherwise.
==Example==
<syntaxhighlight lang="lua">
-- Note: You have to wait 30 seconds before showing another tray notification, there is no queuing
createTrayNotification("Hello World") -- Show a 'Hello World' notification
createTrayNotification("Hello World", "warning") -- Show a notification with a warning symbol
createTrayNotification("Hello World", "default", false) -- Show a default notification without sound
</syntaxhighlight>
==Example of notification on minimize MTA application==
<syntaxhighlight lang="lua">
function setTrayOnMinimize()
    createTrayNotification("We are waiting for you again...", "warning")
end
addEventHandler("onClientMinimize", root, setTrayOnMinimize)
</syntaxhighlight>
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.5.6-9.16925|Added support for Windows 10}}
==See Also==
==See Also==
{{Client_utility_functions}}
{{Client_utility_functions}}

Latest revision as of 12:12, 30 December 2022

This function creates a notification balloon on the desktop.


[[{{{image}}}|link=|]] Note: MTA won't show any tray notifications if the MTA window is focused, because there is no reason to show tray notifications if you are in-game. If you want to test this function you should use a Timer and switch to your desktop.
[[{{{image}}}|link=|]] Note: You can only show a tray notification every 30 seconds.

Syntax

bool createTrayNotification ( string notificationText [, string iconType = "default", bool useSound = true ] )
GIF preview of a tray notification
Tray Notification GIF

Required Arguments

  • notificationText: The text to send in the notification.

Optional Arguments

  • iconType: The notification icon type. Possible values are: "default" (the MTA icon), "info", "warning", "error"
  • useSound: A boolean value indicating whether or not to play a sound when receiving the notification.

Returns

Returns true if the notification is correctly created, false otherwise.

Example

-- Note: You have to wait 30 seconds before showing another tray notification, there is no queuing

createTrayNotification("Hello World") -- Show a 'Hello World' notification

createTrayNotification("Hello World", "warning") -- Show a notification with a warning symbol

createTrayNotification("Hello World", "default", false) -- Show a default notification without sound

Example of notification on minimize MTA application

function setTrayOnMinimize()
     createTrayNotification("We are waiting for you again...", "warning")
end
addEventHandler("onClientMinimize", root, setTrayOnMinimize)

Changelog

Version Description
1.5.6-9.16925 Added support for Windows 10

See Also