16.03.2015, 17:00
I have a problem with loading vehicles
This is my code:
The problem is that the text does not appear above the car ...
CarText:
When I do "printf("%d", Vehicles[i][vType]);" in public load_vehicle_data_VehicleData
It does not print anything ...
And I do not see any problem with the code ...
This is my code:
pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
print("=========================");
print("Load Vehicles ...");
LoadStaticVehiclesFromFile("ServerVehicles.ini");
new INI:ini, count;
for(new i; i < MAX_VEHICLES; i++)
{
format(vFile(i), 14, "Cars/%d.ini", i);
if(!fexist(vFile(i)))
{
if(!IsValidVehicle(i)) continue;
Vehicles[i][vModel] = GetVehicleModel(i);
GetVehiclePos(i, Vehicles[i][vPos][0], Vehicles[i][vPos][1], Vehicles[i][vPos][2]);
GetVehicleZAngle(i, Vehicles[i][vPos][3]);
Vehicles[i][vColor][0] = random(255);
Vehicles[i][vColor][1] = random(255);
Vehicles[i][vPrice] = GetVehiclePrice(GetVehicleModel(i));
Vehicles[i][vType] = VEHICLE_TYPE_PUBLIC;
Vehicles[i][vHaveOwners] = false;
Vehicles[i][vOwners] = EOS;
strcpy(Vehicles[i][vName], GetVehicleName(GetVehicleModel(i)), 32);
Vehicles[i][vPayTax] = 0;
Vehicles[i][vSale] = 0;
Vehicles[i][vTrade] = 0;
ini = INI_Open(vFile(i));
INI_SetTag(ini, "VehicleData");
INI_WriteInt(ini, "Model", Vehicles[i][vModel]);
INI_WriteFloat(ini, "X", Vehicles[i][vPos][0]);
INI_WriteFloat(ini, "Y", Vehicles[i][vPos][1]);
INI_WriteFloat(ini, "Z", Vehicles[i][vPos][2]);
INI_WriteFloat(ini, "A", Vehicles[i][vPos][3]);
INI_WriteInt(ini, "Color1", Vehicles[i][vColor][0]);
INI_WriteInt(ini, "Color2", Vehicles[i][vColor][1]);
INI_WriteInt(ini, "Price", Vehicles[i][vPrice]);
INI_WriteInt(ini, "Type", Vehicles[i][vType]);
INI_WriteBool(ini, "HaveOwners", Vehicles[i][vHaveOwners]);
INI_WriteString(ini, "Owners", Vehicles[i][vOwners]);
INI_WriteString(ini, "Name", Vehicles[i][vName]);
INI_WriteInt(ini, "PayTax", Vehicles[i][vPayTax]);
INI_WriteInt(ini, "Sale", Vehicles[i][vSale]);
INI_WriteInt(ini, "3DColor", Vehicles[i][v3DColor]);
INI_WriteString(ini, "3DText", Vehicles[i][v3DText]);
INI_WriteBool(ini, "HaveNitro", Vehicles[i][vHaveNitro]);
INI_WriteBool(ini, "HaveAutoNitro", Vehicles[i][vHaveAutoNitro]);
INI_WriteBool(ini, "HaveHyd", Vehicles[i][vHaveHyd]);
INI_WriteBool(ini, "HaveDisco", Vehicles[i][vHaveDisco]);
INI_WriteBool(ini, "DiscoActive", Vehicles[i][vDiscoActive]);
INI_WriteInt(ini, "Wheels", Vehicles[i][vWheels]);
INI_Close(ini);
Vehicles[i][vCreated] = true;
}
else INI_ParseFile(vFile(i), "load_vehicle_data_%s", .bExtra = true, .extra = i);
if(!IsValidVehicle(i)) continue;
CarText(i);
count++;
}
new vcount = AddStaticVehicle(411, 0.0, 0.0, 0.0, 0.0, -1, -1);
DestroyVehicle(vcount);
printf("%s Files Loaded | %s Vehicles loaded", GetNum(count), GetNum(vcount - 1));
return print("=========================");
}
forward load_vehicle_data_VehicleData(i, name[], value[]);
public load_vehicle_data_VehicleData(i, name[], value[])
{
INI_Int("Model", Vehicles[i][vModel]);
INI_Float("X", Vehicles[i][vPos][0]);
INI_Float("Y", Vehicles[i][vPos][1]);
INI_Float("Z", Vehicles[i][vPos][2]);
INI_Float("A", Vehicles[i][vPos][3]);
INI_Int("Color1", Vehicles[i][vColor][0]);
INI_Int("Color2", Vehicles[i][vColor][1]);
INI_Int("Price", Vehicles[i][vPrice]);
INI_Int("Type", Vehicles[i][vType]);
INI_Bool("HaveOwners", Vehicles[i][vHaveOwners]);
INI_String("Owners", Vehicles[i][vOwners], MAX_PLAYER_NAME + 1);
INI_String("Name", Vehicles[i][vName], 32);
INI_Int("PayTax", Vehicles[i][vPayTax]);
INI_Int("Sale", Vehicles[i][vSale]);
INI_Int("3DColor", Vehicles[i][v3DColor]);
INI_String("3DText", Vehicles[i][v3DText], 64);
INI_Bool("HaveNitro", Vehicles[i][vHaveNitro]);
INI_Bool("HaveAutoNitro", Vehicles[i][vHaveAutoNitro]);
INI_Bool("HaveHyd", Vehicles[i][vHaveHyd]);
INI_Bool("HaveDisco", Vehicles[i][vHaveDisco]);
INI_Bool("DiscoActive", Vehicles[i][vDiscoActive]);
INI_Int("Wheels", Vehicles[i][vWheels]);
Vehicles[i][vCreated] = true;
return 1;
}
CarText:
pawn Код:
forward CarText(i);
public CarText(i)
{
DestroyDynamic3DTextLabel(Vehicles[i][v3DLabel]);
if(!fexist(vFile(i))) return 1;
switch(Vehicles[i][vType])
{
case VEHICLE_TYPE_PUBLIC:
{
if(strlen(Vehicles[i][v3DText]) != 0) Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(Vehicles[i][v3DText], Vehicles[i][v3DColor], 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
else Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel("шлб цйбешй", Red, 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
}
case VEHICLE_TYPE_ADMIN:
{
if(strlen(Vehicles[i][v3DText]) != 0) Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(Vehicles[i][v3DText], Vehicles[i][v3DColor], 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
else Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel("шлб агойрйн", Yellow, 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
}
case VEHICLE_TYPE_HQ:
{
if(strlen(Vehicles[i][v3DText]) != 0) Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(Vehicles[i][v3DText], Vehicles[i][v3DColor], 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
else Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel("шлб офчгд", Red, 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
}
case VEHICLE_TYPE_REGULAR:
{
if(strlen(Vehicles[i][v3DText]) != 0) Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(Vehicles[i][v3DText], Vehicles[i][v3DColor], 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
else
{
new string[128];
if(Vehicles[i][vHaveOwners])
{
if(Vehicles[i][vSale]) format(string, sizeof string, ""purple"%s :бтмйн", Vehicles[i][vOwners]);
else format(string, sizeof string, "%s :бтмйн", Vehicles[i][vOwners]);
}
else format(string, sizeof string, ""green"фрей мшлйщд\n$%s :озйш", GetNum(Vehicles[i][vPrice]));
Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(string, Orange, 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
}
}
case VEHICLE_TYPE_SPECIAL:
{
if(strlen(Vehicles[i][v3DText]) != 0) Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(Vehicles[i][v3DText], Vehicles[i][v3DColor], 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
else
{
new string[128];
if(Vehicles[i][vHaveOwners])
{
if(Vehicles[i][vSale]) format(string, sizeof string, "шлб ойезг\n"purple"%s :бтмйн", Vehicles[i][vOwners]);
else format(string, sizeof string, "шлб ойезг\n"orange"%s :бтмйн", Vehicles[i][vOwners]);
}
else format(string, sizeof string, "шлб ойезг\n"green"фрей мшлйщд\n$%s :озйш", GetNum(Vehicles[i][vPrice]));
Vehicles[i][v3DLabel] = CreateDynamic3DTextLabel(string, Aqua, 0.0, 0.0, 1.2, 25.0, INVALID_PLAYER_ID, i);
}
}
}
return 1;
}
It does not print anything ...
And I do not see any problem with the code ...