Nil_Pet
Умник
Пожалуйста помогите с базой данных домов я в них нуб я не могу ее составить в чем у меня ошибка
Вот мое База данных домов
Вот команда создание дома
У меня он после перезагрузки сервера не сохраняется в базе данных mysql домов
Вот загрузка домов
Помогите нубу
И вот сохранение домов
Вот мое База данных домов
PHP:
REATE TABLE IF NOT EXISTS `house` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`hOwner` varchar(32) NOT NULL DEFAULT 'None',
`hEnterx` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0',
`hEntery` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0',
`hEnterz` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0',
`hExitx` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0',
`hExity` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0',
`hExitz` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0',
`hPrice` int(11) NOT NULL DEFAULT '0',
`hInt` int(11) NOT NULL DEFAULT '0',
`hClass` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
PHP:
CMD:chouse(playerid,params[])
{
new Float:PosX,Float:PosY,Float:PosZ;
new Float:ExitX,Float:ExitY,Float:ExitZ,Interior;
if(PlayerInfo[playerid][pAdmin] < 6) return true;
if(sscanf(params,"iii",params[0],params[1],params[2])) return SCM(playerid,-1,"Используйте: /chouse [Класс] [Цена] [Интерьер дома]");
if(!GetPlayerVehicleID(playerid))
{
if(params[2] < 1 || params[2] > 26) return SCM(playerid,red,"Неверный интерьер дома. Введите /tpint");
GetPlayerPos(playerid,PosX,PosY,PosZ);
switch(params[2])
{
case 1: { ExitX = 2233.6423; ExitY = -1115.2604; ExitZ = 1050.8828; Interior = 5; }
case 2: { ExitX = 2259.3833; ExitY = -1135.7765; ExitZ = 1050.6403; Interior = 10; }
case 3: { ExitX = 221.7961; ExitY = 1140.1957; ExitZ = 1082.6094; Interior = 4; }
case 4: { ExitX = 2218.4016; ExitY = -1076.3292; ExitZ = 1050.4844; Interior = 1; }
case 5: { ExitX = -42.6558; ExitY = 1405.4763; ExitZ = 1084.4297; Interior = 8; }
case 6: { ExitX = 260.7471; ExitY = 1237.5288; ExitZ = 1084.2578; Interior = 9; }
case 7: { ExitX = 2237.4856; ExitY = -1081.6361; ExitZ = 1049.0234; Interior = 2; }
case 8: { ExitX = -68.8527; ExitY = 1351.1975; ExitZ = 1080.2109; Interior = 6; }
case 9: { ExitX = 223.1055; ExitY = 1287.0765; ExitZ = 1082.1406; Interior = 1; }
case 10: { ExitX = 226.7857; ExitY = 1239.9708; ExitZ = 1082.1406; Interior = 2; }
case 11: { ExitX = 447.0353; ExitY = 1397.0632; ExitZ = 1084.3047; Interior = 2; }
case 12: { ExitX = 295.2918; ExitY = 1472.2563; ExitZ = 1080.2578; Interior = 15; }
case 13: { ExitX = 295.1453; ExitY = 1472.2563; ExitZ = 1080.2578; Interior = 15; }
case 14: { ExitX = 22.8414; ExitY = 1403.3251; ExitZ = 1084.4370; Interior = 5; }
case 15: { ExitX = 2365.2424; ExitY = -1135.5955; ExitZ = 1050.8826; Interior = 8; }
case 16: { ExitX = 2807.7151; ExitY = -1174.7552; ExitZ = 1025.5703; Interior = 8; }
case 17: { ExitX = 235.2912; ExitY = 1186.6814; ExitZ = 1080.2578; Interior = 3; }
case 18: { ExitX = 23.9711; ExitY = 1340.1598; ExitZ = 1084.3750; Interior = 10; }
case 19: { ExitX = 83.0452; ExitY = 1322.2833; ExitZ = 1083.8662; Interior = 9; }
case 20: { ExitX = -283.4403; ExitY = 1470.9785; ExitZ = 1084.3750; Interior = 15; }
case 21: { ExitX = -260.4859; ExitY = 1456.6578; ExitZ = 1084.3672; Interior = 4; }
case 22: { ExitX = 2317.7705; ExitY = -1026.7661; ExitZ = 1050.2178; Interior = 9; }
case 23: { ExitX = 234.1428; ExitY = 1063.7218; ExitZ = 1084.2123; Interior = 6; }
case 24: { ExitX = 140.2813; ExitY = 1365.9230; ExitZ = 1083.8594; Interior = 5; }
case 25: { ExitX = 2324.3484; ExitY = -1149.5460; ExitZ = 1050.7101; Interior = 12; }
case 26: { ExitX = 226.2991; ExitY = 1114.3654; ExitZ = 1080.9929; Interior = 5; }
}
new query[500];
format(query,sizeof(query),"INSERT INTO `"TABLE_HOUSES"` (`hEnterX`,`hEnterY`,`hEnterZ`,`hExitX`,`hExitY`,` hExitZ`,`hPrice`,`hInt`,`hClass`)\
VALUES ('%f','%f','%f','%f','%f','%f','%i','%i','%i')",
PosX,PosY,PosZ,ExitX,ExitY,ExitZ,params[1],Interior,params[0]);
mysql_function_query(ConBD,query,false,"","");
SCM(playerid,blue,"Дом создан");
SCM(playerid,blue,"Дом появится после перезагрузки");
}
return true;
}
Вот загрузка домов
PHP:
public OnHousesLoad() // Коллбэйк загрузки
{
new time = GetTickCount();
new string[128],klass[2];
new temp[32],rows,fields;
cache_get_data(rows,fields,ConBD);
if(rows)
{
for(new idx = 1; idx <= rows; idx++)
{
cache_get_field_content(idx-1,"hID",temp,ConBD), HouseInfo[idx][hID] = strval(temp);
cache_get_field_content(idx-1,"hOwned",temp,ConBD), HouseInfo[idx][hOwned] = strval(temp);
cache_get_field_content(idx-1,"hOwner",HouseInfo[idx][hOwner],ConBD);
cache_get_field_content(idx-1,"hEnterX",temp,ConBD), HouseInfo[idx][hEnterX] = floatstr(temp);
cache_get_field_content(idx-1,"hEnterY",temp,ConBD), HouseInfo[idx][hEnterY] = floatstr(temp);
cache_get_field_content(idx-1,"hEnterZ",temp,ConBD), HouseInfo[idx][hEnterZ] = floatstr(temp);
cache_get_field_content(idx-1,"hExitX",temp,ConBD), HouseInfo[idx][hExitX] = floatstr(temp);
cache_get_field_content(idx-1,"hExitY",temp,ConBD), HouseInfo[idx][hExitY] = floatstr(temp);
cache_get_field_content(idx-1,"hExitZ",temp,ConBD), HouseInfo[idx][hExitZ] = floatstr(temp);
cache_get_field_content(idx-1,"hLevel",temp,ConBD), HouseInfo[idx][hLevel] = strval(temp);
cache_get_field_content(idx-1,"hPrice",temp,ConBD), HouseInfo[idx][hPrice] = strval(temp);
cache_get_field_content(idx-1,"hLock",temp,ConBD), HouseInfo[idx][hLock] = strval(temp);
cache_get_field_content(idx-1,"hTakings",temp,ConBD), HouseInfo[idx][hTakings] = strval(temp);
cache_get_field_content(idx-1,"hInt",temp,ConBD), HouseInfo[idx][hInt] = strval(temp);
cache_get_field_content(idx-1,"hHel",temp,ConBD), HouseInfo[idx][hHel] = strval(temp);
cache_get_field_content(idx-1,"hClass",temp,ConBD), HouseInfo[idx][hClass] = strval(temp);
TOTALHOUSES++;
if(HouseInfo[idx][hOwned] == 0)
{
HouseInfo[idx][hPickupID] = CreatePickup(1273, 23, HouseInfo[idx][hEnterX], HouseInfo[idx][hEnterY], HouseInfo[idx][hEnterZ],-1);
HouseInfo[idx][hIconID] = CreateDynamicMapIcon(HouseInfo[idx][hEnterX], HouseInfo[idx][hEnterY], HouseInfo[idx][hEnterZ], 31, red, 0, -1, -1, 200.0);
switch(HouseInfo[idx][hClass])
{
case 0: klass = "E";
case 1: klass = "D";
case 2: klass = "C";
case 3: klass = "B";
case 4: klass = "A";
case 5: klass = "S";
}
format(string,256,"Номер: %i\nЦена: %i \nКласс: %s",idx,HouseInfo[idx][hPrice],klass);
HouseInfo[idx][hTextID] = Create3DTextLabel(string,yellow,HouseInfo[idx][hEnterX], HouseInfo[idx][hEnterY], HouseInfo[idx][hEnterZ],20.0,0,1);
}
else
{
HouseInfo[idx][hPickupID] = CreatePickup(1272, 23, HouseInfo[idx][hEnterX], HouseInfo[idx][hEnterY], HouseInfo[idx][hEnterZ],-1);
HouseInfo[idx][hIconID] = CreateDynamicMapIcon(HouseInfo[idx][hEnterX], HouseInfo[idx][hEnterY], HouseInfo[idx][hEnterZ], 32, red, 0, -1, -1, 200.0);
switch(HouseInfo[idx][hClass])
{
case 0: klass = "E";
case 1: klass = "D";
case 2: klass = "C";
case 3: klass = "B";
case 4: klass = "A";
case 5: klass = "S";
}
format(string,256,"Дом: %i\nВладелец: %s\nКласс: %s",idx,HouseInfo[idx][hOwner],klass);
HouseInfo[idx][hTextID] = Create3DTextLabel(string,-1,HouseInfo[idx][hEnterX], HouseInfo[idx][hEnterY], HouseInfo[idx][hEnterZ],20.0,0,1);
}
}
}
printf("[Загрузка домов]: <%i>. Загруженно домов: <%i ìñ>",TOTALHOUSES,GetTickCount()-time);
return true;
}
И вот сохранение домов
PHP:
public OnHouseSave(houseid) // Коллбэйк сохранение домов
{
new string[32],query[256];
format(string,sizeof(string),"UPDATE `"TABLE_HOUSES"` SET "),strcat(query,string);
format(string,sizeof(string),"`hOwned` = '%i', ",HouseInfo[houseid][hOwned]),strcat(query,string);
format(string,sizeof(string),"`hOwner` = '%s', ",HouseInfo[houseid][hOwner]),strcat(query,string);
format(string,sizeof(string),"`hEnterX` = '%f', ",HouseInfo[houseid][hEnterX]),strcat(query,string);
format(string,sizeof(string),"`hEnterY` = '%f', ",HouseInfo[houseid][hEnterY]),strcat(query,string);
format(string,sizeof(string),"`hEnterZ` = '%f', ",HouseInfo[houseid][hEnterZ]),strcat(query,string);
format(string,sizeof(string),"`hExitX` = '%f', ",HouseInfo[houseid][hExitX]),strcat(query,string);
format(string,sizeof(string),"`hExitY` = '%f', ",HouseInfo[houseid][hExitY]),strcat(query,string);
format(string,sizeof(string),"`hExitZ` = '%f', ",HouseInfo[houseid][hExitZ]),strcat(query,string);
format(string,sizeof(string),"`hLevel` = '%i', ",HouseInfo[houseid][hLevel]),strcat(query,string);
format(string,sizeof(string),"`hPrice` = '%i', ",HouseInfo[houseid][hPrice]),strcat(query,string);
format(string,sizeof(string),"`hLock` = '%i', ",HouseInfo[houseid][hLock]),strcat(query,string);
format(string,sizeof(string),"`hTakings` = '%i', ",HouseInfo[houseid][hTakings]),strcat(query,string);
format(string,sizeof(string),"`hInt` = '%i', ",HouseInfo[houseid][hInt]),strcat(query,string);
format(string,sizeof(string),"`hHel` = '%i', ",HouseInfo[houseid][hHel]),strcat(query,string);
format(string,sizeof(string),"`hClass` = '%i' ",HouseInfo[houseid][hClass]),strcat(query,string);
format(string,sizeof(string),"WHERE `hID` = '%i'",HouseInfo[houseid][hID]),strcat(query,string);
mysql_function_query(ConBD,query,false,"","");
return true;
}
Последнее редактирование:
