29.04.2014, 00:20
Hello. When I buy a safe for my house using a dialog it creates the safe and places it inside for me.
But when I reload the game mode, it loads all other house information but it doesn't create the safe object?
Thanks
pawn Код:
if(dialogid == DIALOG_FURNI)
{
new string[128], i = PlayerInfo[playerid][pHouse];
if(response)
{
switch(listitem)
{
case 0:
{
if(PlayerInfo[playerid][pCash] < Safe)
{
SendClientMessage(playerid, COLOR_RED, "Error"White": You don't have enough cash to purchase a house safe.");
return 1;
}
if(HouseInfo[i][hSafe] >= 0)
{
SendClientMessage(playerid, COLOR_RED, "Error"White": Your house already contains a safe.");
return 1;
}
else
{
HouseInfo[i][hSafe] = CreateDynamicObject(2332, 273.93460, 304.21188, 998.54669, 356.85840, 0.00000, 270.00000, HouseInfo[i][hVirtualWorld], HouseInfo[i][hInterior], -1, 300.0);
format(string, sizeof(string), "Shop Assistant"White": You have purchased a House Safe for "Green"$%d"White". It has been placed in your house automatically!", Safe);
SendClientMessage(playerid, COLOR_YELLOW, string);
GiveCash(playerid, -Safe);
SaveHouse(i);
return 1;
}
}
}
}
}
pawn Код:
public HousesLoad()
{
new temp[400], string[200], rows, fields;
cache_get_data(rows, fields, g_Handle);
new id = 0;
if(rows)
{
while(id <= rows-1)
{
cache_get_row(id, 0, temp, g_Handle), HouseInfo[id][hHouseID] = strval(temp);
cache_get_row(id, 1, HouseInfo[id][hAddress], g_Handle, 32);
cache_get_row(id, 2, HouseInfo[id][hOwner], g_Handle, 35);
cache_get_row(id, 3, temp, g_Handle), HouseInfo[id][hPrice] = strval(temp);
cache_get_row(id, 4, temp, g_Handle), HouseInfo[id][hEnterPos][0] = floatstr(temp);
cache_get_row(id, 5, temp, g_Handle), HouseInfo[id][hEnterPos][1] = floatstr(temp);
cache_get_row(id, 6, temp, g_Handle), HouseInfo[id][hEnterPos][2] = floatstr(temp);
cache_get_row(id, 7, temp, g_Handle), HouseInfo[id][hEnterPos][3] = floatstr(temp);
cache_get_row(id, 8, temp, g_Handle), HouseInfo[id][hExitPos][0] = floatstr(temp);
cache_get_row(id, 9, temp, g_Handle), HouseInfo[id][hExitPos][1] = floatstr(temp);
cache_get_row(id, 10, temp, g_Handle), HouseInfo[id][hExitPos][2] = floatstr(temp);
cache_get_row(id, 11, temp, g_Handle), HouseInfo[id][hExitPos][3] = floatstr(temp);
cache_get_row(id, 12, temp, g_Handle), HouseInfo[id][hInterior] = strval(temp);
cache_get_row(id, 13, temp, g_Handle), HouseInfo[id][hVirtualWorld] = strval(temp);
cache_get_row(id, 14, temp, g_Handle), HouseInfo[id][hType] = strval(temp);
cache_get_row(id, 15, temp, g_Handle), HouseInfo[id][hLock] = strval(temp);
cache_get_row(id, 16, temp, g_Handle), HouseInfo[id][hSafe] = strval(temp);
if(HouseInfo[id][hSafe] != -1)
{
HouseInfo[id][hSafe] = CreateDynamicObject(2332, 273.93460, 304.21188, 998.54669, 356.85840, 0.00000, 270.00000, HouseInfo[id][hVirtualWorld], HouseInfo[id][hInterior], -1, 300.0);
SaveHouse(id);
}
if(!strcmp("None", HouseInfo[id][hOwner], false))
{
HouseInfo[id][hPickup] = CreateDynamicPickup(1273, 23, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], -1, -1, -1, 100.0);
format(string, sizeof(string), "Type"White": %s\n"Aqua"Address"White": %s\n"Aqua"Owner"White": None\n"Aqua"Price"White": $%d\n"Aqua"Status"White": Unlocked", HouseType(id), HouseInfo[id][hAddress], HouseInfo[id][hPrice]);
HouseInfo[id][hText] = CreateDynamic3DTextLabel(string, COLOR_AQUA, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], 25, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
}
else
{
HouseInfo[id][hPickup] = CreateDynamicPickup(1273, 23, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], -1, -1, -1, 100.0);
format(string, sizeof(string), "Type"White": %s\n"Aqua"Address"White": %s\n"Aqua"Owner"White": %s\n"Aqua"Status"White": %s", HouseType(id), HouseInfo[id][hAddress], HouseInfo[id][hOwner], HouseStatus(id));
HouseInfo[id][hText] = CreateDynamic3DTextLabel(string, COLOR_AQUA, HouseInfo[id][hEnterPos][0], HouseInfo[id][hEnterPos][1], HouseInfo[id][hEnterPos][2], 25, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 100);
}
id ++;
}
houseid = rows;
}
else
{
for(new i = 0; i < MAX_HOUSES; i++)
{
HouseInfo[i][hHouseID] = -1;
}
}
return 1;
}