12.07.2016, 07:06
I'm working on a vehicle system. I This is how I load and save the vehicle data.
Everything loads and saves fine except for the Owner's name. I try this in OnPlayerEnterVehicle
And this shows:
Any Ideas?
PHP код:
enum vInfo {
vID,
vModel,
Float:xSpawn,
Float:ySpawn,
Float:zSpawn,
Float:angleSpawn,
vCol1,
vCol2,
vPaintjob,
vRespawn,
vOwner[MAX_PLAYER_NAME],
vPrice,
bool:isOwned,
bool:vBuyable
}
new VehicleInfo[MAX_VEHICLES][vInfo];
new bool:vCreated[MAX_VEHICLES];
public LoadVehicleData(vehicleID, name[], value[]) {
INI_Int("model", VehicleInfo[vehicleID][vModel]);
INI_Float("LocX", VehicleInfo[vehicleID][xSpawn]);
INI_Float("LocY", VehicleInfo[vehicleID][ySpawn]);
INI_Float("LocZ", VehicleInfo[vehicleID][zSpawn]);
INI_Float("LocAngle", VehicleInfo[vehicleID][angleSpawn]);
INI_Int("color1", VehicleInfo[vehicleID][vCol1]);
INI_Int("color2", VehicleInfo[vehicleID][vCol2]);
INI_Int("paintjob", VehicleInfo[vehicleID][vPaintjob]);
INI_Int("respawn", VehicleInfo[vehicleID][vRespawn]);
INI_String("owner", VehicleInfo[vehicleID][vOwner], MAX_PLAYER_NAME);
INI_Int("price", VehicleInfo[vehicleID][vPrice]);
INI_Bool("owned", VehicleInfo[vehicleID][isOwned]);
INI_Bool("buyable", VehicleInfo[vehicleID][vBuyable]);
return 1;
}
stock SaveVehicle(vehicleID) {
new INI:dFile = INI_Open(VehiclePath(vehicleID));
INI_WriteInt(dFile, "model", VehicleInfo[vehicleID][vModel]);
INI_WriteFloat(dFile, "LocX", VehicleInfo[vehicleID][xSpawn]);
INI_WriteFloat(dFile, "LocY", VehicleInfo[vehicleID][ySpawn]);
INI_WriteFloat(dFile, "LocZ", VehicleInfo[vehicleID][zSpawn]);
INI_WriteFloat(dFile, "LocAngle", VehicleInfo[vehicleID][angleSpawn]);
INI_WriteInt(dFile, "color1", VehicleInfo[vehicleID][vCol1]);
INI_WriteInt(dFile, "color2", VehicleInfo[vehicleID][vCol2]);
INI_WriteInt(dFile, "paintjob", VehicleInfo[vehicleID][vPaintjob]);
INI_WriteInt(dFile, "respawn", VehicleInfo[vehicleID][vRespawn]);
INI_WriteString(dFile, "owner", VehicleInfo[vehicleID][vOwner]);
INI_WriteInt(dFile,"price", VehicleInfo[vehicleID][vPrice]);
INI_WriteBool(dFile, "owned", VehicleInfo[vehicleID][isOwned]);
INI_WriteBool(dFile, "buyable", VehicleInfo[vehicleID][vBuyable]);
INI_Close(dFile);
return 1;
}
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger) {
new str[256];
new vid = GetVID(vehicleid);
new owned[24];
if(VehicleInfo[vid][isOwned]) { // testing purpose
format(owned, 24, "true");
} else {
format(owned, 24, "false");
}
format(str, sizeof(str), "Owner: %s | SID: %i |ID: %i | VModel: %i | Price: %i | Owned: %s | Color 1: %i | Color 2: %i | Paintjob: %i | Respawn: %i", VehicleInfo[vid][vOwner], vehicleid, VehicleInfo[vid][vID],VehicleInfo[vid][vModel], VehicleInfo[vid][vPrice], owned, VehicleInfo[vid][vCol1], VehicleInfo[vid][vCol2], VehicleInfo[vid][vPaintjob], VehicleInfo[vid][vRespawn]);
SendClientMessage(playerid, -1, str);
}
return 1;
}
Any Ideas?