move command to /estate for now

This commit is contained in:
Lorenc Pekaj 2018-09-25 12:42:20 +10:00
parent 2bb7604548
commit 57a1db8cd8
4 changed files with 71 additions and 64 deletions

View File

@ -490,7 +490,10 @@ hook OnPlayerSelectDynObject( playerid, objectid, modelid, Float:x, Float:y, Flo
hook OnHouseOwnerChange( houseid, owner )
{
if ( owner != 0 ) // transfer furniture only to valid owner
{
mysql_single_query( sprintf( "UPDATE `FURNITURE` SET `OWNER`=%d WHERE `HOUSE_ID`=%d", owner, houseid ) );
}
return 1;
}

View File

@ -398,9 +398,8 @@ CMD:h( playerid, params[ ] )
}
new
ID = p_InHouse[ playerid ],
query[ 140 ]
;
ID = p_InHouse[ playerid ];
if ( strmatch( params, "spawn" ) )
{
SendServerMessage( playerid, "We have changed the command to simply "COL_GREY"/spawn"COL_WHITE"." );
@ -463,30 +462,10 @@ CMD:h( playerid, params[ ] )
format( szBigString, sizeof( szBigString ), "[SELL] [%s] %s | %s | %d\r\n", getCurrentDate( ), ReturnPlayerName( playerid ), g_houseData[ ID ][ E_OWNER ], ID );
AddFileLogLine( "log_houses.txt", szBigString );
p_OwnedHouses[ playerid ] --;
format( g_houseData[ ID ] [ E_PASSWORD ], 4, "N/A" );
format( g_houseData[ ID ] [ E_OWNER ], 7, "No-one" );
format( g_houseData[ ID ] [ E_HOUSE_NAME ], 5, "Home" );
for( new i; i < MAX_HOUSE_WEAPONS; i++ ) { g_HouseWeapons[ ID ] [ i ] = 0, g_HouseWeaponAmmo[ ID ] [ i ] = -1; }
SaveHouseWeaponStorage( ID );
SetHouseForAuction( ID );
GivePlayerCash( playerid, ( g_houseData[ ID ] [ E_COST ] / 2 ) );
destroyAllFurniture( ID );
FillHomeWithFurniture( ID, 0 );
g_houseData[ ID ] [ E_TX ] = g_houseInteriors[ 0 ] [ E_EX ];
g_houseData[ ID ] [ E_TY ] = g_houseInteriors[ 0 ] [ E_EY ];
g_houseData[ ID ] [ E_TZ ] = g_houseInteriors[ 0 ] [ E_EZ ];
g_houseData[ ID ] [ E_INTERIOR_ID ] = 2;
format( query, sizeof( query ), "UPDATE HOUSES SET OWNER='No-one',PASSWORD='N/A',NAME='Home',TX=%f,TY=%f,TZ=%f,INTERIOR=%d WHERE ID=%d", g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], g_houseData[ ID ] [ E_INTERIOR_ID ], ID );
mysql_single_query( query );
format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" Home(%d)\n"COL_GOLD"Owner:"COL_WHITE" No-one\n"COL_GOLD"Price:"COL_WHITE" %s", ID, cash_format( g_houseData[ ID ] [ E_COST ] ) );
UpdateDynamic3DTextLabelText( g_houseData[ ID ] [ E_LABEL ] [ 0 ], COLOR_WHITE, szBigString );
DestroyDynamic3DTextLabel( g_houseData[ ID ] [ E_LABEL ] [ 1 ] );
g_houseData[ ID ] [ E_LABEL ] [ 1 ] = CreateDynamic3DTextLabel( "[EXIT]", COLOR_GOLD, g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, g_houseData[ ID ] [ E_WORLD ] );
DestroyDynamicCP( g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] );
g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] = CreateDynamicCP( g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 1.0, g_houseData[ ID ] [ E_WORLD ], g_houseData[ ID ] [ E_INTERIOR_ID ], -1, 50.0 );
SetPlayerPos( playerid, g_houseData[ ID ] [ E_EX ], g_houseData[ ID ] [ E_EY ], g_houseData[ ID ] [ E_EZ ] );
DestroyDynamicMapIcon( g_houseData[ ID ] [ E_MAP_ICON ] );
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
SetPlayerInterior( playerid, 0 ), SetPlayerVirtualWorld( playerid, 0 );
SendServerMessage( playerid, "You have successfully sold your house for "COL_GOLD"%s", cash_format( ( g_houseData[ ID ] [ E_COST ] / 2 ) ) );
}
return 1;
@ -735,7 +714,9 @@ stock SetHouseForAuction( ID )
SendClientMessage( player, -1, ""COL_PINK"[HOUSE]"COL_WHITE" One of your houses has been taken for auction.");
p_OwnedHouses[ player ] --;
}
CallLocalFunction( "OnHouseOwnerChange", "dd", ID, 0 );
for( new i; i < MAX_HOUSE_WEAPONS; i++ ) { g_HouseWeapons[ ID ] [ i ] = 0, g_HouseWeaponAmmo[ ID ] [ i ] = -1; }
SaveHouseWeaponStorage( ID );
format( g_houseData[ ID ] [ E_PASSWORD ], 4, "N/A" );
format( g_houseData[ ID ] [ E_OWNER ], 7, "No-one" );
format( g_houseData[ ID ] [ E_HOUSE_NAME ], 5, "Home" );

View File

@ -21,11 +21,11 @@
/* ** Constants ** */
static const
HOUSE_LISTING_FEE = 50000;
HOUSE_LISTING_FEE = 75000;
/* ** Variables ** */
static stock
p_CurrentListings [ MAX_PLAYERS ] [ 20 ];
p_CurrentListings [ MAX_PLAYERS ] [ 50 ]; // TODO: add pagination
/* ** Hooks ** */
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
@ -79,14 +79,12 @@ hook OnHouseOwnerChange( houseid, owner )
}
/* ** Commands ** */
hook cmd_h( playerid, params[ ] )
CMD:realestate( playerid, params[ ] ) return cmd_estate( playerid, params );
CMD:estate( playerid, params[ ] )
{
new
houseid = p_InHouse[ playerid ];
if ( strmatch( params, "listings" ) ) {
return ShowPlayerHomeListings( playerid ), Y_HOOKS_BREAK_RETURN_1;
}
if ( strmatch( params, "list cancel" ) )
{
if ( ! Iter_Contains( houses, houseid ) ) return SendError( playerid, "You are not inside of any home." );
@ -94,27 +92,30 @@ hook cmd_h( playerid, params[ ] )
{
mysql_tquery( dbHandle, sprintf( "DELETE FROM `HOUSE_LISTINGS` WHERE `HOUSE_ID` = %d AND `SALE_DATE` IS NULL", houseid ), "HouseListing_OnDeleteListing", "dd", playerid, houseid );
}
return Y_HOOKS_BREAK_RETURN_1;
return 1;
}
else if ( !strcmp( params, "list", false, 4 ) )
{
new
Float: coins;
if ( sscanf( params[ 5 ], "f", coins ) ) return SendUsage( playerid, "/h list [ASK_PRICE (IC)]");
if ( sscanf( params[ 5 ], "f", coins ) ) return SendUsage( playerid, "/estate list [IC_ASK_PRICE/CANCEL]");
else if ( ! Iter_Contains( houses, houseid ) ) return SendError( playerid, "You are not inside of any home." );
else if ( g_houseData[ houseid ] [ E_COST ] > 2500 ) return SendError( playerid, "This home is not a V.I.P home." );
else if ( ! IsPlayerHomeOwner( playerid, houseid ) ) return SendError( playerid, "You are not the owner of this home." );
else if ( coins < 25.0 ) return SendError( playerid, "Please specify an ask price greater than 25.00 IC." );
else if ( coins > 25000.0 ) return SendError( playerid, "Please specify an ask price less than 25,000 IC." );
else if ( GetPlayerCash( playerid ) < HOUSE_LISTING_FEE && GetPlayerVIPLevel( playerid ) != VIP_GOLD ) return SendError( playerid, "You need at least %s to create a house listing.", cash_format( HOUSE_LISTING_FEE ) );
else if ( GetPlayerCash( playerid ) < HOUSE_LISTING_FEE && GetPlayerVIPLevel( playerid ) < VIP_GOLD ) return SendError( playerid, "You need at least %s to create a house listing.", cash_format( HOUSE_LISTING_FEE ) );
else
{
mysql_tquery( dbHandle, sprintf( "SELECT * FROM `HOUSE_LISTINGS` WHERE `HOUSE_ID` = %d AND `SALE_DATE` IS NULL", houseid ), "HouseListing_OnCreateListing", "ddf", playerid, houseid, coins );
}
return Y_HOOKS_BREAK_RETURN_1;
}
return 1;
}
else
{
return ShowPlayerHomeListings( playerid );
}
}
/* ** SQL Threads ** */
@ -127,7 +128,7 @@ thread HouseListing_OnShowHomes( playerid )
{
static
location[ MAX_ZONE_NAME ],
city[ MAX_ZONE_NAME ],
city[ 3 ],
house_name[ 32 ],
owner[ 24 ];
@ -146,19 +147,21 @@ thread HouseListing_OnShowHomes( playerid )
new houseid = cache_get_field_content_int( row, "HOUSE_ID" );
Get2DCity( city, g_houseData[ houseid ] [ E_EX ], g_houseData[ houseid ] [ E_EX ] );
GetZoneFromCoordinates( location, g_houseData[ houseid ] [ E_EX ], g_houseData[ houseid ] [ E_EX ] );
Get2DCityShort( city, g_houseData[ houseid ] [ E_EX ], g_houseData[ houseid ] [ E_EY ] );
GetZoneFromCoordinates( location, g_houseData[ houseid ] [ E_EX ], g_houseData[ houseid ] [ E_EY ], .placeholder = "Island" );
new Float: coins = cache_get_field_content_float( row, "ASK" );
format( szLargeString, sizeof( szLargeString ), "%s%s\t%s\t%s, %s\t"COL_GREEN"%s IC\n", szLargeString, house_name, owner, city, location, number_format( coins, .decimals = 2 ) );
format( szLargeString, sizeof( szLargeString ), "%s%s\t%s\t%s, %s\t"COL_GREEN"%s IC\n", szLargeString, house_name, owner, location, city, number_format( coins, .decimals = 2 ) );
}
else
{
p_CurrentListings[ playerid ] [ row ] = -1;
}
}
return ShowPlayerDialog( playerid, DIALOG_HOUSE_LISTINGS, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}House Real Estate", szLargeString, "Select", "Back" );
SendServerMessage( playerid, "You can list your own home using "COL_GREY"/estate list"COL_WHITE" for %s (or free if you're GOLD V.I.P).", cash_format( HOUSE_LISTING_FEE ) );
return ShowPlayerDialog( playerid, DIALOG_HOUSE_LISTINGS, DIALOG_STYLE_TABLIST_HEADERS, ""COL_GOLD"Irresistible Coin - "COL_WHITE"Premium Home Estate", szLargeString, "Select", "Back" );
}
else
{
@ -181,7 +184,7 @@ thread HouseListing_OnShowHome( playerid, house_listing_id )
return ShowPlayerDialog(
playerid, DIALOG_HOUSE_LIST_VIEW, DIALOG_STYLE_TABLIST,
"{FFFFFF}House Real Estate",
""COL_GOLD"Irresistible Coin - "COL_WHITE"Premium Home Estate",
sprintf( "Purchase Home\t"COL_GREEN"%s IC\nSet GPS Waypoint\t"COL_GREY">>>", number_format( coins, .decimals = 2 ) ),
"Select", "Back"
);
@ -205,7 +208,7 @@ thread HouseListing_OnBuyHome( playerid, house_listing_id )
// does the dude even have the coins
if ( GetPlayerIrresistibleCoins( playerid ) < ask_price ) {
ShowPlayerHomeListing( playerid, house_listing_id );
return SendError( playerid, "You do not have enough Irresistible coins for this home (%s IC).", number_format( ask_price, .decimals = 2 ) );
return SendError( playerid, "You do not have enough Irresistible Coins for this home (%s IC).", number_format( ask_price, .decimals = 2 ) );
}
// check if sale already completed
@ -216,9 +219,17 @@ thread HouseListing_OnBuyHome( playerid, house_listing_id )
return SendError( playerid, "You can no longer buy this home as it has been sold." );
}
// check if buyer is the player himself
new
owner_account_id = cache_get_field_content_int( 0, "USER_ID" );
if ( GetPlayerAccountID( playerid ) == owner_account_id ) {
ShowPlayerHomeListing( playerid, house_listing_id );
return SendError( playerid, "You cannot buy your own home." );
}
// credit seller if they are on/offline
new
owner_account_id = cache_get_field_content_int( 0, "USER_ID" ),
sellerid;
foreach ( sellerid : Player ) if ( GetPlayerAccountID( sellerid ) == owner_account_id ) {
@ -260,17 +271,17 @@ thread HouseListing_OnCreateListing( playerid, houseid, Float: ask_price )
if ( ! rows )
{
// debit user account
if ( GetPlayerVIPLevel( playerid ) != VIP_GOLD ) {
if ( GetPlayerVIPLevel( playerid ) < VIP_GOLD ) {
GivePlayerCash( playerid, -HOUSE_LISTING_FEE );
}
// insert into database and notify
mysql_single_query( sprintf( "INSERT INTO `HOUSE_LISTINGS` (`HOUSE_ID`, `USER_ID`, `ASK`) VALUES (%d, %d, %f)", houseid, GetPlayerAccountID( playerid ), ask_price ) );
return SendServerMessage( playerid, "You have listed your home. You can retract your listing using "COL_GREY"/h list cancel"COL_WHITE"." );
return SendServerMessage( playerid, "You have listed your home. You can retract your listing using "COL_GREY"/estate list cancel"COL_WHITE"." );
}
else
{
return SendError( playerid, "This home is already listed. You can retract your listing using "COL_GREY"/h list cancel"COL_WHITE"." );
return SendError( playerid, "This home is already listed. You can retract your listing using "COL_GREY"/estate list cancel"COL_WHITE"." );
}
}
@ -281,7 +292,7 @@ thread HouseListing_OnDeleteListing( playerid, houseid )
if ( deleted_rows )
{
return SendServerMessage( playerid, "You have delisted your home. You can create a new listing using "COL_GREY"/h list"COL_WHITE"." );
return SendServerMessage( playerid, "You have delisted your home. You can create a new listing using "COL_GREY"/estate list"COL_WHITE"." );
}
else
{
@ -297,8 +308,8 @@ thread HouseListing_OnDeleteListing( playerid, houseid )
HOUSE_ID int(11),
USER_ID int(11),
ASK float,
LISTING_DATE DATETIME default CURRENT_TIMESTAMP,
SALE_DATE DATETIME default null,
LISTING_DATE TIMESTAMP default CURRENT_TIMESTAMP,
SALE_DATE TIMESTAMP nullable default null,
FOREIGN KEY (HOUSE_ID) REFERENCES HOUSES (ID) ON DELETE CASCADE
);
)
*/

View File

@ -14,19 +14,19 @@ enum SAZONE_MAIN {
};
enum MainCity {
City_Name[MAX_ZONE_NAME], Float:City_Area[6]
City_Short[3], City_Name[MAX_ZONE_NAME], Float:City_Area[6]
};
static const gSACitys[9][MainCity] = {
{"Los Santos", {44.60,-2892.90,-242.90,2997.00,-768.00,900.00} },
{"Las Venturas", {869.40,596.30,-242.90,2997.00,2993.80,900.00} },
{"Bone County", {-480.50,596.30,-242.90,869.40,2993.80,900.00} },
{"Tierra Robada", {-2997.40,1659.60,-242.90,-480.50,2993.80,900.00} },
{"Tierra Robada", {-1213.90,596.30,-242.90,-480.50,1659.60,900.00} },
{"San Fierro", {-2997.40,-1115.50,-242.90,-1213.90,1659.60,900.00} },
{"Red County", {-1213.90,-768.00,-242.90,2997.00,596.30,900.00} },
{"Flint County", {-1213.90,-2892.90,-242.90,44.60,-768.00,900.00} },
{"Whetstone", {-2997.40,-2892.90,-242.90,-1213.90,-1115.50,900.00}}
{"LS", "Los Santos", {44.60,-2892.90,-242.90,2997.00,-768.00,900.00} },
{"LV", "Las Venturas", {869.40,596.30,-242.90,2997.00,2993.80,900.00} },
{"BC", "Bone County", {-480.50,596.30,-242.90,869.40,2993.80,900.00} },
{"TR", "Tierra Robada", {-2997.40,1659.60,-242.90,-480.50,2993.80,900.00} },
{"TR", "Tierra Robada", {-1213.90,596.30,-242.90,-480.50,1659.60,900.00} },
{"SF", "San Fierro", {-2997.40,-1115.50,-242.90,-1213.90,1659.60,900.00} },
{"RC", "Red County", {-1213.90,-768.00,-242.90,2997.00,596.30,900.00} },
{"FC", "Flint County", {-1213.90,-2892.90,-242.90,44.60,-768.00,900.00} },
{"WS", "Whetstone", {-2997.40,-2892.90,-242.90,-1213.90,-1115.50,900.00}}
};
static const gSAZones[][SAZONE_MAIN] = {
@ -421,7 +421,19 @@ stock Get2DCity(zone[], Float:x, Float:y, Float:z = 0.0)
return format(zone, MAX_ZONE_NAME, "San Andreas");
}
stock GetZoneFromCoordinates( zone[ ], Float: x, Float: y, Float: z = 0.0 )
stock Get2DCityShort(zone[], Float:x, Float:y)
{
for( new i = 0, s = sizeof(gSACitys); i < s; i++ )
{
if(x >= gSACitys[i][City_Area][0] && x <= gSACitys[i][City_Area][3] && y >= gSACitys[i][City_Area][1] && y <= gSACitys[i][City_Area][4])
{
return format(zone, MAX_ZONE_NAME, gSACitys[i][City_Short]);
}
}
return format(zone, MAX_ZONE_NAME, "SA");
}
stock GetZoneFromCoordinates( zone[ ], Float: x, Float: y, Float: z = 0.0, const placeholder[ ] = "a place" )
{
#pragma unused z
@ -433,7 +445,7 @@ stock GetZoneFromCoordinates( zone[ ], Float: x, Float: y, Float: z = 0.0 )
break;
if( i >= sizeof( gSAZones ) )
return format( zone, MAX_ZONE_NAME, "a place" );
return format( zone, MAX_ZONE_NAME, placeholder );
return strmid( zone, gSAZones[ i ] [ SAZONE_NAME ], false, strlen( gSAZones[ i ] [ SAZONE_NAME ] ), MAX_ZONE_NAME );
}