Quick Help
#1

I need a little help.. This command spams the user with "[ERROR:] You are not at/in a business."
Like it sends at least 5+ times.. I don't understand what's wrong with it...
Код:
 	if(strcmp(cmd, "/advertise", true) == 0 || strcmp(cmd, "/ad", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(gPlayerLogged[playerid] == 0)
	    {
	      SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] Your not logged in!");
	      return 1;
	    }
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
  			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] (/ad)vertise [advert text]");
				return 1;
			}
  	  	for(new i = 0; i < sizeof(Businesses); i++)
			{
				if (PlayerToPoint(1.0, playerid,Businesses[i][EnterX], Businesses[i][EnterY], Businesses[i][EnterZ]) || PlayerToPoint(25.0, playerid,Businesses[i][ExitX], Businesses[i][ExitY], Businesses[i][ExitZ]))
				{
					if(GetPlayerVirtualWorld(playerid) == i)
					{
			  		if(Businesses[i][BizType] == 5)
			  		{
				    	if(Businesses[i][Products] != 0)
				    	{
								if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1))
								{
									format(string, sizeof(string), "[ERROR:] You must wait %d seconds before making another advertisement.", (addtimer/1000));
									SendClientMessage(playerid, COLOR_LIGHTYELLOW2, string);
									return 1;

								}
								new payout = idx * 25;
								if(GetPlayerCash(playerid) < payout)
						    {
						      SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You don't have enough money.");
						      return 1;
						    }
						    GivePlayerCash(playerid, - payout);
								Businesses[i][Till] += payout;
								Businesses[i][Products] --;
								format(string, sizeof(string), "---------------------------------[Advertisement (%s)]---------------------------------", Businesses[i][BusinessName]);
								SendClientMessageToAll(COLOR_LIGHTGREEN,string);
								format(string, sizeof(string), "[AD:] %s", result);
								SendClientMessageToAll(COLOR_WHITE,string);
								format(string, sizeof(string), "[AD:] Advertisement By: %s - Phone Number: %d.", GetPlayerNameEx(playerid),PlayerInfo[playerid][pPhoneNumber],Businesses[i][BusinessName]);
								SendClientMessageToAll(COLOR_WHITE,string);
								SendClientMessageToAll(COLOR_LIGHTGREEN,"-----------------------------------------------------------------------------------------------------------------------");
						    if (PlayerInfo[playerid][pAdmin] < 1){SetTimer("AddsOn", addtimer, 0);adds = 0;}
						    format(string, sizeof(string), "[INFO:] Characters Contained: %d - Cost: $%d - Thanks from %s", idx,payout,Businesses[i][BusinessName]);
								SendClientMessage(playerid,COLOR_WHITE,string);
								PlayerActionMessage(playerid,15.0,"gives the company worker some money and gets his advertisement posted in return.");
								SaveBusinesses();
								return 1;
							}
							else
							{
								SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] The business is out of products.");
							}
						}
						else
						{
							SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] This business is not an advertising company.");
						}
					}
	  			}
	  			else
				{
					SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You are not at/in a business.");
				}
			}
		}
		return 1;
	}
And if it matters at all here's the top of my OnPlayerCommandText. After this the commands begin.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[256];
	new cmd[256];
	new idx;
	cmd = strtok(cmdtext, idx);
	new tmp[256];
	new giveplayerid;
	new sendername[MAX_PLAYER_NAME];
Reply
#2

Do you get in PAWNO error, or that code dont work in-game?
Reply
#3

It works, just in game when I'm standing in public (Lets say a road?..) it will Spam me with the last "else" statement. I just want to know why it Spams me.
Reply
#4

Quote:
Originally Posted by Mini`
It works, just in game when I'm standing in public (Lets say a road?..) it will Spam me with the last "else" statement. I just want to know why it Spams me.
Putting messages in for() loop ain't a good idea.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)