SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/02/2010, 01:33 PM   #1
TouR
Gangsta
 
TouR's Avatar
 
Join Date: Oct 2009
Location: Greece
Posts: 739
Reputation: 33
Default command spaming

Code:
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?
TouR is offline  
Old 24/02/2010, 01:33 PM   #2
TouR
Gangsta
 
TouR's Avatar
 
Join Date: Oct 2009
Location: Greece
Posts: 739
Reputation: 33
Default Re: command spaming

Quote:
Originally Posted by tour15
Code:
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?
TouR is offline  
Old 24/02/2010, 01:34 PM   #3
BlackFoX
Huge Clucker
 
Join Date: Dec 2007
Posts: 227
Reputation: 10
Default Re: command spaming

You send it to all with a loop
Code:
SendClientMessageToAll(COLOR_GREEN, str);
Thats the Problem
BlackFoX is offline  
Old 24/02/2010, 01:35 PM   #4
TouR
Gangsta
 
TouR's Avatar
 
Join Date: Oct 2009
Location: Greece
Posts: 739
Reputation: 33
Default Re: command spaming

can you further explain this to me pls?
TouR is offline  
Old 24/02/2010, 01:37 PM   #5
VonLeeuwen
Big Clucker
 
Join Date: Oct 2007
Posts: 196
Reputation: 0
Default Re: command spaming

I think he means,
Change this:
Code:
SendClientMessageToAll(COLOR_GREEN, str);
into
Code:
SendClientMessage(i,COLOR_GREEN, str);
NOT SURE THO
VonLeeuwen is offline  
Old 24/02/2010, 01:40 PM   #6
TouR
Gangsta
 
TouR's Avatar
 
Join Date: Oct 2009
Location: Greece
Posts: 739
Reputation: 33
Default Re: command spaming

thank you for helping but it didnt work:\
TouR is offline  
Old 24/02/2010, 01:41 PM   #7
BlackFoX
Huge Clucker
 
Join Date: Dec 2007
Posts: 227
Reputation: 10
Default Re: command spaming

Yes, but it is better you Send it without loop ToAll, so you need no unless Loops for it
BlackFoX is offline  
Old 24/02/2010, 01:42 PM   #8
VonLeeuwen
Big Clucker
 
Join Date: Oct 2007
Posts: 196
Reputation: 0
Default Re: command spaming

It spams the same message?

Like:
Code:
[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?
VonLeeuwen is offline  
Old 24/02/2010, 01:44 PM   #9
TouR
Gangsta
 
TouR's Avatar
 
Join Date: Oct 2009
Location: Greece
Posts: 739
Reputation: 33
Default Re: command spaming

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
TouR is offline  
Old 24/02/2010, 01:46 PM   #10
BlackFoX
Huge Clucker
 
Join Date: Dec 2007
Posts: 227
Reputation: 10
Default Re: command spaming

Code:
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
BlackFoX is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Command Bugged] Each time i use /respawnallcars it says Unknown Command Rand_Omar Scripting Help 11 30/09/2012 01:35 AM
how i change wrong command (unknow command) OmarEco Help Archive 10 22/06/2010 05:09 PM
SERVER: Unknown Command when using a scripted command and it does execute! Moustafa Help Archive 6 11/06/2010 02:34 PM
SERVER: Unknown Command - after login on every command virtualmarc Help Archive 0 20/09/2009 07:27 PM
Massive flood, hack tentative, spaming... billkaulitz Help Archive 5 02/04/2009 02:00 PM


All times are GMT. The time now is 07:06 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.