From 5be244ea276411919ed7d34011e9eaf9db79d21c Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Fri, 28 Sep 2018 02:52:38 +1000 Subject: [PATCH] begin work on player ic market --- gamemodes/irresistible/cnr/_cnr.pwn | 4 +- gamemodes/irresistible/cnr/vip/_vip.pwn | 10 +++++ .../irresistible/cnr/vip/player_market.pwn | 38 +++++++++++++++++++ gamemodes/irresistible/cnr/{ => vip}/vip.pwn | 18 ++++----- 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 gamemodes/irresistible/cnr/vip/_vip.pwn create mode 100644 gamemodes/irresistible/cnr/vip/player_market.pwn rename gamemodes/irresistible/cnr/{ => vip}/vip.pwn (96%) diff --git a/gamemodes/irresistible/cnr/_cnr.pwn b/gamemodes/irresistible/cnr/_cnr.pwn index 3a5a2f0..b6d8430 100644 --- a/gamemodes/irresistible/cnr/_cnr.pwn +++ b/gamemodes/irresistible/cnr/_cnr.pwn @@ -15,7 +15,9 @@ #include "irresistible\cnr\spawn.pwn" #include "irresistible\cnr\dialog_ids.pwn" #include "irresistible\cnr\checkpoints.pwn" -#include "irresistible\cnr\vip.pwn" + +// reliant on core definitions +#include "irresistible\cnr\vip\_vip.pwn" #include "irresistible\cnr\ammunation.pwn" #include "irresistible\cnr\irresistibleguard.pwn" #include "irresistible\cnr\player_settings.pwn" diff --git a/gamemodes/irresistible/cnr/vip/_vip.pwn b/gamemodes/irresistible/cnr/vip/_vip.pwn new file mode 100644 index 0000000..f263282 --- /dev/null +++ b/gamemodes/irresistible/cnr/vip/_vip.pwn @@ -0,0 +1,10 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc Pekaj + * Module: cnr\vip\_vip.pwn + * Purpose: encloses all vip modules & components (cnr) + */ + +/* ** Includes ** */ +#include "irresistible\cnr\vip\vip.pwn" +#include "irresistible\cnr\vip\player_market.pwn" diff --git a/gamemodes/irresistible/cnr/vip/player_market.pwn b/gamemodes/irresistible/cnr/vip/player_market.pwn new file mode 100644 index 0000000..48b2601 --- /dev/null +++ b/gamemodes/irresistible/cnr/vip/player_market.pwn @@ -0,0 +1,38 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc Pekaj + * Module: + * Purpose: + */ + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Definitions ** */ + +/* ** Variables ** */ + +/* ** Hooks ** */ + +/* ** Functions ** */ + +/* ** Migrations ** */ +/* + CREATE TABLE IF NOT EXISTS IC_SELL_ORDERS ( + USER_ID int(11) PRIMARY KEY, + ASK_PRICE int(11), + TOTAL_IC float, + LISTING_DATE TIMESTAMP default CURRENT_TIMESTAMP, + UNIQUE (USER_ID), + FOREIGN KEY (USER_ID) REFERENCES USERS (ID) ON DELETE CASCADE + ); + + CREATE TABLE IF NOT EXISTS IC_MARKET_LOG ( + `ID` int(11) AUTO_INCREMENT PRIMARY KEY, + `SELLER_ID` int(11), + `BUYER_ID` int(11), + `ASK_RATE` int(11), + `IC_AMOUNT` float, + `DATE` TIMESTAMP default CURRENT_TIMESTAMP + ); +*/ diff --git a/gamemodes/irresistible/cnr/vip.pwn b/gamemodes/irresistible/cnr/vip/vip.pwn similarity index 96% rename from gamemodes/irresistible/cnr/vip.pwn rename to gamemodes/irresistible/cnr/vip/vip.pwn index 23e6b2d..e6d4ce8 100644 --- a/gamemodes/irresistible/cnr/vip.pwn +++ b/gamemodes/irresistible/cnr/vip/vip.pwn @@ -55,7 +55,7 @@ new { VIP_BRONZE, "Bronze V.I.P", 1000.0 }, { VIP_REGULAR, "Regular V.I.P", 500.0 } }, - g_irreisistibleCashCards [ ] [ E_IC_MARKET_DATA ] = + g_irresistibleCashCards [ ] [ E_IC_MARKET_DATA ] = { { 1250000, "Tiger Shark", 225.0 }, { 2750000, "Bull Shark", 450.0 }, @@ -156,7 +156,7 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) } // cash cards else if ( dialogid == DIALOG_IC_MARKET_3 ) { - iCoinRequirement *= g_irreisistibleCashCards[ listitem ] [ E_PRICE ]; + iCoinRequirement *= g_irresistibleCashCards[ listitem ] [ E_PRICE ]; } p_CoinMarketPage{ playerid } = ( dialogid == DIALOG_IC_MARKET_3 ) ? ICM_PAGE_CASHCARD : ICM_PAGE_ASSETS; @@ -250,19 +250,19 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) // buy cash cards else if ( p_CoinMarketPage{ playerid } == ICM_PAGE_CASHCARD ) { - new Float: iCoinRequirement = g_irreisistibleCashCards[ listitem ] [ E_PRICE ] * GetGVarFloat( "vip_discount" ); + new Float: iCoinRequirement = g_irresistibleCashCards[ listitem ] [ E_PRICE ] * GetGVarFloat( "vip_discount" ); if ( player_coins < iCoinRequirement ) { SendError( playerid, "You need around %s coins before you can get this!", number_format( iCoinRequirement - player_coins, .decimals = 2 ) ); return ShowPlayerCoinMarketDialog( playerid, p_CoinMarketPage{ playerid } ); } - new cash_amount = g_irreisistibleCashCards[ listitem ] [ E_ID ]; + new cash_amount = g_irresistibleCashCards[ listitem ] [ E_ID ]; GivePlayerCash( playerid, cash_amount ); GivePlayerIrresistibleCoins( playerid, -iCoinRequirement ); - SendServerMessage( playerid, "You have ordered a "COL_GREEN"%s Cash Card (%s)"COL_WHITE" for %s Irresistible Coins!", g_irreisistibleCashCards[ listitem ] [ E_NAME ], number_format( cash_amount ), number_format( iCoinRequirement, .decimals = 0 ) ); - ShowPlayerHelpDialog( playerid, 10000, "You have bought a ~g~%s~w~ %s Cash Card!", number_format( cash_amount ), g_irreisistibleCashCards[ listitem ] [ E_NAME ] ); + SendServerMessage( playerid, "You have ordered a "COL_GREEN"%s Cash Card (%s)"COL_WHITE" for %s Irresistible Coins!", g_irresistibleCashCards[ listitem ] [ E_NAME ], number_format( cash_amount ), number_format( iCoinRequirement, .decimals = 0 ) ); + ShowPlayerHelpDialog( playerid, 10000, "You have bought a ~g~%s~w~ %s Cash Card!", number_format( cash_amount ), g_irresistibleCashCards[ listitem ] [ E_NAME ] ); } // all other market items @@ -476,10 +476,10 @@ stock ShowPlayerCoinMarketDialog( playerid, page = ICM_PAGE_DEFAULT ) { szMarket = ""COL_GREY"Cash Card\t"COL_GREY"Amount ($)\t"COL_GREY"Coins Needed\n"; - for( new i = 0; i < sizeof( g_irreisistibleCashCards ); i++ ) + for( new i = 0; i < sizeof( g_irresistibleCashCards ); i++ ) { - new iCoinRequirement = floatround( g_irreisistibleCashCards[ i ] [ E_PRICE ] * discount ); - format( szMarket, sizeof( szMarket ), "%s%s\t"COL_GREEN"%s\t"COL_GOLD"%s\n", szMarket, g_irreisistibleCashCards[ i ] [ E_NAME ], number_format( g_irreisistibleCashCards[ i ] [ E_ID ] ), number_format( iCoinRequirement, .decimals = 0 ) ); + new iCoinRequirement = floatround( g_irresistibleCashCards[ i ] [ E_PRICE ] * discount ); + format( szMarket, sizeof( szMarket ), "%s%s\t"COL_GREEN"%s\t"COL_GOLD"%s\n", szMarket, g_irresistibleCashCards[ i ] [ E_NAME ], number_format( g_irresistibleCashCards[ i ] [ E_ID ] ), number_format( iCoinRequirement, .decimals = 0 ) ); } return ShowPlayerDialog( playerid, DIALOG_IC_MARKET_3, DIALOG_STYLE_TABLIST_HEADERS, ""COL_GOLD"Irresistible Coin -{FFFFFF} Cash Cards", szMarket, "Select", "Back" ); }