Код:
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;
}
. Maybe the business your in IS bugged and not the code.
Because he checks all the businesses, but I think, now he's only checking one, so test this and if this is wrong I'm going to think of another thing