From 22ae95ca6df9873c84674480d47f19e5374edf04 Mon Sep 17 00:00:00 2001 From: Crova Date: Mon, 14 Jan 2019 12:51:48 +0100 Subject: [PATCH] Weed sell price param --- gamemodes/irresistible/cnr/features/weed.pwn | 13 ++++++------- gamemodes/irresistible/cnr/player.pwn | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/weed.pwn b/gamemodes/irresistible/cnr/features/weed.pwn index 78b552f..b2d6000 100644 --- a/gamemodes/irresistible/cnr/features/weed.pwn +++ b/gamemodes/irresistible/cnr/features/weed.pwn @@ -154,29 +154,28 @@ CMD:weed( playerid, params[ ] ) } else if ( !strcmp( params, "sell", false, 4 ) ) { - new pID, iAmount; + new pID, iAmount, iCost; if ( !IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You are not a drug dealer." ); else if ( p_SellingWeedTick[ playerid ] > g_iTime ) return SendError( playerid, "You must wait a minute before selling weed again." ); else if ( !p_WeedGrams[ playerid ] ) return SendError( playerid, "You don't have any weed with you." ); - else if ( sscanf( params[ 5 ], "ud", pID, iAmount ) ) return SendUsage( playerid, "/weed sell [PLAYER_ID] [GRAMS]" ); + else if ( sscanf( params[ 5 ], "udd", pID, iAmount, iCost ) ) return SendUsage( playerid, "/weed sell [PLAYER_ID] [GRAMS] [PRICE]" ); else if ( !IsPlayerConnected( pID ) || IsPlayerNPC( pID ) ) return SendError( playerid, "Invalid Player ID." ); else if ( pID == playerid ) return SendError( playerid, "You cannot sell yourself weed." ); else if ( p_Class[ pID ] != CLASS_CIVILIAN ) return SendError( playerid, "This person is not a civilian." ); else if ( iAmount > p_WeedGrams[ playerid ] ) return SendError( playerid, "You only have %d grams of weed on you.", p_WeedGrams[ playerid ] ); else if ( iAmount < 1 || iAmount > 25 ) return SendError( playerid, "You can only sell between 1 to 25 grams of weed to a player." ); + else if ( iCost < 0 || iCost > 100000 ) return SendError( playerid, "Price must be between 0 and 100000." ); else if ( GetDistanceBetweenPlayers( playerid, pID ) < 5.0 ) { - new - iCost = iAmount * 5000, - iTaxed = floatround( iCost * 0.8 ) - ; + new iTaxed = floatround( iCost * 0.8 ); if ( GetPlayerCash( pID ) < iCost ) return SendError( playerid, "This person doesn't have enough money." ); p_WeedDealer[ pID ] = playerid; p_WeedTick[ pID ] = GetServerTime( ) + 120; p_WeedSellingGrams[ pID ] = iAmount; + p_WeedSellingPrice[ pID ] = iCost; p_SellingWeedTick[ playerid ] = g_iTime + 60; SendClientMessageFormatted( pID, -1, ""COL_ORANGE"[DRUG DEAL]{FFFFFF} %s(%d) is selling you %d gram(s) of weed for %s. "COL_ORANGE"/weed buy"COL_WHITE" to buy.", ReturnPlayerName( playerid ), playerid, iAmount, cash_format( iCost ) ); SendClientMessageFormatted( playerid, -1, ""COL_ORANGE"[DRUG DEAL]{FFFFFF} You have sent an offer to %s(%d) to buy a %d gram(s) of weed for "COL_GOLD"%s.", ReturnPlayerName( pID ), pID, iAmount, cash_format( iTaxed ) ); @@ -196,7 +195,7 @@ CMD:weed( playerid, params[ ] ) new dealerid = p_WeedDealer[ playerid ], iGrams = p_WeedSellingGrams[ playerid ], - iCost = iGrams * 5000, + iCost = p_WeedSellingPrice[ playerid ], iTaxed = floatround( iCost * 0.8 ) ; diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index dbc6805..6b1ec67 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -95,6 +95,7 @@ new p_WeedDealer [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... }, p_WeedTick [ MAX_PLAYERS ], p_WeedSellingGrams [ MAX_PLAYERS ], + p_WeedSellingPrice [ MAX_PLAYERS ], p_Arrests [ MAX_PLAYERS ], bool: p_AidsVaccine [ MAX_PLAYERS char ], bool: p_CantUseAsk [ MAX_PLAYERS char ],