//command to save the vehicles.
CMD:addhcar(playerid, params[])
{
new h;
if(!IsPlayerAdmin(playerid)) return 0;
if(!IsPlayerInAnyVehicle(playerid)) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_HCAR_NOT_IN_VEH);
if(sscanf(params, "d", h)) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_CMD_USAGE_ADDHCAR);
if(!fexist(HouseFile(h))) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_INVALID_HID);
else
{
if(hInfo[h][HouseCar] == 1) { ShowInfoBox(playerid, I_HCAR_EXIST_ALREADY, h); }
if(hInfo[h][HouseCar] == 0) { ShowInfoBox(playerid, I_HCAR_CREATED, h); }
GetVehiclePos(GetPlayerVehicleID(playerid), X, Y, Z);
GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
new world = GetPlayerVirtualWorld(playerid), interior = GetPlayerInterior(playerid);
hInfo[h][HouseCar] = 1, hInfo[h][HouseCarPosX] = X, hInfo[h][HouseCarPosY] = Y, hInfo[h][HouseCarPosZ] = Z, hInfo[h][HouseCarAngle] = Angle;
hInfo[h][HouseCarModel] = GetVehicleModel(GetPlayerVehicleID(playerid)), hInfo[h][HouseCarInterior] = interior, hInfo[h][HouseCarWorld] = world;
new INI:file = INI_Open(HouseFile(h));
INI_WriteFloat(file, "HCarPosX", X);
INI_WriteFloat(file, "HCarPosY", Y);
INI_WriteFloat(file, "HCarPosZ", Z);
INI_WriteFloat(file, "HCarAngle", Angle);
INI_WriteInt(file, "HCar", 1);
INI_WriteInt(file, "HCarWorld", world);
INI_WriteInt(file, "HCarInt", interior);
INI_WriteInt(file, "HCarModel", hInfo[h][HouseCarModel]);
INI_Close(file);
}
return 1;
}
function LoadHouseData(h, name[], value[])
{
if(!strcmp(name, "HouseName", true)) { format(hInfo[h][HouseName], MAX_HOUSE_NAME, "%s", value); }
if(!strcmp(name, "HouseOwner", true)) { format(hInfo[h][HouseOwner], MAX_PLAYER_NAME, "%s", value); }
if(!strcmp(name, "HouseLocation", true)) { format(hInfo[h][HouseLocation], MAX_ZONE_NAME, "%s", GetHouseLocation(h)); }
if(!strcmp(name, "HousePassword", true))
{
switch(strcmp(value, "INVALID_HOUSE_PASSWORD", true))
{
case 0: hInfo[h][HousePassword] = udb_hash(value);
case 1: hInfo[h][HousePassword] = strval(value);
}
}
if(!strcmp(name, "SpawnOutX", true)) { hInfo[h][SpawnOutX] = floatstr(value); }
if(!strcmp(name, "SpawnOutY", true)) { hInfo[h][SpawnOutY] = floatstr(value); }
if(!strcmp(name, "SpawnOutZ", true)) { hInfo[h][SpawnOutZ] = floatstr(value); }
if(!strcmp(name, "SpawnOutAngle", true)) { hInfo[h][SpawnOutAngle] = floatstr(value); }
if(!strcmp(name, "SpawnInterior", true)) { hInfo[h][SpawnInterior] = strval(value); }
if(!strcmp(name, "SpawnWorld", true)) { hInfo[h][SpawnWorld] = strval(value); }
if(!strcmp(name, "CPOutX", true)) { hInfo[h][CPOutX] = floatstr(value); }
if(!strcmp(name, "CPOutY", true)) { hInfo[h][CPOutY] = floatstr(value); }
if(!strcmp(name, "CPOutZ", true)) { hInfo[h][CPOutZ] = floatstr(value); }
if(!strcmp(name, "HouseValue", true)) { hInfo[h][HouseValue] = strval(value); }
if(!strcmp(name, "HouseStorage", true)) { hInfo[h][HouseStorage] = strval(value); }
if(!strcmp(name, "HouseInterior", true)) { hInfo[h][HouseInterior] = strval(value); }
if(!strcmp(name, "HouseWorld", true)) { hInfo[h][SpawnWorld] = strval(value); }
if(!strcmp(name, "HouseCar", true)) { hInfo[h][HouseCar] = strval(value); }
if(!strcmp(name, "HCarPosX", true)) { hInfo[h][HouseCarPosX] = floatstr(value); }
if(!strcmp(name, "HCarPosY", true)) { hInfo[h][HouseCarPosY] = floatstr(value); }
if(!strcmp(name, "HCarPosZ", true)) { hInfo[h][HouseCarPosZ] = floatstr(value); }
if(!strcmp(name, "HCarAngle", true)) { hInfo[h][HouseCarAngle] = floatstr(value); }
if(!strcmp(name, "HCarModel", true)) { hInfo[h][HouseCarModel] = strval(value); }
if(!strcmp(name, "HCarWorld", true)) { hInfo[h][HouseCarWorld] = strval(value); }
if(!strcmp(name, "HCarInt", true)) { hInfo[h][HouseCarInterior] = strval(value); }
if(!strcmp(name, "QuitInHouse", true)) { hInfo[h][QuitInHouse] = strval(value); }
if(!strcmp(name, "ForSale", true)) { hInfo[h][ForSale] = strval(value); }
if(!strcmp(name, "ForSalePrice", true)) { hInfo[h][ForSalePrice] = strval(value); }
if(!strcmp(name, "HousePrivacy", true)) { hInfo[h][HousePrivacy] = strval(value); }
if(!strcmp(name, "HouseAlarm", true)) { hInfo[h][HouseAlarm] = strval(value); }
if(!strcmp(name, "HouseCamera", true)) { hInfo[h][HouseCamera] = strval(value); }
if(!strcmp(name, "HouseDog", true)) { hInfo[h][HouseDog] = strval(value); }
if(!strcmp(name, "HouseUpgradedLock", true)) { hInfo[h][UpgradedLock] = strval(value); }
return 0;
}
stock LoadHouseCar(houseid)
{
if(fexist(HouseFile(houseid)) && hInfo[houseid][HouseCar] == 1)
{
HCar[houseid] = CreateVehicle(hInfo[houseid][HouseCarModel], hInfo[houseid][HouseCarPosX], hInfo[houseid][HouseCarPosY], hInfo[houseid][HouseCarPosZ], hInfo[houseid][HouseCarAngle], HCAR_COLOUR1, HCAR_COLOUR2, HCAR_RESPAWN);
SetVehicleVirtualWorld(HCar[houseid], hInfo[houseid][HouseCarWorld]);
LinkVehicleToInterior(HCar[houseid], hInfo[houseid][HouseCarInterior]);
}
return 1;
}
there should be a define at the beginning, that says,#define USE_HOUSECARS false
if you change false into true, it will load them not sure if this is exact as what i said above, but search for something like that |