Ui::setNotificationMessage: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
(New examples, icons info, and tutorial how to use own textures and in-game sprites)
Line 1: Line 1:
See [[Notification Pictures]] for a list of notification pictures.
See [[Notification Pictures]] for a list of notification pictures. Pictures from this link have the same '''textureDict''' and '''textureName'''.
 
Also some of them needs to be requested with [[Graphics::requestStreamedTextureDict]].
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">mp.game.ui.setNotificationMessage(picName1, picName2, flash, iconType, sender, subject);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.ui.setNotificationMessage(textureDict, textureName, flash, iconType, sender, subject);</syntaxhighlight>
 
===Icon types===
* '''No Icon''': 0, 4, 5, 6
* '''Speech Bubble''': 1
* '''Message''': 2
* '''Friend Request''': 3
* '''Arrow''': 7
* '''RP''': 8
* '''Money''': 9


=== Required Arguments ===
=== Required Arguments ===
*'''picName1:''' String
*'''textureDict:''' {{RageType|String}}
*'''picName2:''' String
*'''textureName:''' {{RageType|String}}
*'''flash:''' Boolean
*'''flash:''' {{RageType|Boolean}}
*'''iconType:''' int
*'''iconType:''' {{RageType|Int}}
*'''sender:''' String
*'''sender:''' {{RageType|String}}
*'''subject:''' String
*'''subject:''' {{RageType|String}}


===Return value===
===Return value===
*'''int'''
*{{RageType|Int}}


==Example==
==Example==
<syntaxhighlight lang="javascript">
{{ClientsideCode|
    mp.game.ui.setNotificationTextEntry("STRING");
<pre>
    mp.game.ui.setNotificationMessage("CHAR_BLOCKED", "CHAR_BLOCKED", false, 4, 'sender or title', 'subject');
const notifyWithPicture = () => {
    mp.game.ui.drawNotification(true, false);
mp.game.ui.setNotificationTextEntry('STRING');
</syntaxhighlight>
mp.game.ui.setNotificationMessage('CHAR_RON', 'CHAR_RON', false, 2, 'New Message', 'Hello World!');
};
 
notifyWithPicture();
</pre>
}}
Output:
[[File:outputnative.png|200px]]
 
Values '''textureDict''' and '''textureName''' gives you ability to make custom notifcation pictures using: [[Using_DLC_Packs_with_Custom_Textures]]
{{ClientsideCode|
<pre>
// Before using your custom textures you must request them by this function
mp.game.graphics.requestStreamedTextureDict('notifications', true);
 
const notifyWithPicture = () => {
mp.game.ui.setNotificationTextEntry('STRING');
mp.game.ui.setNotificationMessage('notifications', 'ragelogo', false, 2, 'New Message', 'Hi, now your notifications look ~y~beast');
};
 
notifyWithPicture();
</pre>
}}
Output:
[[File:outputcustom.png|200px]]
 
or using in-game sprites:
{{ClientsideCode|
<pre>
// Just in case you should request textureDict
mp.game.graphics.requestStreamedTextureDict('commonmenu', true);
 
const notifyWithPicture = () => {
mp.game.ui.setNotificationTextEntry('STRING');
return mp.game.ui.setNotificationMessage('commonmenu', 'mp_specitem_cash', false, 9, 'New notification!', 'Your account has been charged');
};


[[File:notification.png|200px]]
notifyWithPicture();
</pre>
}}
Output:
[[File:outputcustom2.png|200px]]


==See also==
==See also==

Revision as of 10:07, 5 December 2020

See Notification Pictures for a list of notification pictures. Pictures from this link have the same textureDict and textureName.

Also some of them needs to be requested with Graphics::requestStreamedTextureDict.

Syntax

mp.game.ui.setNotificationMessage(textureDict, textureName, flash, iconType, sender, subject);

Icon types

  • No Icon: 0, 4, 5, 6
  • Speech Bubble: 1
  • Message: 2
  • Friend Request: 3
  • Arrow: 7
  • RP: 8
  • Money: 9

Required Arguments

  • textureDict: String
  • textureName: String
  • flash: Boolean
  • iconType: Int
  • sender: String
  • subject: String

Return value

  • Int

Example

Client-Side
const notifyWithPicture = () => {
	mp.game.ui.setNotificationTextEntry('STRING');
	mp.game.ui.setNotificationMessage('CHAR_RON', 'CHAR_RON', false, 2, 'New Message', 'Hello World!');
};

notifyWithPicture();

Output:

Values textureDict and textureName gives you ability to make custom notifcation pictures using: Using_DLC_Packs_with_Custom_Textures

Client-Side
// Before using your custom textures you must request them by this function
mp.game.graphics.requestStreamedTextureDict('notifications', true);

const notifyWithPicture = () => {
	mp.game.ui.setNotificationTextEntry('STRING');
	mp.game.ui.setNotificationMessage('notifications', 'ragelogo', false, 2, 'New Message', 'Hi, now your notifications look ~y~beast');
};

notifyWithPicture();

Output:

or using in-game sprites:

Client-Side
// Just in case you should request textureDict
mp.game.graphics.requestStreamedTextureDict('commonmenu', true);

const notifyWithPicture = () => {
	mp.game.ui.setNotificationTextEntry('STRING');
	return mp.game.ui.setNotificationMessage('commonmenu', 'mp_specitem_cash', false, 9, 'New notification!', 'Your account has been charged');
};

notifyWithPicture();

Output:

See also