Доступ к архиву

Переход в группу "Пользователь"

300.00 ₽
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Сохранения

Статус
В этой теме нельзя размещать новые ответы.

sk.tm_radik

Компетентный
Привет всем.

Вопрос мой в том что когда я ввожу команду /addhouse допустим создал пару домов то в бд сохраняется все правильно по порядку
так вот после этого я создаю командой /addhouseveh транспорт для дома так вот после этого у меня все перезаписывается в бд неправильно тоесть допустим было три строчки с домами где все было нормально а после команды все строчки перезаписались в одно. Вообщем смотрите ниже скриншот.
Так вот в чем может проблема?




PHP:
CMD:addhouse(playerid, params[]) // /addhouse Система домов
{
    new stirng[144], query_string[500], entrance_stirng[40], exit_stirng[40];
	GetPlayerPos(playerid, GetPos[playerid][0],GetPos[playerid][1],GetPos[playerid][2]);
    All_Houses++;
    HInfo[All_Houses][hID] = All_Houses;
    HInfo[All_Houses][hOwned] = 0;
    strins(HInfo[All_Houses][hOwner], "None", 0);
    HInfo[All_Houses][hEntrance][0] = GetPos[playerid][0];
    HInfo[All_Houses][hEntrance][1] = GetPos[playerid][1];
    HInfo[All_Houses][hEntrance][2] = GetPos[playerid][2];
    HInfo[All_Houses][hExit][0] = 235.4220;
    HInfo[All_Houses][hExit][1] = 1187.3510;
    HInfo[All_Houses][hExit][2] = 1080.2578;
    HInfo[All_Houses][hInt] = 3;
    HInfo[All_Houses][hVW] = All_Houses+50;
    HInfo[All_Houses][hVeh] = 0;
	HInfo[All_Houses][hPosVeh][0] = 0.0;
	HInfo[All_Houses][hPosVeh][1] = 0.0;
	HInfo[All_Houses][hPosVeh][2] = 0.0;
	HInfo[All_Houses][hPosVeh][3] = 0.0;
	HInfo[All_Houses][hColor][0] = 0;
	HInfo[All_Houses][hColor][1] = 0;
	HInfo[All_Houses][hPaintjob] = 0;
	for(new i; i < 14; i++) HInfo[All_Houses][hMods][i] = 0;
    HInfo[All_Houses][hPrice] = 32450;
    HInfo[All_Houses][hLevel] = 5;
    HInfo[All_Houses][hLock] = 1;
    HInfo[All_Houses][hMoney] = 0;
    HInfo[All_Houses][hMats] = 0;
    HInfo[All_Houses][hDrugs] = 0;
    HInfo[All_Houses][hHeal] = 0;
	HInfo[All_Houses][hArmor] = 0;
	CreateHouse(All_Houses);
    format(entrance_stirng, sizeof(entrance_stirng),"%f,%f,%f",HInfo[All_Houses][hEntrance][0],HInfo[All_Houses][hEntrance][1],HInfo[All_Houses][hEntrance][2]);
    format(exit_stirng, sizeof(exit_stirng),"%f,%f,%f",HInfo[All_Houses][hExit][0],HInfo[All_Houses][hExit][1],HInfo[All_Houses][hExit][2]);
    mysql_format(mysql_connect_id, query_string, sizeof(query_string),"INSERT INTO `houses` (`hID`, `hOwned`, `hOwner`, `hEntrance`, `hExit`, `hVW`, `hInt`, `hPosVeh`, `hColor`) VALUES ('%d', '0', 'None', '%s', '%s', '%d', '%d', '0.0,0.0,0.0,0.0', '0,0')",HInfo[All_Houses][hID],entrance_stirng,exit_stirng,HInfo[All_Houses][hVW],HInfo[All_Houses][hInt]);
    mysql_tquery(mysql_connect_id, query_string);
    format(stirng, sizeof(stirng),"Вы успешно создали дом [ID: %d].",HInfo[All_Houses][hID]),SendClientMessage(playerid, -1, stirng);
    format(stirng, sizeof(stirng),"Создать транспорт для дома - /addhouseveh %d.",HInfo[All_Houses][hID]),SendClientMessage(playerid, -1, stirng);
    return 1;
}
PHP:
CMD:addhouseveh(playerid, params[]) // /addhouseveh Система домов
{
	if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "Вы должны находиться в транспорте!");
	if(sscanf(params,"d",params[0])) return SendClientMessage(playerid, -1, "Используйте - /addhouseveh [номер дома]");
	if(params[0] > All_Houses) return SendClientMessage(playerid, -1, "Дом не найден!");
    new stirng[144], Float: Pos[4];
	GetVehiclePos(GetPlayerVehicleID(playerid), Pos[0], Pos[1], Pos[2]);
	GetVehicleZAngle(GetPlayerVehicleID(playerid), Pos[3]);
    HInfo[params[0]][hVeh] = GetVehicleModel(GetPlayerVehicleID(playerid));
	HInfo[params[0]][hPosVeh][0] = Pos[0];
	HInfo[params[0]][hPosVeh][1] = Pos[1];
	HInfo[params[0]][hPosVeh][2] = Pos[2];
	HInfo[params[0]][hPosVeh][3] = Pos[3];
	HInfo[params[0]][hColor][0] = 0;
	HInfo[params[0]][hColor][1] = 0;
	HInfo[params[0]][hPaintjob] = 0;
	for(new i; i < 14; i++) HInfo[params[0]][hMods][i] = 0;
    SaveHouse(params[0]);
    if(h_veh[params[0]] != 0) DestroyVehicle(h_veh[params[0]]);
    h_veh[params[0]] = CreateVehicle(HInfo[params[0]][hVeh], HInfo[params[0]][hPosVeh][0],HInfo[params[0]][hPosVeh][1],HInfo[params[0]][hPosVeh][2],HInfo[params[0]][hPosVeh][3], HInfo[params[0]][hColor][0],HInfo[params[0]][hColor][1], 5600);
    format(stirng, sizeof(stirng),"Вы успешно создали транспорт для дома [ID: %d].",HInfo[params[0]][hID]),SendClientMessage(playerid, -1, stirng);
    return 1;
}
PHP:
forward LoadHouses(); // Система домов
public LoadHouses()
{
    new rows, fields, entrance_stirng[100], exit_stirng[100], pveh_stirng[40], color_stirng[10], mods_stirng[100];
    cache_get_data(rows, fields);
	if(!rows) return 1;
    for(new h = 0; h < rows; h++)
    {
        HInfo[h][hID] = cache_get_field_content_int(h, "hID", mysql_connect_id);
        HInfo[h][hOwned] = cache_get_field_content_int(h, "hOwned", mysql_connect_id);
        cache_get_field_content(h, "hOwner", HInfo[h][hOwner], mysql_connect_id, 24);
        cache_get_field_content(h, "hEntrance", entrance_stirng, mysql_connect_id);
        sscanf(entrance_stirng,"p<,>fff",HInfo[h][hEntrance][0],HInfo[h][hEntrance][1],HInfo[h][hEntrance][2]);
        cache_get_field_content(h, "hExit", exit_stirng, mysql_connect_id);
        sscanf(exit_stirng,"p<,>fff",HInfo[h][hExit][0],HInfo[h][hExit][1],HInfo[h][hExit][2]);
        HInfo[h][hInt] = cache_get_field_content_int(h, "hInt", mysql_connect_id);
        HInfo[h][hVW] = cache_get_field_content_int(h, "hVW", mysql_connect_id);
	    HInfo[h][hVeh] = cache_get_field_content_int(h, "hVeh", mysql_connect_id);
	    cache_get_field_content(h, "hPosVeh", pveh_stirng, mysql_connect_id);
        sscanf(pveh_stirng,"p<,>ffff",HInfo[h][hPosVeh][0],HInfo[h][hPosVeh][1],HInfo[h][hPosVeh][2],HInfo[h][hPosVeh][3]);
        cache_get_field_content(h, "hColor", color_stirng, mysql_connect_id);
        sscanf(color_stirng,"p<,>dd",HInfo[h][hColor][0],HInfo[h][hColor][1]);
        HInfo[h][hPaintjob] = cache_get_field_content_int(h, "hPaintjob", mysql_connect_id);
        cache_get_field_content(h, "hMods", mods_stirng, mysql_connect_id);
        sscanf(mods_stirng,"p<,>dddddddddddddd",HInfo[h][hMods][0],HInfo[h][hMods][1],HInfo[h][hMods][2],HInfo[h][hMods][3],HInfo[h][hMods][4],HInfo[h][hMods][5],HInfo[h][hMods][6],HInfo[h][hMods][7],HInfo[h][hMods][8],HInfo[h][hMods][9],HInfo[h][hMods][10],HInfo[h][hMods][11],HInfo[h][hMods][12],HInfo[h][hMods][13]);
        HInfo[h][hPrice] = cache_get_field_content_int(h, "hPrice", mysql_connect_id);
        HInfo[h][hLevel] = cache_get_field_content_int(h, "hLevel", mysql_connect_id);
	    HInfo[h][hLock] = cache_get_field_content_int(h, "hLock", mysql_connect_id);
	    HInfo[h][hMoney] = cache_get_field_content_int(h, "hMoney", mysql_connect_id);
	    HInfo[h][hMats] = cache_get_field_content_int(h, "hMats", mysql_connect_id);
	    HInfo[h][hDrugs] = cache_get_field_content_int(h, "hDrugs", mysql_connect_id);
	    HInfo[h][hHeal] = cache_get_field_content_int(h, "hHeal", mysql_connect_id);
	    HInfo[h][hArmor] = cache_get_field_content_int(h, "hArmor", mysql_connect_id);
	    CreateHouse(h);
		LoadTuning(h);
		All_Houses++;
    }
    printf("[info] Дома загружены: %d",All_Houses);
    return 1;
}
stock SaveHouse(h) // Система домов
{
    new query_string[500], entrance_stirng[100], exit_stirng[100], pveh_stirng[40], color_stirng[10], mods_stirng[100];
    format(entrance_stirng, sizeof(entrance_stirng),"%f,%f,%f",HInfo[h][hEntrance][0],HInfo[h][hEntrance][1],HInfo[h][hEntrance][2]);
    format(exit_stirng, sizeof(exit_stirng),"%f,%f,%f",HInfo[h][hExit][0],HInfo[h][hExit][1],HInfo[h][hExit][2]);
    format(pveh_stirng, sizeof(pveh_stirng),"%f,%f,%f,%f",HInfo[h][hPosVeh][0],HInfo[h][hPosVeh][1],HInfo[h][hPosVeh][2],HInfo[h][hPosVeh][3]);
    format(color_stirng, sizeof(color_stirng),"%d,%d",HInfo[h][hColor][0],HInfo[h][hColor][1]);
    format(mods_stirng, sizeof(mods_stirng),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",HInfo[h][hMods][0],HInfo[h][hMods][1],HInfo[h][hMods][2],HInfo[h][hMods][3],HInfo[h][hMods][4],HInfo[h][hMods][5],HInfo[h][hMods][6],HInfo[h][hMods][7],HInfo[h][hMods][8],HInfo[h][hMods][9],HInfo[h][hMods][10],HInfo[h][hMods][11],HInfo[h][hMods][12],HInfo[h][hMods][13]);
    mysql_format(mysql_connect_id, query_string, sizeof(query_string),"UPDATE `houses` SET `hID` = '%d', `hOwned` = '%d', `hOwner` = '%s', `hEntrance` = '%s', `hExit` = '%s', `hInt` = '%d', `hVW` = '%d', `hVeh` = '%d', `hPosVeh` = '%s' WHERE `hColor` = '%s'",
    HInfo[h][hID],
    HInfo[h][hOwned],
    HInfo[h][hOwner],
    entrance_stirng,
	exit_stirng,
	HInfo[h][hInt],
    HInfo[h][hVW],
	HInfo[h][hVeh],
    pveh_stirng,
    color_stirng);
    mysql_tquery(mysql_connect_id, query_string);
    mysql_format(mysql_connect_id, query_string, sizeof(query_string),"UPDATE `houses` SET `hPaintjob` = '%d', `hMods` = '%s', `hPrice` = '%d', `hLevel` = '%d', `hLock` = '%d', `hMoney` = '%d', `hMats` = '%d' WHERE `hDrugs` = '%d'",
    HInfo[h][hPaintjob],
    mods_stirng,
    HInfo[h][hPrice],
    HInfo[h][hLevel],
	HInfo[h][hLock],
    HInfo[h][hMoney],
    HInfo[h][hMats],
    HInfo[h][hDrugs]);
	mysql_tquery(mysql_connect_id, query_string);
    mysql_format(mysql_connect_id, query_string, sizeof(query_string),"UPDATE `houses` SET `hHeal` = '%d' WHERE `hArmor` = '%d'",
    HInfo[h][hHeal],
    HInfo[h][hArmor]);
	mysql_tquery(mysql_connect_id, query_string);
	return 1;
}
 
Последнее редактирование:
Статус
В этой теме нельзя размещать новые ответы.
Сверху Снизу