- Регистрация
- 18 Апр 2012
- Сообщения
- 468
- Лучшие ответы
- 0
- Репутация
- 135
Здравствуйте. Выкладываю вырезку из своего мода.
Ко всем переменным:
Ко всем forward:
Ко всем define:
В OnGameModeInit:
В OnPlayerPickUpPickup
В OnPlayerKeyStateChange:
В OnDialogResponse:
В конец мода:
В OnGameModeExit:
БД:
Отель называется "Джефферсон", думаю все знают где он.
Ко всем переменным:
PHP:
new HotelPickups[3];
enum mInfo
{
mID,
mOwned,
Float:mX,
Float:mY,
Float:mZ
};
new MotelInfo[12][mInfo];
PHP:
forward LoadHotel();
PHP:
#define D_RENTROOM 110
PHP:
HotelPickups[0] = CreatePickup(19133, 23, 2233.2844, -1159.8071, 25.8906);
HotelPickups[1] = CreatePickup(19133, 23, 2214.3914, -1150.5221, 1025.7969);
HotelPickups[2] = CreatePickup(1239, 23, 2217.3523, -1146.4225, 1025.7969);
mysql_function_query(handle, "SELECT * FROM `hotel`", true, "LoadHotel", "");
PHP:
if(pickupid == HotelPickups[0])
{
SetPlayerPos(playerid, 2215.454833, -1147.475585, 1025.796875);
SetPlayerInterior(playerid, 15);
return true;
}
else if(pickupid == HotelPickups[1])
{
SetPlayerPos(playerid, 2231.7917, -1160.1095, 25.8906);
SetPlayerInterior(playerid, 0);
return true;
}
else if(pickupid == HotelPickups[2])
{
new listitems[256], tmp[32];
for(new i = 0; i < 12; i++)
{
if(MotelInfo[i][mOwned] == 0)
{
if(i != 11)
{
format(tmp, 32, "Свободный номер:\t%d\n", i);
}
else
{
format(tmp, 32, "Свободный номер:\t%d", i);
}
strcat(listitems, tmp);
}
}
ShowPlayerDialog(playerid, 111, DIALOG_STYLE_LIST, "Свободные номера", listitems, "OK", "");
SCM(playerid, CGRAY, "Для снятия комнаты, нажмите ALT у свободного номера.\nСтоимость: 500$, игрокам 1 LvL бесплатно.");
}
PHP:
if(newkeys == KEY_WALK)
{
if(GetPlayerInterior(playerid) == 15)
{
for(new i = 0; i < 12; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, MotelInfo[i][mX], MotelInfo[i][mY], MotelInfo[i][mZ]))
{
if(MotelInfo[i][mOwned] == 0)
{
if(PlayerInfo[playerid][pHotelKey] == -1)
{
ShowPlayerDialog(playerid, D_RENTROOM, DIALOG_STYLE_MSGBOX, "Подтверждение", "{FFFFFF}Вы действительно хотите снять эту комнату?", "Да", "Нет");
SetPVarInt(playerid, "ROOMTORENT", i);
}
else SCM(playerid, CGRAY, "[!] Вы уже снимаете комнату.");
}
else if(i == PlayerInfo[playerid][pHotelKey])
{
SetPlayerPos(playerid, 2350.339843, -1181.649902, 1027.976562);
SetPlayerInterior(playerid, 5);
SetPlayerVirtualWorld(playerid, i + 10);
}
}
}
}
else if(PlayerInfo[playerid][pHotelKey] != -1 && GetPlayerVirtualWorld(playerid) == PlayerInfo[playerid][pHotelKey] + 10 && GetPlayerInterior(playerid) == 5)
{
new id = PlayerInfo[playerid][pHotelKey];
SetPlayerPos(playerid, MotelInfo[id][mX], MotelInfo[id][mY], MotelInfo[id][mZ]);
SetPlayerInterior(playerid, 15);
SetPlayerVirtualWorld(playerid, 0);
}
}
if(newkeys == KEY_NO)
{
if(PlayerInfo[playerid][pHotelKey] != -1 && GetPlayerVirtualWorld(playerid) == PlayerInfo[playerid][pHotelKey] + 15 && GetPlayerInterior(playerid) == 5)
{
new id = PlayerInfo[playerid][pHotelKey];
MotelInfo[id][mOwned] = 0;
SetPlayerPos(playerid, MotelInfo[id][mX], MotelInfo[id][mY], MotelInfo[id][mZ]);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 15);
PlayerInfo[playerid][pHotelKey] = -1;
SCM(playerid, COLOR_YELLOW, "Вы сдали ключи. Вы больше не живёте здесь.");
}
}
PHP:
case D_RENTROOM:
{
if(response)
{
if(PlayerInfo[playerid][pCash] >= 500 && PlayerInfo[playerid][pLevel] != 0 && PlayerInfo[playerid][pHotelKey] == -1)
{
new id = GetPVarInt(playerid, "ROOMTORENT");
PlayerInfo[playerid][pHotelKey] = id;
MotelInfo[id][mOwned] = 1;
SetPlayerPos(playerid, 2350.339843, -1181.649902, 1027.976562);
SetPlayerInterior(playerid, 5);
SetPlayerVirtualWorld(playerid, id + 10);
GiveMoney(playerid, -500);
SCM(playerid, COLOR_YELLOW, "Вы успешно сняли комнату.");
SCM(playerid, COLOR_GRAY, "Для сдачи ключей - нажмите {FF0000}'N'{FFFFFF} в номере.");
}
else if(PlayerInfo[playerid][pLevel] == 1 && PlayerInfo[playerid][pHotelKey] == -1)
{
new id = GetPVarInt(playerid, "ROOMTORENT");
PlayerInfo[playerid][pHotelKey] = id;
MotelInfo[id][mOwned] = 1;
SetPlayerPos(playerid, 2350.339843, -1181.649902, 1027.976562);
SetPlayerInterior(playerid, 5);
SetPlayerVirtualWorld(playerid, id + 10);
SCM(playerid, COLOR_YELLOW, "Вы успешно сняли комнату.");
SCM(playerid, COLOR_GRAY, "Для сдачи ключей - нажмите {FF0000}'N'{FFFFFF} в номере.");
}
else if(PlayerInfo[playerid][pHotelKey] != -1)
{
SCM(playerid, CGRAY, "[!] Вы уже снимаете комнату. Для сдачи ключей - нажмите {FF0000}'N'{FFFFFF} в номере.");
return true;
}
}
}
PHP:
stock SCM(playerid, color, fstring[], {Float, _}:...)
{
static const
STATIC_ARGS = 3;
new
n = (numargs() - STATIC_ARGS) * BYTES_PER_CELL;
if (n)
{
new
message[128],
arg_start,
arg_end;
#emit CONST.alt fstring
#emit LCTRL 5
#emit ADD
#emit STOR.S.pri arg_start
#emit LOAD.S.alt n
#emit ADD
#emit STOR.S.pri arg_end
do
{
#emit LOAD.I
#emit PUSH.pri
arg_end -= BYTES_PER_CELL;
#emit LOAD.S.pri arg_end
}
while (arg_end > arg_start);
#emit PUSH.S fstring
#emit PUSH.C 128
#emit PUSH.ADR message
n += BYTES_PER_CELL * 3;
#emit PUSH.S n
#emit SYSREQ.C format
n += BYTES_PER_CELL;
#emit LCTRL 4
#emit LOAD.S.alt n
#emit ADD
#emit SCTRL 4
return SendClientMessage(playerid, color, message);
}
else return SendClientMessage(playerid, color, fstring);
}
public LoadHotel()
{
new rows, fields, tmpdata[32], i;
cache_get_data(rows, fields);
if(rows)
{
while(i != 12)
{
MotelInfo[i][mID] = i;
cache_get_field_content(i, "owned", tmpdata); MotelInfo[i][mOwned] = strval(tmpdata);
cache_get_field_content(i, "X", tmpdata); MotelInfo[i][mX] = floatstr(tmpdata);
cache_get_field_content(i, "Y", tmpdata); MotelInfo[i][mY] = floatstr(tmpdata);
cache_get_field_content(i, "Z", tmpdata); MotelInfo[i][mZ] = floatstr(tmpdata);
format(tmpdata, 32, "Номер комнаты {FFFFFF}#%d", i);
Create3DTextLabel(tmpdata, COLOR_YELLOW, MotelInfo[i][mX], MotelInfo[i][mY], MotelInfo[i][mZ], 10.0, 0);
i++;
}
}
return true;
}
stock SaveHotel()
{
new query[128];
for(new i = 0; i < 12; i++)
{
mysql_format(handle, query, "UPDATE `hotel` SET `owned` = '%d' WHERE `id` = '%d'", MotelInfo[i][mOwned], i);
mysql_function_query(handle, query, false, "", "");
}
return true;
}
PHP:
SaveHotel();
PHP:
CREATE TABLE IF NOT EXISTS `hotel` (
`id` int(11) NOT NULL,
`owned` int(11) NOT NULL,
`X` float NOT NULL,
`Y` float NOT NULL,
`Z` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `hotel` (`id`, `owned`, `X`, `Y`, `Z`) VALUES
(0, 0, 2239.87, -1159.81, 1029.8),
(1, 0, 2242.45, -1159.86, 1029.8),
(2, 0, 2242.52, -1170.74, 1029.8),
(3, 0, 2239.83, -1170.69, 1029.8),
(4, 0, 2225.63, -1189.96, 1029.8),
(5, 0, 2225.68, -1187.31, 1029.8),
(6, 0, 2209.61, -1187.38, 1029.8),
(7, 0, 2209.66, -1190.13, 1029.8),
(8, 0, 2191.89, -1172.96, 1029.8),
(9, 0, 2194.59, -1173.14, 1029.8),
(10, 0, 2191.91, -1156.99, 1029.8),
(11, 0, 2194.56, -1157.1, 1029.8);
Последнее редактирование: