13.10.2014, 12:19
RandomMessages.inc
What is this?
I've seen some poorly optimized random message scripts and I decided to create an include that makes it easier!
Features
Replacements
You can even add your own text replacements!
Output:
Disable for players
You can also disable random messages from being sent to players:
If disabled, random messages will not be automatically sent to the player. This is useful for scripters that wish to show the random message somewhere else, like a textdraw! An example can be seen below.
Callback
This library includes one callback:
This callback is only called when "SetMessageInterval" is used. It will be called each time the time interval has passed.
This is useful for displaying random messages in textdraws, game text, etc.
If there are no random messages in the queue, this callback will not be called.
Functions
A list of functions for documentation purposes:
Download
http://pastebin.com/zZ16y5Ks
What is this?
I've seen some poorly optimized random message scripts and I decided to create an include that makes it easier!
Features
- You can add random messages with ease!
- Ability to add your own replacement functions.
- Toggle random messages for specific players.
pawn Код:
// Set the interval to 30 seconds (30000 ms).
SetMessageInterval(30000);
// Add a random message to the queue.
AddRandomMessage("Make sure you visit our forums for more information!", 0xFFFFFFFF);
You can even add your own text replacements!
pawn Код:
Replace->$name(playerid, string[], size) {
GetPlayerName(playerid, string, MAX_PLAYER_NAME);
}
Replace->$money(playerid, string[], size) {
format(string, size, "%d", GetPlayerMoney(playerid));
}
AddRandomMessage("Hey there [$name], you currently have [$money]!", 0xFFFFFFFF);
pawn Код:
Hey there Emmet_Jones, you currently have $50000!
You can also disable random messages from being sent to players:
pawn Код:
SetRandomMessagesForPlayer(playerid, false);
Callback
This library includes one callback:
pawn Код:
public OnRandomInterval()
{
return 1;
}
This is useful for displaying random messages in textdraws, game text, etc.
pawn Код:
public OnPlayerConnect(playerid)
{
// This will disable automatic messages from being sent automatically.
SetRandomMessagesForPlayer(playerid, false);
}
public OnRandomInterval()
{
// This allows the scripter to show random messages elsewhere.
// For example, showing the random message in a textdraw!
new
messageid = GetRandomMessageID(),
string[128];
for (new i = 0; i < MAX_PLAYERS; i ++)
{
if (IsPlayerConnected(i))
{
GetRandomMessageOutput(i, messageid, string, sizeof(string));
// Do something with "string"!
}
}
}
Functions
A list of functions for documentation purposes:
pawn Код:
// Add a random message to the queue.
native AddRandomMessage(const message[], color = -1);
// Sets the random message time interval (time = ms).
native SetMessageInterval(time);
// Conditional check to check for valid messages.
native IsValidRandomMessage(messageid);
// Enable or disable random messages for a player.
native SetRandomMessagesForPlayer(playerid, bool:status);
// Returns true if random messages are disabled for the player.
native bool:GetRandomMessagesForPlayer(playerid);
// Returns a random message in the queue (INVALID_MESSAGE_ID if none exist).
native GetRandomMessageID();
// Sends a random message to a player.
native SendRandomMessage(playerid, messageid);
// Generates the output for a random message (useful for textdraw displays, etc).
native GetRandomMessageOutput(playerid, messageid, dest[], size = sizeof(dest));
// Returns the total amount of random messages.
native GetTotalRandomMessages();
http://pastebin.com/zZ16y5Ks