03.08.2014, 13:58
вот в общем загрузка сохранение и команда:
PHP код:
stock SavePropertys()
{
for(new houseid = 1; houseid <= TotalHouse; houseid++)
{
mysql_format(MYSQL_ARG, asd, sizeof(asd),"UPDATE `House` SET `hEntrancex` = '%f', `hEntrancey` = '%f',`hEntrancez` = '%f',`hExitx` = '%f', `hExity` = '%f', `hExitz` = '%f',`hOwner` = '%e', `hValue` = '%d',`hHel` = '%d', `hInt` = '%d',`hLock` = '%d',`hOwned` = '%d',`hTakings` = '%d', `hVec` = '%d',`hVcol1` = '%d',`hVcol2` = '%d', `hKlass` = '%d', `hCarx` = '%f',`hCary` = '%f', `hCarz` = '%f', `hCarc` = '%f' WHERE `hID` = '%d'",
HouseInfo[houseid][hEntrancex],
HouseInfo[houseid][hEntrancey],
HouseInfo[houseid][hEntrancez],
HouseInfo[houseid][hExitx],
HouseInfo[houseid][hExity],
HouseInfo[houseid][hExitz],
HouseInfo[houseid][hOwner],
HouseInfo[houseid][hValue],
HouseInfo[houseid][hHel],
HouseInfo[houseid][hInt],
HouseInfo[houseid][hLock],
HouseInfo[houseid][hOwned],
HouseInfo[houseid][hTakings],
HouseInfo[houseid][hVec],
HouseInfo[houseid][hVcol1],
HouseInfo[houseid][hVcol2],
HouseInfo[houseid][hKlass],
HouseInfo[houseid][hCarx],
HouseInfo[houseid][hCary],
HouseInfo[houseid][hCarz],
HouseInfo[houseid][hCarc],
HouseInfo[houseid][hID]
);
mysql_function_query(MYSQL_ARG, asd, false, "", "");//Îòïðàâëÿåì çàïðîñ
}
}
PHP код:
else if(strcmp(cmd, "/addh", true) == 0)
{
//if(PlayerInfo[playerid][pLogin] == 0) return true;
if(!IsPlayerConnected(playerid)) return true;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "Ââåäèòå: /addh [êëàññ] [öåíà]");
new stat12 = strval(tmp);
if(stat12 < 0 || stat12 > 4) return SCM(playerid, COLOR_WHITE, "Íå âåðíûé èä êëàññà (Îò 0 äî 4)");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "Ââåäèòå: /addh [êëàññ] [öåíà]");
new stat1 = strval(tmp);
if(stat1 < 1 || stat1 > 1000000000) return SCM(playerid, COLOR_WHITE, "Íå âåðíîå çíà÷åíèå.");
new Float: posX, Float: posY, Float: posZ;
GetPlayerPos(playerid, posX, posY, posZ);
TotalHouse++;
///////// hID hEntrancex hEntrancey hEntrancez hExitx hExity hExitz hOwner hValue hHel hInt hLock hOwned hTakings hVec hVcol1 hVcol2 hKlass hCarx hCary hCarz hCarc
// format(asd, 256, "INSERT INTO `House` (`hID`,`hEntrancex`, `hEntrancey`,`hEntrancez`) VALUES ('%d','%f', '%f', '%f')",TotalHouse,posX,posY,posZ);
// mysql_function_query(MYSQL_ARG, asd, false, "", "");
mysql_format(MYSQL_ARG,asd, sizeof(asd), "INSERT INTO `House` (`hID`,`hEntrancex`, `hEntrancey`,`hEntrancez`) VALUES ('%d','%f', '%f', '%f')",TotalHouse,posX,posY,posZ);
mysql_function_query(MYSQL_ARG, asd, false, "", "");
HouseInfo[TotalHouse][hID] = TotalHouse;
HouseInfo[TotalHouse][hEntrancex] = posX;
HouseInfo[TotalHouse][hEntrancey] = posY;
HouseInfo[TotalHouse][hEntrancez] = posZ;
HouseInfo[TotalHouse][hLock] = 1;
HouseInfo[TotalHouse][hKlass] = stat12;
HouseInfo[TotalHouse][hValue] = stat1;
HouseInfo[TotalHouse][hInt] = 10;
HouseInfo[TotalHouse][hExitx] = 421.7613;
HouseInfo[TotalHouse][hExity] = 2536.4836;
HouseInfo[TotalHouse][hExitz] = 10.0000;
if(HouseInfo[TotalHouse][hKlass] == 1)
{
HouseInfo[TotalHouse][hInt] = 6;
HouseInfo[TotalHouse][hExitx] = -68.8618;
HouseInfo[TotalHouse][hExity] = 1352.2183;
HouseInfo[TotalHouse][hExitz] = 1080.2109;
}
else if(HouseInfo[TotalHouse][hKlass] == 2)
{
HouseInfo[TotalHouse][hInt] = 5;
HouseInfo[TotalHouse][hExitx] = 22.7405;
HouseInfo[TotalHouse][hExity] = 1404.3799;
HouseInfo[TotalHouse][hExitz] = 1084.4297;
}
else if(HouseInfo[TotalHouse][hKlass] == 3)
{
HouseInfo[TotalHouse][hInt] = 12;
HouseInfo[TotalHouse][hExitx] = 2324.3367;
HouseInfo[TotalHouse][hExity] = -1148.6296;
HouseInfo[TotalHouse][hExitz] = 1050.7101;
}
else
{
HouseInfo[TotalHouse][hInt] = 5;
HouseInfo[TotalHouse][hExitx] = 140.2206;
HouseInfo[TotalHouse][hExity] = 1367.2734;
HouseInfo[TotalHouse][hExitz] = 1083.8612;
}
HouseInfo[TotalHouse][hPickup] = CreatePickup(1273, 23, HouseInfo[TotalHouse][hEntrancex], HouseInfo[TotalHouse][hEntrancey], HouseInfo[TotalHouse][hEntrancez],-1);
//pickups++;
HouseInfo[TotalHouse][hMIcon] = CreateDynamicMapIcon(HouseInfo[TotalHouse][hEntrancex], HouseInfo[TotalHouse][hEntrancey], HouseInfo[TotalHouse][hEntrancez], 31, COLOR_WHITE, 0, -1, -1);
SendMes(playerid,COLOR_WHITE,"Âû ñîçäàëè äîì íîìåð: %d. Èñïîëüçóéòå /setcarh (Óêàçàòü ïîçèöèþ àâòî)", TotalHouse);
BuyHouse();
SavePropertys();
return true;
}
PHP код:
forward LoadPropertys();
public LoadPropertys()
{
new time = GetTickCount();
new temp[128],rows,fields;
cache_get_data(rows, fields, MYSQL_ARG);
if(rows)
{
for(new idx = 1; idx <= rows; idx++)
{
cache_get_field_content(idx-1,"hID",temp,MYSQL_ARG), HouseInfo[idx][hID] = strval(temp);
cache_get_field_content(idx-1,"hEntrancex",temp,MYSQL_ARG), HouseInfo[idx][hEntrancex] = floatstr(temp);
cache_get_field_content(idx-1,"hEntrancey",temp,MYSQL_ARG), HouseInfo[idx][hEntrancey] = floatstr(temp);
cache_get_field_content(idx-1,"hEntrancez",temp,MYSQL_ARG), HouseInfo[idx][hEntrancez] = floatstr(temp);
cache_get_field_content(idx-1,"hExitx",temp,MYSQL_ARG), HouseInfo[idx][hExitx] = floatstr(temp);
cache_get_field_content(idx-1,"hExity",temp,MYSQL_ARG), HouseInfo[idx][hExity] = floatstr(temp);
cache_get_field_content(idx-1,"hExitz",temp,MYSQL_ARG), HouseInfo[idx][hExitz] = floatstr(temp);
cache_get_field_content(idx-1,"hOwner",HouseInfo[idx][hOwner],MYSQL_ARG,24);
cache_get_field_content(idx-1,"hValue",temp,MYSQL_ARG), HouseInfo[idx][hValue] = strval(temp);
cache_get_field_content(idx-1,"hHel",temp,MYSQL_ARG), HouseInfo[idx][hHel] = strval(temp);
cache_get_field_content(idx-1,"hInt",temp,MYSQL_ARG), HouseInfo[idx][hInt] = strval(temp);
cache_get_field_content(idx-1,"hLock",temp,MYSQL_ARG), HouseInfo[idx][hLock] = strval(temp);
cache_get_field_content(idx-1,"hOwned",temp,MYSQL_ARG), HouseInfo[idx][hOwned] = strval(temp);
cache_get_field_content(idx-1,"hTakings",temp,MYSQL_ARG), HouseInfo[idx][hTakings] = strval(temp);
cache_get_field_content(idx-1,"hVec",temp,MYSQL_ARG), HouseInfo[idx][hVec] = strval(temp);
cache_get_field_content(idx-1,"hVcol1",temp,MYSQL_ARG), HouseInfo[idx][hVcol1] = strval(temp);
cache_get_field_content(idx-1,"hVcol2",temp,MYSQL_ARG), HouseInfo[idx][hVcol2] = strval(temp);
cache_get_field_content(idx-1,"hKlass",temp,MYSQL_ARG), HouseInfo[idx][hKlass] = strval(temp);
cache_get_field_content(idx-1,"hCarx",temp,MYSQL_ARG), HouseInfo[idx][hCarx] = floatstr(temp);
cache_get_field_content(idx-1,"hCary",temp,MYSQL_ARG), HouseInfo[idx][hCary] = floatstr(temp);
cache_get_field_content(idx-1,"hCarz",temp,MYSQL_ARG), HouseInfo[idx][hCarz] = floatstr(temp);
cache_get_field_content(idx-1,"hCarc",temp,MYSQL_ARG), HouseInfo[idx][hCarc] = floatstr(temp);
if(HouseInfo[idx][hOwned] == 0)
{
HouseInfo[idx][hPickup] = CreatePickup(1273, 23, HouseInfo[idx][hEntrancex], HouseInfo[idx][hEntrancey], HouseInfo[idx][hEntrancez]);
// pickups++;
HouseInfo[idx][hMIcon] = CreateDynamicMapIcon(HouseInfo[idx][hEntrancex], HouseInfo[idx][hEntrancey], HouseInfo[idx][hEntrancez], 31, COLOR_WHITE, 0, -1, -1, 400.0);
}
if(HouseInfo[idx][hOwned] == 1)
{
HouseInfo[idx][hPickup] = CreatePickup(1272, 23, HouseInfo[idx][hEntrancex], HouseInfo[idx][hEntrancey], HouseInfo[idx][hEntrancez]);
// pickups++;
HouseInfo[idx][hMIcon] = CreateDynamicMapIcon(HouseInfo[idx][hEntrancex], HouseInfo[idx][hEntrancey], HouseInfo[idx][hEntrancez], 32, COLOR_WHITE, 0, -1, -1, 400.0);
}
TotalHouse++;
}
}
printf("[Çàãðóæåíî äîìîâ]: <%d>. Âðåìåíè çàòðà÷åíî: <%d ìñ>", TotalHouse, GetTickCount()-time);
return true;
}