Сообщение от
vasyok28
Привет! Кидай загрузку домов, и действие при нахождение на дин. Зоне
Загрузка домов:
Код:
publics: HouseLoading()
{
new rows, fields;
cache_get_data(rows,fields,MYSQL_CONNECT);
if(rows)
{
for(new i = 1; i <= rows; i++)
{
House[i][ID] = cache_get_field_content_int(i-1, "ID", MYSQL_CONNECT);
House[i][Owned] = cache_get_field_content_int(i-1, "Owned", MYSQL_CONNECT);
cache_get_field_content(i-1, "Owner", House[i][Owner], MYSQL_CONNECT, 24);
House[i][HEnter][0] = cache_get_field_content_float(i-1, "PosX", MYSQL_CONNECT);
House[i][HEnter][1] = cache_get_field_content_float(i-1, "PosY", MYSQL_CONNECT);
House[i][HEnter][2] = cache_get_field_content_float(i-1, "PosZ", MYSQL_CONNECT);
House[i][Price] = cache_get_field_content_int(i-1, "Price", MYSQL_CONNECT);
House[i][Class] = cache_get_field_content_int(i-1, "Class", MYSQL_CONNECT);
House[i][Lock] = cache_get_field_content_int(i-1, "Lock", MYSQL_CONNECT);
TOTAL_HOUSE++;
if(!House[i][Owned])
{
House[i][EnterPickup] = CreatePickup(1273, 23, House[i][HEnter][0], House[i][HEnter][1], House[i][HEnter][2],-1);
House[i][MapIcons] = CreateDynamicMapIcon(House[i][HEnter][0], House[i][HEnter][1], House[i][HEnter][2], 31, CWHITE, 0, -1, -1, 200.0);
}
else
{
House[i][EnterPickup] = CreatePickup(19522, 23, House[i][HEnter][0], House[i][HEnter][1], House[i][HEnter][2],-1);
House[i][MapIcons] = CreateDynamicMapIcon(House[i][HEnter][0], House[i][HEnter][1], House[i][HEnter][2], 32, CWHITE, 0, -1, -1, 100.0);
}
House[i][Area] = CreateDynamicSphere(House[i][HEnter][0],House[i][HEnter][1],House[i][HEnter][2],1.0,0,0,-1);
}
}
printf("[Система домов]: %i домов было загружено.", TOTAL_HOUSE);
return true;
}
Действие, когда игрок входит в зону.
Код:
public OnPlayerEnterDynamicArea(playerid, areaid)
{
if(areaid >= House[1][Area] && areaid <= House[TOTAL_HOUSE][Area])
{
new house_class[15], mes[128];
new houseid = areaid - House[1][Area]+1;
if(houseid == -1) return true;
switch(House[houseid][Class])
{
case 1: house_class = "Ýêîíîì";
case 2: house_class = "Ñðåäíèé";
case 3: house_class = "Ëþêñ";
}
if(!House[houseid][Owned])
{
f(mes, "Íîìåð äîìà: %i\nÄîì ïðîäà¸òñÿ!\n\nÊëàññ: %s\nÑòîèìîñòü: %i$", houseid, house_class, House[houseid][Price]);
ShowPlayerDialog(playerid, dBuyHouse,DIALOG_STYLE_MSGBOX,"Äîì ñâîáîäåí",mes,"Êóïèòü","Îòìåíà");
}
else
{
f(mes, "Íîìåð äîìà: %i\n\nÂëàäåëåö: %s\n\nÊëàññ: %s", houseid, House[houseid][Owner], house_class);
ShowPlayerDialog(playerid, dHouseEnter,DIALOG_STYLE_MSGBOX,"Äîì çàíÿò",mes,"Âîéòè","Îòìåíà");
}
PlayerInfo[playerid][SelectedHouseID] = houseid;
}
return 1;
}