Fine! I see that you're already assigning the file-id to its variable, then your OnPlayerEnterVehicle code could just be like this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Vehiclefile[256];
format(Vehiclefile, sizeof(Vehiclefile), "vehicles/Vehicle_%d.ini", vehicleid);
if(fexist(Vehiclefile))
{
Vehicles[i][FILEID] = dini_Int(Vehiclefile, "FILEID");
new string[128];
format(string, sizeof(string), "Car %d", Vehicles[i][FILEID]);
SendClientMessage(playerid, COLOUR_PURPLE, string);
}
return 1;
}
Though, I have some notes on your code:
1. Isn't 256 too much for your strings? Have you done your measurement or you're just dropping numbers? Stop wasting memory! Also why more strings when could be less, for example:
Instead of this:
pawn Код:
new Vehiclefile[256];
format(Vehiclefile, sizeof(Vehiclefile), "vehicles/Vehicle_%d.ini", vehicleid);
if(fexist(Vehiclefile))
{
Vehicles[i][FILEID] = dini_Int(Vehiclefile, "FILEID");
new string[128];
format(string, sizeof(string), "Car %d", Vehicles[i][FILEID]);
SendClientMessage(playerid, COLOUR_PURPLE, string);
}
You could do this, you can format strings twice and more if you want (unless you're gonna need to use them later):
pawn Код:
new string[appropriate size here for both uses];
format(string, sizeof(string), "vehicles/Vehicle_%d.ini", vehicleid);
if(fexist(string))
{
Vehicles[i][FILEID] = dini_Int(string, "FILEID");
format(string, sizeof(string), "Car %d", Vehicles[i][FILEID]);
SendClientMessage(playerid, COLOUR_PURPLE, string);
}
2. I have a feeling that you will probably face other problems in the future by the look of this:
pawn Код:
SpawnedVehicles++;
new id = SpawnedVehicles;
new Vehiclefile[256];
format(Vehiclefile, sizeof(Vehiclefile), "vehicles/Vehicle_%d.ini", id);
I think you're mixing up vehicle FileIDs and in-game vehicleids, however I could be wrong, it's your system anyway and you should know better.