command spaming
#1

Код:
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?
Reply
#2

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?
Reply
#3

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

can you further explain this to me pls?
Reply
#5

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

thank you for helping but it didnt work:\
Reply
#7

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

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?
Reply
#9

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
Reply
#10

Код:
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)