29.08.2015, 18:04
The command only prints (Done?) which is under
I'm making it on this way to prevent messages spamming in loops but it doesn't do anything :/
PHP код:
CMD:buycar(playerid, params[])
{
new bool:in_range = false;
new bool:notIn = false;
new bool:noMoney = false;
new bool:AlreadyHas = false;
new bool:NotForSale = false;
for(new a = 1; a <= MAX_VEHICLES; a++)
{
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(a, vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 3.0, vx, vy, vz))
{
if(CarInDb[a] == false) { notIn = true; }
}
}
if(notIn == true) return SendClientMessage(playerid, COLOR_RED, "This is a server-car!");
for(new i = 0; i != CarsLoad;i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, CarInfo[i][CarX], CarInfo[i][CarY], CarInfo[i][CarY]))
{
if(GetPlayerMoney(playerid) < CarInfo[i][CarPrice])
{
if(PlayerInfo[playerid][pHasCar] > 2)
{
if(CarInfo[i][cSale] == 0)
{
if(strcmp(CarInfo[i][owner], "None"))
{
new UMoney[128];
new Smoney[128];
new money = format(Smoney, sizeof(Smoney), "SELECT pMoney FROM users WHERE pName='%s'",CarInfo[i][owner]);
mysql_query(1, Smoney);
format(UMoney, sizeof(UMoney), "UPDATE users SET pMoney='%i' WHERE username='%s'",money+CarInfo[i][CarPrice], CarInfo[i][owner]);
mysql_query(1, UMoney);
}
new query[200];
format(query, sizeof(query), "UPDATE cars SET owner='%s', owned='1', cSale='0' WHERE id='%i'",PlayerName(playerid), CarInfo[i][CarID]);
mysql_query(1, query);
PlayerInfo[playerid][pHasCar]++;
GivePlayerMoney(playerid, -CarInfo[i][CarPrice]);
}
else { NotForSale = true; }
} else { AlreadyHas = true; }
} else { noMoney = true; }
} else { notIn = true; }
}
if(in_range == true) return SendClientMessage(playerid, COLOR_RED, "You aren't near any for-sale car!");
if(noMoney == true) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money!");
if(AlreadyHas == true) return SendClientMessage(playerid, COLOR_RED, "You already have two cars!");
if(NotForSale == true) return SendClientMessage(playerid, COLOR_RED, "This vehicle isn't for sale!");
print("Done?");
return 1;
}
PHP код:
CarsLoad = clamp(cache_get_row_count(), 0, sizeof CarInfo - 1);