12.12.2013, 02:04

As shown in the screenshot, I typed the command (/forsale). It returned as it should, except it wouldn't make the label, if I make it spawn with the label it won't re-create it if I /forsale to turn it off.
(I /forsale'd it twice in the picture to show I was turning it on.)
It should display like the other vehicles (they are there after server respawn and I can use /forsale with no issue (I use mysql to load data).
Every other command I use for the car works correctly, even though it's a new spawn, except this one.
Yes, I've tried getting out the vehicle etc.
COMMAND
pawn Код:
CMD:forsale(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOUR_GREY, "You must be in a vehicle to use this.");
if(BizOwned[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You do not own a business.");
if(BizOwned[playerid] != VehBizID[vehicleid]) return SendClientMessage(playerid, COLOUR_GREY, "Your business does not own this vehicle.");
printf("Veh For Sale On Command %d",VehForSale[vehicleid]);
VehModel[vehicleid] = GetVehicleModel(vehicleid);
if(VehForSale[vehicleid] == 1)
{
VehForSale[vehicleid] = 0;
MySQL_SetInteger(VehicleSQLID[vehicleid], "VehForSale", 0, "vehicles");
SendClientMessage(playerid, COLOUR_WHITE, "Business vehicle is no longer for sale.");
DestroyDynamic3DTextLabel(VehicleLabel[vehicleid]);
}
else if(VehForSale[vehicleid] == 0)
{
VehForSale[vehicleid] = 1;
new string[80];
new Float: x, Float: y, Float: z;
MySQL_SetInteger(VehicleSQLID[vehicleid], "VehForSale", 1, "vehicles");
GetVehiclePos(vehicleid, x,y,z);
printf("%f %f %f", x,y,z);
format(string, sizeof(string), "%s, $%d, %s", VehicleNames[(VehModel[vehicleid] - 400)], VehPrice[vehicleid], VehPlate[vehicleid]);
VehicleLabel[vehicleid] = CreateDynamic3DTextLabel(string, COLOUR_ORANGE, x,y, z, 100.0, INVALID_PLAYER_ID, VehicleSQLID[vehicleid] , 0, 0, -1, -1, 20.0);
SendClientMessage(playerid, COLOUR_WHITE, "Business vehicle is now for sale.");
}
return 1;
}
pawn Код:
stock DealerOrderVehicle(playerid, model, price)
{
if(GetPlayerMoney(playerid) < price)return SendClientMessage(playerid, COLOUR_GREY, "You do not have enough money to purchase this vehicle.");
new string1[128], businessid = GetPlayerBizID(playerid), plate[8], colour1, colour2;
colour1 = random(126);
colour2 = random(126);
#define MAX_PLATE 8
new charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
new newPlate[MAX_PLATE + 1];
for(new i = 0; i < MAX_PLATE; i++)
{
newPlate[i] = charset[RandomEx(0, sizeof(charset)- 1)]; // 62 = strlen of charset
}
format(plate, sizeof(plate), "%s",newPlate);
if(BizType[businessid] == 2)
{
new vehicleid = CreateVehicle(model,-199.5428,1224.1710, 19.5659, 180.0,colour1, colour2, 0);
new query[550];
new vehslotfree = GetFreeMySQLSlot("vehicles");
if(vehslotfree == 0)
{
format(query, sizeof(query), "INSERT INTO `vehicles` (VehModel, VehOwner, VehSpawnX, VehSpawnY, VehSpawnZ,VehSpawnAngle, VehColour1, VehColour2, VehFuel, VehPlate, VehWep1,VehWepA1,VehWep2,VehWepA2, VehCash, VehArmour, VehFaction, VehFRank, VehOwned, VehFactioned, VehBizID, VehPrice,VehForSale) VALUES (%d, 0, -199.5428,1224.1710,19.5659,180.0,%d,%d,%d,'%s',0,0,0,0,0,0,0,0,0,0,%d,0,0)",model,colour1, colour2, random(100), plate, BizOwned[playerid]);
mysql_query(query);
VehicleSQLID[vehicleid] = mysql_insert_id();
}
else
{
format(query, sizeof(query), "UPDATE vehicles SET Inactive = 0, VehModel = %d, VehOwner = 0, VehSpawnX = %f, VehSpawnY = %f, VehSpawnZ = %f, VehSpawnAngle = %f, VehColour1 = %d, VehColour2 = %d, VehPlate = '%s', VehBizID = %d, VehForSale = 0 WHERE id = %d",model,VehSpawnX[vehicleid], VehSpawnY[vehicleid], VehSpawnZ[vehicleid], VehSpawnAngle[vehicleid], colour1, colour2,plate, BizOwned[playerid], vehslotfree);
mysql_query(query);
VehicleSQLID[vehicleid] = vehslotfree;
}
VehModel[vehicleid] = model;
SetVehicleNumberPlate(vehicleid, plate);
EngineStartStatus[vehicleid] = 0;
VehFuel[vehicleid] = random(100);
VehBizID[vehicleid] = BizOwned[playerid];
VehForSale[vehicleid] = 0;
VehPrice[vehicleid] = price;
VehFactioned[vehicleid] = 0;
VehOwner[vehicleid] = 0;
VehOwned[vehicleid] = 0;
VehPlate[vehicleid] = plate;
VehSpawnX[vehicleid] = -199.5428;
VehSpawnY[vehicleid] = 1224.1710;
VehSpawnZ[vehicleid] = 19.5659;
VehSpawnAngle[vehicleid] = 180.0;
printf("%d vehicle for sale", VehForSale[vehicleid]);
format(string1, sizeof(string1), "Your have ordered a %s (Cost: $%d.) for your business. Use /help business for further assistance", VehicleNames[model - 400], price);
SendClientMessage(playerid, COLOUR_WHITE, string1);
//PlayerMoney[playerid] = MySQL_GetValue(PlayerMoney[playerid], "Money", "accounts");
GivePlayerMoney(playerid, PlayerMoney[playerid] - price);
}
return 1;
}
Thanks in advance.