08.06.2013, 20:38
I were to share a simple way to create an advertisement system which allows you to post an advertisement only every 60 seconds.
Place this on top of the script
Now for the actual Command.
Now for the timer to limit the amount of advertisements placed.
You can use your own function to get the Underscore from the name.
Place this on top of the script
pawn Code:
new ServerAdvert;
// COLOR
#define COLOR_LIME 0x10F441AA
pawn Code:
CMD:advertisement(playerid, params[])
{
new string[128], name[64] ;
GetPlayerName(playerid, name, sizeof(name));
if(PlayerInfo[playerid][Level] < 1) return SendClientMessage(playerid, COLOR_GRAY, "You need to be level 2 to advertise!");
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_GRAY, "USAGE: /ad(vertisement) [Text]");
if(ServerAdvert == 1)
{
SendClientMessage(playerid, COLOR_RED, "Only one advertisement every 60 seconds!");
}
else
{
ServerAdvert = 1;
format(string, sizeof(string), "[Advertisement] %s Contact: %s Ph: %d", params, name(playerid), PlayerInfo[playerid][Phone]);
SendClientMessageToAll(COLOR_LIME, string);
SetTimer("AdTimer", 60000, false);
GivePlayerMoney(playerid, -1000);
}
return 1;
}
Now for the timer to limit the amount of advertisements placed.
pawn Code:
public AdTimer()
{
ServerAdvert = 0;
return 1;
}