Hello guys.

I saw that some of you where looking for Random Server Messages, which where easy to use and easy to append to your gamemode, This is why i'm writing a tutorial for the people who are seeking to get this done.

Underneath
Code:
#include <a_samp>
place the following line
Code:
forward RandomMessages()
This creates a function, which we shall use to send the messages to the players/server.

Now underneath the forward we shall make a variable, holding all the messages, we shall place some basic ones.
Code:
#include <a_samp>

forward RandomMessages();

new randomMessages[][] =
{
"{e868d3}Server: {FFFFFF}We are always working on improvements feel free to suggest anything!",
"{e868d3}Server: {FFFFFF}Need help? Use /help , use /ask for assistance.",
"{e868d3}Server: {FFFFFF}Donate today for epic features, items and more! Contact us on our Forum",
"{e868d3}Server: {FFFFFF}Please read /rules, and /help regularly, as they may change randomly.",
"{e868d3}Server: {FFFFFF}Spotted a player hacking/cheating/breaking rules? Use /report [name/id] [reason]",
"{e868d3}Server: {FFFFFF}Welcome to our Server, we hope you enjoy playing with us!",
"{e868d3}Server: {FFFFFF}Please /savestats regularly as this stores all your current data in the database."
};
We just made a variable holding data, the data is ofcourse, the random messages!
Ofcourse, it will not work like this, if you where to compile right now it would come up with a warning saying
warning symbol is never used: "RandomMessages" or something simulair to that.

Lets proceed by creating a timer, this is needed because we would want to dispatch a message each 2 minutes.

Place the following line at OnGameModeInit,
Code:
SetTimer("RandomMessages", 120000, true);
120000 = Milisecconds = 120 secconds = 60*2 = 2 minutes.
This is the timer, it shall countdown, 120 secconds and start over, because we set it to true,
If you change this to false, it shall count down to 0 and stop the count which will stop random messages from being sent.

Lets get to the function!
Underneath OngameModeInit place the following lines.
Code:
public RandomMessages()
{
new randomMsg = random(sizeof(randomMessages));
SendClientMessageToAll(-1, randomMessages[randomMsg]);
}
This makes a variable that picks a random RandomMessage which we defined at the top of the script, Gets the size of the variable, and sends it to all the clients that are connected to the server, You now have an automatic predefined Random Messages system, If you have any questions, feel free to ask them, i shall try to answer them all.

Full code on a blank gamemode :
Code:
#include <a_samp>

forward RandomMessages();

new randomMessages[][] =
{
"{e868d3}Server: {FFFFFF}We are always working on improvements feel free to suggest anything!",
"{e868d3}Server: {FFFFFF}Need help? Use /help , use /ask for assistance.",
"{e868d3}Server: {FFFFFF}Donate today for epic features, items and more! Contact us on our Forum",
"{e868d3}Server: {FFFFFF}Please read /rules, and /help regularly, as they may change randomly.",
"{e868d3}Server: {FFFFFF}Spotted a player hacking/cheating/breaking rules? Use /report [name/id] [reason]",
"{e868d3}Server: {FFFFFF}Welcome to our Server, we hope you enjoy playing with us!",
"{e868d3}Server: {FFFFFF}Please /savestats regularly as this stores all your current data in the database."
};

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
SetTimer("RandomMessages", 120000, true);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public RandomMessages()
{
new randomMsg = random(sizeof(randomMessages));
SendClientMessageToAll(-1, randomMessages[randomMsg]);
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
If i have helped you out hit that +rep button!