I am trying to modify an Ad System by Textdraw, (made by Felipe Blanco, credits to him).
What I want to do practically, is that when sending an ad, it appears, and after "X" number of seconds, it disappears, and if at the same time, another person sends an ad, it appears at the bottom, but .. Since there are only 5 TextDraw in total, if the last TextDraw is already being used, and a player sends another announcement, it appears at the top, again, that is to say in the first TextDraw, and so on and off, go down until get to number 5, and from there again appear above.
PD: If an anti bug is also possible, so that if 5 people send an ad, and at the same time, a 6 player wants to make use of the ad, it does not collapse with one another, if not, for example: If the TextDraw 1,2,3,4 and 5 are being used, and there is no space for another ad, a message is sent to the player that the ads are full, and when one of them disappears (this with the variable of the time that goes to disappear) the first TextDraw you find free, show it there, in that TextDraw space that is no longer being used.
pawn Code:
/*
SISTEMA DE ANUNCIOS v0.1
Comandos:
/anuncio [texto] - Para publicar un anuncio en la pantalla
/resetearanuncios - Borra los anuncios de la pantalla, por si hacen spam
*/
/* INCLUDES */
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define NA 5 /* Cantidad de anuncios (Recuerden agregar textdraw) */
new TiempoAnuncio[MAX_PLAYERS],Text:TextDraw[5];
enum anuncios
{
Texto[75]
};
new Anuncio[NA][anuncios];
public OnFilterScriptInit()
{
print("Sistema de anuncios, por Felipe Blanco");
SetTimer("Timer",1000,1);
TextDraw[0] = TextDrawCreate(360.625000, 363.833374, "~g~Anuncio:~w~ Se vende un pito de goma a gran precio ~g~(Movil: 3250)");
TextDrawLetterSize(TextDraw[0], 0.152500, 1.232499);
TextDrawAlignment(TextDraw[0], 1);
TextDrawColor(TextDraw[0], -1);
TextDrawSetShadow(TextDraw[0], 0);
TextDrawSetOutline(TextDraw[0], 1);
TextDrawBackgroundColor(TextDraw[0], 255);
TextDrawFont(TextDraw[0], 1);
TextDrawSetProportional(TextDraw[0], 1);
TextDrawSetShadow(TextDraw[0], 0);
TextDraw[1] = TextDrawCreate(360.625000, 376.083007, "~g~Anuncio:~w~ Se vende un pito de goma a gran precio ~g~(Movil: 3250)");
TextDrawLetterSize(TextDraw[1], 0.152500, 1.232499);
TextDrawAlignment(TextDraw[1], 1);
TextDrawColor(TextDraw[1], -1);
TextDrawSetShadow(TextDraw[1], 0);
TextDrawSetOutline(TextDraw[1], 1);
TextDrawBackgroundColor(TextDraw[1], 255);
TextDrawFont(TextDraw[1], 1);
TextDrawSetProportional(TextDraw[1], 1);
TextDrawSetShadow(TextDraw[1], 0);
TextDraw[2] = TextDrawCreate(360.625000, 390.666503, "~g~Anuncio:~w~ Se vende un pito de goma a gran precio ~g~(Movil: 3250)");
TextDrawLetterSize(TextDraw[2], 0.152500, 1.232499);
TextDrawAlignment(TextDraw[2], 1);
TextDrawColor(TextDraw[2], -1);
TextDrawSetShadow(TextDraw[2], 0);
TextDrawSetOutline(TextDraw[2], 1);
TextDrawBackgroundColor(TextDraw[2], 255);
TextDrawFont(TextDraw[2], 1);
TextDrawSetProportional(TextDraw[2], 1);
TextDrawSetShadow(TextDraw[2], 0);
TextDraw[3] = TextDrawCreate(360.000000, 405.249847, "~g~Anuncio:~w~ Se vende un pito de goma a gran precio ~g~(Movil: 3250)");
TextDrawLetterSize(TextDraw[3], 0.152500, 1.232499);
TextDrawAlignment(TextDraw[3], 1);
TextDrawColor(TextDraw[3], -1);
TextDrawSetShadow(TextDraw[3], 0);
TextDrawSetOutline(TextDraw[3], 1);
TextDrawBackgroundColor(TextDraw[3], 255);
TextDrawFont(TextDraw[3], 1);
TextDrawSetProportional(TextDraw[3], 1);
TextDrawSetShadow(TextDraw[3], 0);
TextDraw[4] = TextDrawCreate(360.625000, 419.250000, "~g~Anuncio:~w~ Se vende un pito de goma a gran precio ~g~(Movil: 3250)");
TextDrawLetterSize(TextDraw[4], 0.152500, 1.232499);
TextDrawAlignment(TextDraw[4], 1);
TextDrawColor(TextDraw[4], -1);
TextDrawSetShadow(TextDraw[4], 0);
TextDrawSetOutline(TextDraw[4], 1);
TextDrawBackgroundColor(TextDraw[4], 255);
TextDrawFont(TextDraw[4], 1);
TextDrawSetProportional(TextDraw[4], 1);
TextDrawSetShadow(TextDraw[4], 0);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
TiempoAnuncio[playerid] = 0;
return 1;
}
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 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 0;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
CMD:anuncio(playerid,params[])
{
new anuncio[75];
if(strlen(params) >= 74) return SendClientMessage(playerid,-1,"Ingresaste un anuncio muy largo.");
if(sscanf(params,"s[75]",anuncio)) return SendClientMessage(playerid,-1,"Usa /anuncio [anuncio]");
new string[200];
if(TiempoAnuncio[playerid] > 0)
{
format(string,100,"Espera %d segundos para poder hacer otro anuncio.",TiempoAnuncio[playerid]);
SendClientMessage(playerid,-1,string);
return true;
}
TiempoAnuncio[playerid] = 60;
for(new a; a < NA-1; a++)
{
if(strlen(Anuncio[a+1][Texto]) > 0)
{
format(Anuncio[a][Texto],75,"%s",Anuncio[a+1][Texto]);
format(string,sizeof(string),"~g~Anuncio:~w~ %s ~g~(Movil: 3250)",Anuncio[a][Texto]);
TextDrawSetString(TextDraw[a],string);
TextDrawShowForAll(TextDraw[a]);
}
}
Anuncio[NA-1][Texto] = anuncio;
format(string,sizeof(string),"~g~Anuncio:~w~ %s ~g~(Movil: 3250)",anuncio);
TextDrawSetString(TextDraw[NA-1],string);
TextDrawShowForAll(TextDraw[NA-1]);
return true;
}
CMD:resetanuncios(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return 1; // Por si hacen spam en los anuncios, pueden borrarlos
for(new a; a < NA; a++)
{
if(strlen(Anuncio[a][Texto]) > 0)
{
format(Anuncio[a][Texto],35,"");
TextDrawHideForAll(TextDraw[a]);
}
}
return true;
}
forward Timer();
public Timer()
{
for(new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerConnected(i) && TiempoAnuncio[i] > 0) TiempoAnuncio[i] --;
}
return true;
}
If someone can guide me on how to do it, or in itself, to create an example of the script to do it, I would greatly appreciate it, and if possible give it a reputation, I am grateful in advance for your help, have a good afternoon.