Jump to content

Notification Manager


Rick

Recommended Posts

So, i just convert rootcause script from GT-MP to RAGE 

https://imgur.com/a/kidcW

Methods

 

There are 10 exported methods you can use to display notifications to a certain player/all players. Don't forget to check examples!

Spoiler

 

module.exports.SendMessage = function(player, message, type, time = 1000, place = "bottomRight") {
    player.call('ReceiveNotification', message, type, time, place);
}

module.exports.SendMessageToAll = function(message, type, time = 1000, place = "bottomRight") {
    mp.players.forEach( (player, id) => { player.call('ReceiveNotification', message, type, time, place);  } );
}

module.exports.SendInfoMessage = function(player, message, time = 1000, place = "bottomRight") {
    player.call('ReceiveNotification', message, "info", time, place);
}

module.exports.SendErrorMessage = function(player, message, time = 1000, place = "bottomRight") {
    player.call('ReceiveNotification', message, "error", time, place);
}

module.exports.SendSuccessMessage = function(player, message, time = 1000, place = "bottomRight") {
    player.call('ReceiveNotification', message, "success", time, place);
}
module.exports.SendWarningMessage = function(player, message, time = 1000, place = "bottomRight") {
    player.call('ReceiveNotification', message, "warning", time, place);
}


module.exports.SendInfoMessageToAll = function(message, time = 1000, place = "bottomRight") {
    mp.players.forEach( (player, id) => { player.call('ReceiveNotification', message, "info", time, place);  } );
}

module.exports.SendErrorMessageToAll = function(message, time = 1000, place = "bottomRight") {
    mp.players.forEach( (player, id) => { player.call('ReceiveNotification', message, "error", time, place);  } );
}

module.exports.SendSuccessMessageToAll = function(message, time = 1000, place = "bottomRight") {
    mp.players.forEach( (player, id) => { player.call('ReceiveNotification', message, "success", time, place);  } );
}
module.exports.SendWarningMessageToAll = function(message, time = 1000, place = "bottomRight") {
    mp.players.forEach( (player, id) => { player.call('ReceiveNotification', message, "warning", time, place);  } );
}

 

 

 

Parameters

 

These are the valid options for "type":

  • alert
  • info
  • success
  • warning
  • error

These are the valid options for "place":

  • top
  • topLeft
  • topCenter
  • topRight
  • center
  • centerLeft
  • centerRight
  • bottom
  • bottomLeft
  • bottomCenter
  • bottomRight

Time parameter uses milliseconds so if you want to display a notification for 6 seconds you must write 6000 - aka multiply seconds by 1000

Example

Spoiler

 

var DB = require('../modules/db');
var notice = require('../modules/notice');
var md5 = require('md5');
module.exports.playerAuth = function(player, username, password) {
	DB.Handle.query("SELECT * FROM server_players WHERE Name = ? AND Password = ? LIMIT 1", [username, md5(password)], function(e, result) {
		if (e) throw e;
	    if ( result.length ) {
	    	player.name = result[0]["Name"];
	    	player.sqlID = result[0]["ID"];
	        notice.SendSuccessMessage(player, "Welcome back, " + player.name, 1000, "bottomRight");
	        player.call('authResponse', true);

	    } else {
	    	notice.SendErrorMessage(player, "Wrong username or password !", 1000, "bottomRight");
	    }
	});

};

 

 

 

 

Download : https://drive.google.com/file/d/0B4IUeQBGaaEeRlpDaUVwTW04Skk/view?usp=sharing

Edited by Rick
  • Like 3
  • Take2 1
Link to comment
Share on other sites

  • 2 years later...
  • 10 months later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...