| Описание:
- MySQL. - Доступно создание дома через игру. Список интерьеров будет показан в диалоговом окне, вам останется только выбрать на свой вкус. Добавить новый интерьер - 1 строка. - Параметры дома: Владелец, цена, иконка на карте ( в зависимости от статуса дома, купленный - красная, продается - зеленая ), пикап входа в дом ( в зависимости от статуса ), пикап выхода из дома, виртуальный мир дома, интерьер, ключ ( закрыт / открыт | функция временно недоступна ). - Спавн в доме. - Автоматическое обновление статуса ( При покупке/продаже дома изменяется иконка, пикап ). - Продажа дома для хозяина. ( /sellhouse ) - Теперь доступно создание дома через игру. Список интерьеров будет показан в диалоговом окне, вам останется только выбрать на свой вкус. Добавить новый интерьер - 1 строка. ( Создание дома - /createhouse, для администраторов RCON ) - 3D текст информации о доме, диалоговые окна в зависимости от статуса. - Баги найдены не были. - ФС работает независимо от мода, подойдет к любому.
Скрипт: Code // by Exclusive | Skype: excl-usive | Распространение скрипта без указания автора ЗАПРЕЩЕНО.
/* Запрос | Query
CREATE TABLE IF NOT EXISTS `ExclusiveHouses` ( `hID` int(11) NOT NULL AUTO_INCREMENT, `EnterX` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0', `EnterY` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0', `EnterZ` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0', `ExitX` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0', `ExitY` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0', `ExitZ` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '0.0', `hOwner` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT 'None', `hPrice` int(11) NOT NULL DEFAULT '200000', `hInt` int(11) NOT NULL DEFAULT '0', `hVW` int(11) NOT NULL DEFAULT '0', `hLock` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`hID`) ) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=1;
*/
#include a_samp #include a_mysql
#define MAX_HOUSES 250 #define DIALOG_HOUSE 540
native sscanf(const data[], const format[], {Float,_}:...);
enum hInfo { hID, Float: EnterX, Float: EnterY, Float: EnterZ, Float: ExitX, Float: ExitY, Float: ExitZ, hOwner[32], hPrice, hInt, hVW, hLock, Text3D:hLabel, hMapIcon, hPickup };
enum iInfo { iInt, iName [ 70 ], Float: iX, Float: iY, Float: iZ };
new
Query [ 350 ], strin [ 128 ], HouseInfo [ MAX_HOUSES ][ hInfo ], TOTAL_HOUSES, Interiors[ 11 ][ iInfo ]={ { 1, "Небольшая спальня [ • ]", 243.7176,304.9697,999.1484 }, { 3, "Дом Johnson'а [ • • • ]", 2495.9456,-1692.0854,1014.7422 }, { 10,"Заброшенная башня [ • ]", 422.5720,2536.4568,10.0000 }, { 5,"Светлая квартира со спальней [ • • ]", 2233.6184,-1115.2618,1050.8828 }, { 9,"Двухэтажный дом с зеркальными полами [ • • • ]", 2317.7410,-1026.7661,1050.2178 }, { 10,"Одна из комнат отеля Jefferson [ • ]", 2259.3816,-1135.8962,1050.6403 }, { 3,"Двухэтажный пятикомнатный дом [ • • • ]", 235.2910,1186.6793,1080.2578 }, { 1,"Небольшая четырехкомнатная квартира [ • • ]", 223.1530,1287.0830,1082.1406 }, { 5,"Двухэтажный семикомнатный дом [ • • • ]", 226.2990,1114.3126,1080.9929 }, { 2,"Пятикомнатная квартирка [ • • ]", 447.0905,1397.0645,1084.3047 }, { 10,"Двухэтажная светлая квартирка [ • • ]", 23.9724,1340.1591,1084.3750 } }
;
public OnFilterScriptInit ( ) mysql_connect( "localhost" , "root", "SAMP", "" ), LoadMySQLHouses();
public OnPlayerSpawn ( playerid ) { for( new i = 0; i < sizeof( HouseInfo ); i++ ) { if(!strcmp( HouseInfo[ i ][ hOwner ], "None", true ) ) HouseInfo[ i ][ hMapIcon ] = SetPlayerMapIcon( playerid, i, HouseInfo[ i ][ EnterX ],HouseInfo[ i ][ EnterY ],HouseInfo[ i ][ EnterZ ], 31, -1 ); else HouseInfo[ i ][ hMapIcon ] = SetPlayerMapIcon( playerid, i, HouseInfo[ i ][ EnterX ],HouseInfo[ i ][ EnterY ],HouseInfo[ i ][ EnterZ ], 32, -1 ); } if( IsPlayerHouseOwner( playerid ) ) { SetPlayerInterior( playerid, HouseInfo[ IsPlayerHouseOwner ( playerid ) ][ hInt ] ), SetPlayerVirtualWorld(playerid, HouseInfo[ IsPlayerHouseOwner ( playerid ) ][ hVW ] ); SetPlayerPos( playerid, HouseInfo[ IsPlayerHouseOwner ( playerid ) ][ ExitX ], HouseInfo[ IsPlayerHouseOwner ( playerid ) ][ ExitY ] - 3.0, HouseInfo[ IsPlayerHouseOwner ( playerid ) ][ ExitZ ]); SetPVarInt( playerid, "HouseEnter", IsPlayerHouseOwner ( playerid ) ); } }
public OnPlayerPickUpPickup(playerid, pickupid) { for( new i = 0; i < sizeof( HouseInfo ); i++ ) { if(IsPlayerInRangeOfPoint( playerid, 1.0, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ) ) { if(!strcmp( HouseInfo[ i ][ hOwner ], "None", true ) ) format(strin,128,"{FFFFFF}Дом продается.\nВы можете его купить.\nЦена: %i.", HouseInfo [ i ] [ hPrice ] ), ShowPlayerDialog( playerid, DIALOG_HOUSE, DIALOG_STYLE_MSGBOX, "{FFFFFF}Недвижимость", strin, "Купить", "Отмена" ); else format(strin,128,"{FFFFFF}Владелец дома: %s.", HouseInfo [ i ] [ hOwner ] ), ShowPlayerDialog( playerid, DIALOG_HOUSE, DIALOG_STYLE_MSGBOX, "{FFFFFF}Недвижимость", strin, "Зайти", "Отмена" ); } else if(IsPlayerInRangeOfPoint( playerid, 1.0, HouseInfo[ i ][ ExitX ], HouseInfo[ i ][ ExitY ], HouseInfo[ i ][ ExitZ ] ) && GetPVarInt( playerid, "HouseEnter" ) == i ) SetPVarInt( playerid, "HouseEnter", 255 ), SetPlayerInterior( playerid, 0 ), SetPlayerPos( playerid, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ), SetPlayerVirtualWorld( playerid, 0 ); } }
LoadMySQLHouses ( ) { mysql_query("SELECT * FROM `ExclusiveHouses` ORDER BY `ExclusiveHouses`.`hID` ASC"); mysql_store_result(); for(new i; i < TOTAL_HOUSES; i++) strmid( HouseInfo[ i ][ hOwner ], "None", 0, strlen("None"), 24); if(mysql_num_rows() > 0) { for(new h = 1; h <= mysql_num_rows(); h++) { mysql_fetch_row(Query); sscanf(Query, "p<|>iffffffs[24]iiii",HouseInfo[ h ][ hID ],HouseInfo[ h ][ EnterX ],HouseInfo[ h ][ EnterY ],HouseInfo[ h ][ EnterZ ],HouseInfo[ h ][ ExitX ],HouseInfo[ h ][ ExitY ],HouseInfo[ h ][ ExitZ ],HouseInfo[ h ][ hOwner ],HouseInfo[ h ][ hPrice ],HouseInfo[ h ][ hInt ],HouseInfo[ h ][ hVW ],HouseInfo[ h ][ hLock ] ); if(!strcmp( HouseInfo[ h ][ hOwner ], "None", true ) ) { HouseInfo[ h ][ hPickup ] = CreatePickup(1273, 1, HouseInfo[ h ][ EnterX ], HouseInfo[ h ][ EnterY ], HouseInfo[ h ][ EnterZ ] ); format(strin,sizeof(strin),"Номер дома: %i.\nДом выставлен на продажу!\nЦена: %i.", h, HouseInfo[ h ][ hPrice ]); } else { HouseInfo[ h ][ hPickup ] = CreatePickup(1318, 1, HouseInfo[ h ][ EnterX ], HouseInfo[ h ][ EnterY ], HouseInfo[ h ][ EnterZ ] ); format(strin,sizeof(strin),"Номер дома: %i.\nВладелец дома: %s.", h, HouseInfo[ h ][ hOwner ]); } CreatePickup(19134, 1, HouseInfo[ h ][ ExitX ], HouseInfo[ h ][ ExitY ], HouseInfo[ h ][ ExitZ ], HouseInfo [ h ] [ hVW ] ); HouseInfo[ h ][ hLabel ] = Create3DTextLabel(strin, 0xC4DAADFF, HouseInfo[ h ][ EnterX ],HouseInfo[ h ][ EnterY ],HouseInfo[ h ][ EnterZ ], 15.0,0,1); ++ TOTAL_HOUSES; } } mysql_free_result(), printf("[ Система домов ]: Загружено %i домов.", TOTAL_HOUSES); }
PlayerName( playerid ) { new pName [ 24 ]; GetPlayerName( playerid, pName, sizeof pName ); return pName; }
UpdateHouseInfo( i ) { for( new b; b < MAX_PLAYERS; b++ ) RemovePlayerMapIcon( b, HouseInfo[ i ][ hMapIcon ] ); DestroyPickup( HouseInfo[ i ][ hPickup ]); if(!strcmp(HouseInfo[ i ][ hOwner ],"None",true)) { for( new c; c < MAX_PLAYERS; c++ ) HouseInfo[ i ][ hMapIcon ] = SetPlayerMapIcon( c, i, HouseInfo[ i ][ EnterX ],HouseInfo[ i ][ EnterY ],HouseInfo[ i ][ EnterZ ], 31, -1 ); HouseInfo[ i ][ hPickup ] = CreatePickup(1273, 1, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ); format( strin, 128,"Номер дома: %i.\nДом выставлен на продажу!\nЦена: %i.", i, HouseInfo[ i ][ hPrice ]); } else { for( new c; c < MAX_PLAYERS; c++ ) HouseInfo[ i ][ hMapIcon ] = SetPlayerMapIcon( c, i, HouseInfo[ i ][ EnterX ],HouseInfo[ i ][ EnterY ],HouseInfo[ i ][ EnterZ ], 32, -1 ); HouseInfo[ i ][ hPickup ] = CreatePickup(1318, 1, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ); format( strin, 128,"Номер дома: %i.\nВладелец дома: %s.", i, HouseInfo[ i ][ hOwner ]); } return Update3DTextLabelText( HouseInfo[ i ][ hLabel ], -1, strin); }
public OnPlayerCommandText( playerid, cmdtext[] ) { if(strcmp("/sellhouse", cmdtext, true) == 0) { for( new i = 0; i < sizeof( HouseInfo ); i++ ) { if(IsPlayerInRangeOfPoint( playerid, 1.0, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ) ) { if(!IsPlayerHouseOwner( playerid ) ) SendClientMessage( playerid, -1, "Вы не владелец дома." ); format( Query, sizeof( Query ), "UPDATE ExclusiveHouses SET hOwner = 'None' WHERE hID = '%d' LIMIT 1", i ); mysql_query( Query ), strmid( HouseInfo[ i ][ hOwner ], "None", 0, strlen( "None" ), 24); GivePlayerMoney( playerid, HouseInfo[ i ][ hPrice ] - 10000 ), SetPlayerPos( playerid, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ), SetPlayerInterior( playerid, 0 ), SetPlayerVirtualWorld( playerid, 0 ); return UpdateHouseInfo ( i ); } } } if(strcmp("/createhouse", cmdtext, true) == 0) { if( IsPlayerAdmin ( playerid ) ) ShowPlayerDialog( playerid, DIALOG_HOUSE + 1, DIALOG_STYLE_INPUT, "{FFFFFF}Создание дома", "{FFFFFF}Введите цену дома", "<<<", "Выход" ); } return true; }
IsPlayerHouseOwner(playerid) { format( Query, sizeof(Query) , "SELECT * FROM ExclusiveHouses WHERE hOwner = '%s'", PlayerName(playerid) ); mysql_query( Query ); mysql_store_result(); if(mysql_num_rows()) return true; return false; }
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[] ) { new Float: Pos [ 4 ], str [ 400 ] ; switch( dialogid ) { case DIALOG_HOUSE: { if( response ) { for( new i = 0; i < sizeof( HouseInfo ); i++ ) { if(IsPlayerInRangeOfPoint( playerid, 1.0, HouseInfo[ i ][ EnterX ], HouseInfo[ i ][ EnterY ], HouseInfo[ i ][ EnterZ ] ) ) { if(!strcmp( HouseInfo[ i ][ hOwner ], "None", true ) ) { if( GetPlayerMoney ( playerid ) < HouseInfo[ i ][ hPrice ]) return SendClientMessage( playerid, -1, "У вас нет денег для покупки данной недвижимости!" ); format( Query, sizeof( Query ), "UPDATE ExclusiveHouses SET hOwner = '%s' WHERE hID = '%d' LIMIT 1", PlayerName ( playerid ), i ); mysql_query( Query ), strmid( HouseInfo[ i ][ hOwner ], PlayerName( playerid ), 0, strlen( PlayerName( playerid ) ), 24); GivePlayerMoney( playerid, - HouseInfo[ i ][ hPrice ] ), SetPlayerPos( playerid, HouseInfo[ i ][ ExitX ], HouseInfo[ i ][ ExitY ] - 3.0, HouseInfo[ i ][ ExitZ ] ), SetPlayerInterior( playerid, HouseInfo[ i ][ hInt ] ), SetPlayerVirtualWorld( playerid, HouseInfo[ i ][ hVW ] ), SetPVarInt( playerid, "HouseEnter", i ); return UpdateHouseInfo ( i ); } else SetPVarInt( playerid, "HouseEnter", i ), SetPlayerPos( playerid, HouseInfo[ i ][ ExitX ], HouseInfo[ i ][ ExitY ]-3.0, HouseInfo[ i ][ ExitZ ] ), SetPlayerInterior( playerid, HouseInfo[ i ][ hInt ] ), SetPlayerVirtualWorld( playerid, HouseInfo[ i ][ hVW ]); } } } } case DIALOG_HOUSE + 1: { if( response ) { SetPVarInt( playerid, "HousePrice", strval ( inputtext ) ); for(new x = 0; x < sizeof ( Interiors ); x++) { strcat( str, Interiors[ x ][ iName ] ), strcat( str,"\n" ); ShowPlayerDialog(playerid, DIALOG_HOUSE + 2 , DIALOG_STYLE_LIST, "{FFFFFF}Выберите интерьер дома", str, "Готово", "Выход"); } } } case DIALOG_HOUSE + 2: { if( response ) { ++ TOTAL_HOUSES, GetPlayerPos ( playerid, Pos [ 0 ], Pos [ 1 ], Pos [ 2 ] ); HouseInfo[ TOTAL_HOUSES ][ hInt ] = Interiors[ listitem ] [ iInt ], HouseInfo[ TOTAL_HOUSES ][ EnterX ] = Pos [ 0 ], HouseInfo[ TOTAL_HOUSES ] [ EnterY ] = Pos [ 1 ], HouseInfo[ TOTAL_HOUSES ] [ EnterZ ] = Pos [ 2 ]; HouseInfo[ TOTAL_HOUSES ][ ExitX ] = Interiors[ listitem ][ iX ], HouseInfo[ TOTAL_HOUSES ] [ ExitY ] = Interiors[ listitem ][ iY ], HouseInfo[ TOTAL_HOUSES ] [ ExitZ ] = Interiors[ listitem ][ iZ ]; HouseInfo[ TOTAL_HOUSES ][ hPrice ] = GetPVarInt( playerid, "HousePrice" ); HouseInfo[ TOTAL_HOUSES ][ hPickup ] = CreatePickup(1273, 1, HouseInfo[ TOTAL_HOUSES ][ EnterX ], HouseInfo[ TOTAL_HOUSES ][ EnterY ], HouseInfo[ TOTAL_HOUSES ][ EnterZ ] ); format(strin,sizeof(strin),"Номер дома: %i.\nДом выставлен на продажу!\nЦена: %i.", TOTAL_HOUSES, HouseInfo[ TOTAL_HOUSES ][ hPrice ]); CreatePickup(19134, 1, HouseInfo[ TOTAL_HOUSES ][ ExitX ], HouseInfo[ TOTAL_HOUSES ][ ExitY ], HouseInfo[ TOTAL_HOUSES ][ ExitZ ] ); HouseInfo[ TOTAL_HOUSES ][ hLabel ] = Create3DTextLabel(strin, 0xC4DAADFF, HouseInfo[ TOTAL_HOUSES ][ EnterX ], HouseInfo[ TOTAL_HOUSES ][ EnterY ], HouseInfo[ TOTAL_HOUSES ][ EnterZ ], 15.0,0,1); format(Query,sizeof(Query),"INSERT INTO `ExclusiveHouses` (hID,EnterX,EnterY,EnterZ,ExitX,ExitY,ExitZ,hOwner,hPrice,hInt,hVW,hLock) VALUES ('%d','%f','%f','%f','%f','%f','%f','None','%d','%d','%d',0)",TOTAL_HOUSES, HouseInfo[ TOTAL_HOUSES ][ EnterX ], HouseInfo[ TOTAL_HOUSES ][ EnterY ], HouseInfo[ TOTAL_HOUSES ][ EnterZ ], HouseInfo[ TOTAL_HOUSES ][ ExitX ], HouseInfo[ TOTAL_HOUSES ][ ExitY ], HouseInfo[ TOTAL_HOUSES ][ ExitZ ], HouseInfo[ TOTAL_HOUSES ][ hPrice ], HouseInfo[ TOTAL_HOUSES ][ hInt ], TOTAL_HOUSES ); mysql_query(Query); } } } return true; }
|
Kostyan9041