From 22ae95ca6df9873c84674480d47f19e5374edf04 Mon Sep 17 00:00:00 2001 From: Crova Date: Mon, 14 Jan 2019 12:51:48 +0100 Subject: [PATCH 1/5] 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 ], From ea176e5928a65394b31ca9e95f08d4ee3ddac7ba Mon Sep 17 00:00:00 2001 From: Crova Date: Sat, 19 Jan 2019 15:19:37 +0100 Subject: [PATCH 2/5] Removes tax from weed sell/buy --- gamemodes/irresistible/cnr/features/weed.pwn | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/weed.pwn b/gamemodes/irresistible/cnr/features/weed.pwn index b2d6000..e70d08e 100644 --- a/gamemodes/irresistible/cnr/features/weed.pwn +++ b/gamemodes/irresistible/cnr/features/weed.pwn @@ -168,8 +168,6 @@ CMD:weed( playerid, params[ ] ) else if ( iCost < 0 || iCost > 100000 ) return SendError( playerid, "Price must be between 0 and 100000." ); else if ( GetDistanceBetweenPlayers( playerid, pID ) < 5.0 ) { - new iTaxed = floatround( iCost * 0.8 ); - if ( GetPlayerCash( pID ) < iCost ) return SendError( playerid, "This person doesn't have enough money." ); p_WeedDealer[ pID ] = playerid; @@ -178,7 +176,7 @@ CMD:weed( playerid, params[ ] ) 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 ) ); + 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( iCost ) ); return 1; } else @@ -195,8 +193,7 @@ CMD:weed( playerid, params[ ] ) new dealerid = p_WeedDealer[ playerid ], iGrams = p_WeedSellingGrams[ playerid ], - iCost = p_WeedSellingPrice[ playerid ], - iTaxed = floatround( iCost * 0.8 ) + iCost = p_WeedSellingPrice[ playerid ] ; if ( GetPlayerCash( playerid ) < iCost ) return SendError( playerid, "You need %s to buy %d grams of weed.", cash_format( iCost ), iGrams ); @@ -211,9 +208,9 @@ CMD:weed( playerid, params[ ] ) p_WeedGrams[ dealerid ] -= iGrams; GivePlayerCash( playerid, -iCost ); - GivePlayerCash( dealerid, iTaxed ); + GivePlayerCash( dealerid, iCost ); - SendClientMessageFormatted( dealerid, -1, ""COL_ORANGE"[DRUG DEAL]{FFFFFF} %s(%d) has bought %d grams of weed off you for %s.", ReturnPlayerName( playerid ), playerid, iGrams, cash_format( iTaxed ) ); + SendClientMessageFormatted( dealerid, -1, ""COL_ORANGE"[DRUG DEAL]{FFFFFF} %s(%d) has bought %d grams of weed off you for %s.", ReturnPlayerName( playerid ), playerid, iGrams, cash_format( iCost ) ); SendClientMessageFormatted( playerid, -1, ""COL_ORANGE"[DRUG DEAL]{FFFFFF} You have bought %d grams of weed for %s.", iGrams, cash_format( iCost ) ); GivePlayerWantedLevel( dealerid, 6 ); From 5b7dfb75582273604e24c75719ba31f02ba77b43 Mon Sep 17 00:00:00 2001 From: Crova Date: Sat, 19 Jan 2019 15:31:44 +0100 Subject: [PATCH 3/5] Fixes a map bug, being able to rob safes without exploding the gates. --- gamemodes/irresistible/cnr/static/server_objects.pwn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gamemodes/irresistible/cnr/static/server_objects.pwn b/gamemodes/irresistible/cnr/static/server_objects.pwn index 3f8eaca..bbafda7 100644 --- a/gamemodes/irresistible/cnr/static/server_objects.pwn +++ b/gamemodes/irresistible/cnr/static/server_objects.pwn @@ -5124,6 +5124,11 @@ hook OnScriptInit( ) CreateDynamicObject( 2607, -2376.293945, 1553.312988, 1.487188, 0.000000, 0.000000, 0.000000, -1, -1, -1 ); CreateDynamicObject( 1514, -2375.768554, 1553.325317, 2.117187, 0.000000, 0.000000, 22.000122, -1, -1, -1 ); + // Militia Ship Fix + SetDynamicObjectMaterial( CreateDynamicObject( 19368, -2366.884033, 1551.858032, 2.117000, 0.000000, 0.000000, 86.300003, -1, -1, -1 ), 0, 18202, "w_towncs_t", "concretebig4256128", 1 ); + SetDynamicObjectMaterial( CreateDynamicObject( 19368, -2369.967041, 1556.052978, 2.117000, 0.000000, 0.000000, -3.900000, -1, -1, -1 ), 0, 18202, "w_towncs_t", "concretebig4256128", 1 ); + SetDynamicObjectMaterial( CreateDynamicObject( 19464, -2367.564941, 1554.942993, 3.707000, 0.000000, 90.000000, -3.700000, -1, -1, -1 ), 0, 18202, "w_towncs_t", "concretebig4256128", 1 ); + // SF Penis Tower // tmpVariable = CreateDynamicObject( 8131, -1980.097290, 884.313598, 54.389820, 0.000000, 0.000000, 90.000000, -1, -1, -1 ); // SetDynamicObjectMaterial( tmpVariable, 0, 8460, "vgseland03_lvs", "ceaserwall06_128", 0 ); From 4da941cd097f53c5bc2105c7a3c69763e997910d Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 20 Jan 2019 11:14:44 +1100 Subject: [PATCH 4/5] reset selling properties weed --- gamemodes/irresistible/cnr/features/weed.pwn | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gamemodes/irresistible/cnr/features/weed.pwn b/gamemodes/irresistible/cnr/features/weed.pwn index e70d08e..5a6675f 100644 --- a/gamemodes/irresistible/cnr/features/weed.pwn +++ b/gamemodes/irresistible/cnr/features/weed.pwn @@ -62,6 +62,7 @@ hook OnServerUpdate( ) hook OnPlayerDisconnect( playerid, reason ) { Weed_RemovePlayerPlants( playerid ); + Weed_ResetSellingProperties( playerid ); return 1; } @@ -112,8 +113,7 @@ hook OnPlayerKeyStateChange( playerid, newkeys, oldkeys ) CMD:weed( playerid, params[ ] ) { new - Float: X, Float: Y, Float: Z - ; + Float: X, Float: Y, Float: Z; if ( p_Class[ playerid ] != CLASS_CIVILIAN ) return SendError( playerid, "You are not a civilian." ); @@ -165,7 +165,7 @@ CMD:weed( playerid, params[ ] ) 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 ( iCost <= 0 || iCost > 100000 ) return SendError( playerid, "Price must be between 1 and 100000." ); else if ( GetDistanceBetweenPlayers( playerid, pID ) < 5.0 ) { if ( GetPlayerCash( pID ) < iCost ) return SendError( playerid, "This person doesn't have enough money." ); @@ -187,7 +187,7 @@ CMD:weed( playerid, params[ ] ) else if ( strmatch( params, "buy" ) ) { if ( !IsPlayerConnected( p_WeedDealer[ playerid ] ) ) return SendError( playerid, "Your dealer isn't connected anymore." ); - else if ( GetServerTime( ) > p_WeedTick[ playerid ] ) return p_WeedDealer[ playerid ] = INVALID_PLAYER_ID, SendError( playerid, "This deal has ended, each deal goes for 2 minutes maximum. You were late." ); + else if ( GetServerTime( ) > p_WeedTick[ playerid ] ) return Weed_ResetSellingProperties( playerid ), SendError( playerid, "This deal has ended, each deal goes for 2 minutes maximum. You were late." ); else { new @@ -198,9 +198,9 @@ CMD:weed( playerid, params[ ] ) if ( GetPlayerCash( playerid ) < iCost ) return SendError( playerid, "You need %s to buy %d grams of weed.", cash_format( iCost ), iGrams ); else if ( IsPlayerInPaintBall( dealerid ) || IsPlayerDueling( dealerid ) ) return SendError( playerid, "Your dealer cannot deal in an arena." ); - else if ( p_Class[ dealerid ] != CLASS_CIVILIAN ) return p_WeedDealer[ playerid ] = INVALID_PLAYER_ID, SendError( playerid, "This deal has ended, the dealer is not a civilian." ); + else if ( p_Class[ dealerid ] != CLASS_CIVILIAN ) return Weed_ResetSellingProperties( playerid ), SendError( playerid, "This deal has ended, the dealer is not a civilian." ); else if ( !IsPlayerJob( dealerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "Your dealer no longer does drugs." ); - else if ( !p_WeedGrams[ dealerid ] ) return p_WeedDealer[ playerid ] = INVALID_PLAYER_ID, SendError( playerid, "Your dealer doesn't have any more weed." ); + else if ( !p_WeedGrams[ dealerid ] ) return Weed_ResetSellingProperties( playerid ), SendError( playerid, "Your dealer doesn't have any more weed." ); //else if ( ( p_WeedGrams[ playerid ] + iGrams ) > MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry %d grams of weed.", MAX_WEED_STORAGE ); else { @@ -217,7 +217,7 @@ CMD:weed( playerid, params[ ] ) GivePlayerWantedLevel( playerid, 6 ); Beep( dealerid ); - p_WeedDealer[ playerid ] = INVALID_PLAYER_ID; + Weed_ResetSellingProperties( playerid ); } } return 1; @@ -326,3 +326,10 @@ stock Weed_GetPlantLimit( playerid ) return 5; } } + +stock Weed_ResetSellingProperties( playerid ) +{ + Weed_ResetSellingProperties( playerid ); + p_WeedSellingGrams[ playerid ] = 0; + p_WeedSellingPrice[ playerid ] = 0; +} \ No newline at end of file From 2cf0111d75a3300203879344d06c07edd1a8c3fd Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Sun, 20 Jan 2019 11:15:21 +1100 Subject: [PATCH 5/5] address warning with Weed_ResetSellingProperties --- gamemodes/irresistible/cnr/features/weed.pwn | 1 + 1 file changed, 1 insertion(+) diff --git a/gamemodes/irresistible/cnr/features/weed.pwn b/gamemodes/irresistible/cnr/features/weed.pwn index 5a6675f..6d814ce 100644 --- a/gamemodes/irresistible/cnr/features/weed.pwn +++ b/gamemodes/irresistible/cnr/features/weed.pwn @@ -332,4 +332,5 @@ stock Weed_ResetSellingProperties( playerid ) Weed_ResetSellingProperties( playerid ); p_WeedSellingGrams[ playerid ] = 0; p_WeedSellingPrice[ playerid ] = 0; + return 1; } \ No newline at end of file