SA-MP Forums Archive
command spaming - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: command spaming (/showthread.php?tid=129904)



command spaming - TouR - 24.02.2010

Код:
if( !strcmp(cmdtext, "/advertise", true, 10) )
{

	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if (advert[i] == 0)
	{
	advert[i] = 1;
	new str[256];
	new namez[MAX_PLAYER_NAME];
	GetPlayerName(playerid,namez,sizeof(namez));
	format(str, 256, "[ADVERTISMENT]: %s | Name: %s | ", cmdtext[10], namez);
	SendClientMessage(playerid, COLOR_YELLOW, "The cost of your advertisment is 150$");
	SendClientMessageToAll(COLOR_GREEN, str);
	GivePlayerMoney(playerid, -150);
	SetTimer("advoff", 60000, true);
	}
		else
	{
	SendClientMessage(playerid, COLOR_GREY, "You must wait 1 minute to post your advertise again");
 	}
	}

	return 1;
}

why this command spams the advertisment in main chat? I think something is going wrong with i [i] can someone tell me what could i do to stop it?


Re: command spaming - TouR - 24.02.2010

Quote:
Originally Posted by tour15
Код:
if( !strcmp(cmdtext, "/advertise", true, 10) )
{

	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if (advert[i] == 0)
	{
	advert[i] = 1;
	new str[256];
	new namez[MAX_PLAYER_NAME];
	GetPlayerName(playerid,namez,sizeof(namez));
	format(str, 256, "[ADVERTISMENT]: %s | Name: %s | ", cmdtext[10], namez);
	SendClientMessage(playerid, COLOR_YELLOW, "The cost of your advertisment is 150$");
	SendClientMessageToAll(COLOR_GREEN, str);
	GivePlayerMoney(playerid, -150);
	SetTimer("advoff", 60000, true);
	}
		else
	{
	SendClientMessage(playerid, COLOR_GREY, "You must wait 1 minute to post your advertise again");
 	}
	}

	return 1;
}

why this command spams the advertisment in main chat? I think something is going wrong with [i] [i] can someone tell me what could i do to stop it?



Re: command spaming - BlackFoX - 24.02.2010

You send it to all with a loop
Код:
SendClientMessageToAll(COLOR_GREEN, str);
Thats the Problem


Re: command spaming - TouR - 24.02.2010

can you further explain this to me pls?


Re: command spaming - VonLeeuwen - 24.02.2010

I think he means,
Change this:
Код:
SendClientMessageToAll(COLOR_GREEN, str);
into
Код:
SendClientMessage(i,COLOR_GREEN, str);
NOT SURE THO


Re: command spaming - TouR - 24.02.2010

thank you for helping but it didnt work:\


Re: command spaming - BlackFoX - 24.02.2010

Yes, but it is better you Send it without loop ToAll, so you need no unless Loops for it


Re: command spaming - VonLeeuwen - 24.02.2010

It spams the same message?

Like:
Код:
[ADVERTISEMENT]: Example | Name: VonLeeuwen |
[ADVERTISEMENT]: Example | Name: VonLeeuwen |
[ADVERTISEMENT]: Example | Name: VonLeeuwen |
[ADVERTISEMENT]: Example | Name: VonLeeuwen |
[ADVERTISEMENT]: Example | Name: VonLeeuwen |
Or does it spam different messages?


Re: command spaming - TouR - 24.02.2010

it spams the line you wrote also spams:The cost of your advertisment is 150$ and it decreases my money 150 the time my money turn into -50000


Re: command spaming - BlackFoX - 24.02.2010

Код:
if( !strcmp(cmdtext, "/advertise", true, 10) )
{
	if (!advert[playerid])return SendClientMessage(playerid, COLOR_GREY, "You must wait 1 minute to post your advertise again");
	advert[playerid] = 1;
	new str[128],namez[MAX_PLAYER_NAME];
	GetPlayerName(playerid,namez,sizeof(namez));
	format(str, sizeof str, "[ADVERTISMENT]: %s | Name: %s | ", cmdtext[12], namez);
	SendClientMessage(playerid, COLOR_YELLOW, "The cost of your advertisment is 150$");
	SendClientMessageToAll(COLOR_GREEN, str);
	GivePlayerMoney(playerid, -150);
	SetTimer("advoff", 60000, true);
	return 1;
}
edit : I forgot to say, that you can use GetTickCount() to get the MS Between last Ad