Merged in moneygrub (pull request #31)

Moneygrub
This commit is contained in:
Lorenc Pekaj 2018-10-14 05:14:56 +00:00
commit 2163c29812
3 changed files with 175 additions and 61 deletions

View File

@ -70,7 +70,8 @@ static stock
{ "{8ADE47}Stephanie:"COL_WHITE" Contribute to our feature "COL_GREY"/crowdfunds"COL_WHITE"! Early supporters get benefits!" },
{ "{8ADE47}Stephanie:"COL_WHITE" Don't want to be interrupted as an innocent player? Enter passive mode with "COL_GREY"/passive"COL_WHITE"!" },
{ "{8ADE47}Stephanie:"COL_WHITE" You can buy premium player homes using "COL_GREY"/estate"COL_WHITE"!" },
{ "{8ADE47}Stephanie:"COL_WHITE" You can buy Irresistible Coins from players using "COL_GREY"/ic buy"COL_WHITE"!" }
{ "{8ADE47}Stephanie:"COL_WHITE" You can buy Irresistible Coins from players using "COL_GREY"/ic buy"COL_WHITE"!" },
{ "{8ADE47}Stephanie:"COL_WHITE" Buy a secure wallet to reduce the amount of money you drop when you die!" }
},
g_randomMessageTick = 0
;

View File

@ -16,10 +16,11 @@
#define WEAPON_DROP_ENABLED
/* ** Definitions ** */
#define MAX_WEAPON_DROPS ( 50 )
#define MAX_WEAPON_DROPS ( 100 )
#define WEAPON_HEALTH ( 100 )
#define WEAPON_ARMOUR ( 101 )
#define WEAPON_MONEY ( 102 )
/* ** Variables ** */
enum E_WEAPONDROP_DATA {
@ -29,6 +30,7 @@ enum E_WEAPONDROP_DATA {
static g_weaponDropData [ MAX_WEAPON_DROPS ] [ E_WEAPONDROP_DATA ];
static Iterator: weapondrop < MAX_WEAPON_DROPS >;
static p_PlayerPickupDelay [ MAX_PLAYERS ];
static g_HealthPickup;
@ -45,18 +47,16 @@ hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart )
hook OnPlayerDeath( playerid, killerid, reason )
#endif
{
static
Float: X, Float: Y, Float: Z;
new Float: X, Float: Y, Float: Z;
new expire_time = GetServerTime( ) + 180;
GetPlayerPos( playerid, X, Y, Z );
if ( IsPlayerConnected( killerid ) && ! IsPlayerNPC( killerid ) )
{
if ( IsPlayerJailed( playerid ) || IsPlayerInPaintBall( playerid ) || IsPlayerInEvent( playerid ) || IsPlayerDueling( playerid ) )
return 1;
GetPlayerPos( playerid, X, Y, Z );
new
expire_time = GetServerTime( ) + 180;
for ( new slotid = 0; slotid < 13; slotid++ )
{
@ -86,6 +86,30 @@ hook OnPlayerDeath( playerid, killerid, reason )
if ( killer_dm_level >= 10 ) {
CreateWeaponPickup( WEAPON_HEALTH, killer_dm_level, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time );
}
// random armour drop (1% chance)
if ( killer_dm_level >= 50 && random( 101 ) == 66 ) {
CreateWeaponPickup( WEAPON_ARMOUR, killer_dm_level, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time );
}
}
// drop player money
new
player_money = floatround( float( GetPlayerCash( playerid ) ) * 0.25 );
if ( player_money > 0 )
{
// half the amount lost through secure wallet
if ( p_SecureWallet{ playerid } ) {
player_money = floatround( float( player_money ) * 0.5 );
}
// message the player
ShowPlayerHelpDialog( playerid, 5000, "~w~You have dropped ~r~%s", cash_format( player_money ) );
// reduce player money
GivePlayerCash( playerid, -player_money );
CreateWeaponPickup( WEAPON_MONEY, player_money, 0, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, expire_time );
}
return 1;
}
@ -102,6 +126,10 @@ hook OnPlayerPickUpDynPickup( playerid, pickupid )
return 1;
}
// ignore if theres a delay
if ( p_PlayerPickupDelay[ playerid ] > GetServerTime( ) )
return 1;
// Player Drops
foreach ( new dropid : weapondrop )
{
@ -122,6 +150,29 @@ hook OnPlayerPickUpDynPickup( playerid, pickupid )
SetPlayerHealth( playerid, health );
}
}
else if ( g_weaponDropData[ dropid ] [ E_WEAPON_ID ] == WEAPON_HEALTH )
{
new
Float: armour;
if ( GetPlayerArmour( playerid, armour ) )
{
// no weed like effects
if ( ( armour += float( g_weaponDropData[ dropid ] [ E_AMMO ] ) ) > 100.0 ) {
armour = 100.0;
}
SetPlayerArmour( playerid, armour );
}
}
else if ( g_weaponDropData[ dropid ] [ E_WEAPON_ID ] == WEAPON_MONEY )
{
new
dropped_money = g_weaponDropData[ dropid ] [ E_AMMO ];
GivePlayerCash( playerid, dropped_money );
SendServerMessage( playerid, "You have found "COL_GOLD"%s"COL_WHITE" on the ground.", cash_format( dropped_money ) );
}
else
{
new
@ -162,6 +213,88 @@ hook OnPlayerPickUpDynPickup( playerid, pickupid )
return 1;
}
/* ** Commands ** */
CMD:moneybag( playerid, params[ ] ) return cmd_dropmoney( playerid, params );
CMD:dm( playerid, params[ ] ) return cmd_dropmoney( playerid, params );
CMD:dropmoney( playerid, params[ ] )
{
new
money;
if ( sscanf( params, "d", money ) ) return SendUsage( playerid, "/dropmoney [AMOUNT]" );
else if ( money < 10000 ) return SendError( playerid, "The minimum amount you can drop is $10,000." );
else if ( money > GetPlayerCash( playerid ) ) return SendError( playerid, "You do not have this much money on you." );
else if ( GetPlayerVIPLevel( playerid ) < VIP_REGULAR ) return SendError( playerid, "You need to be V.I.P to use this, to become one visit "COL_GREY"donate.sfcnr.com" );
else if ( GetPVarInt( playerid, "dropmoney_cooldown" ) > GetServerTime( ) ) return SendError( playerid, "You must wait %d seconds before using this command again.", GetPVarInt( playerid, "dropmoney_cooldown" ) - GetServerTime( ) );
else
{
new
Float: X, Float: Y, Float: Z;
GetPlayerPos( playerid, X, Y, Z );
if ( CreateWeaponPickup( WEAPON_MONEY, money, 0, X, Y, Z, GetServerTime( ) + 300 ) != ITER_NONE ) {
p_PlayerPickupDelay[ playerid ] = GetServerTime( ) + 4;
SendServerMessage( playerid, "You have dropped a %s money bag. It will expire in five minutes.", cash_format( money ) );
GivePlayerCash( playerid, -money );
Streamer_Update( playerid );
SetPVarInt( playerid, "dropmoney_cooldown", GetServerTime( ) + 10 );
} else {
SendError( playerid, "Failed to create a money bag. Try again in a little bit." );
}
}
return 1;
}
CMD:disposeweapon( playerid, params[ ] ) return cmd_dropweapon( playerid, params );
CMD:dw( playerid, params[ ] ) return cmd_dropweapon( playerid, params );
CMD:dropweapon( playerid, params[ ] ) {
if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
new
iCurrentWeapon = GetPlayerWeapon( playerid ),
iWeaponID[ 13 ],
iWeaponAmmo[ 13 ]
;
if ( iCurrentWeapon != 0 )
{
for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ )
{
new
iWeapon,
iAmmo;
GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo );
if ( iWeapon != iCurrentWeapon ) {
GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] );
}
else
{
new
Float: X, Float: Y, Float: Z;
if ( GetPlayerPos( playerid, X, Y, Z ) && CreateWeaponPickup( iWeapon, iAmmo, iSlot, X + fRandomEx( 0.5, 3.0 ), Y + fRandomEx( 0.5, 3.0 ), Z, GetServerTime( ) + 120 ) != ITER_NONE ) {
p_PlayerPickupDelay[ playerid ] = GetServerTime( ) + 3;
}
}
}
ResetPlayerWeapons( playerid );
for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) {
GivePlayerWeapon( playerid, iWeaponID[ iSlot ], 0 <= iWeaponAmmo[ iSlot ] < 16384 ? iWeaponAmmo[ iSlot ] : 16384 );
}
SetPlayerArmedWeapon( playerid, 0 ); // prevent driveby
return SendServerMessage( playerid, "You have dropped your weapon." );
} else {
return SendError( playerid, "You are not holding any weapon." );
}
}
/* ** Functions ** */
stock CreateWeaponPickup( weaponid, ammo, slotid, Float: X, Float: Y, Float: Z, expire_time ) {
@ -169,7 +302,23 @@ stock CreateWeaponPickup( weaponid, ammo, slotid, Float: X, Float: Y, Float: Z,
if ( handle != ITER_NONE )
{
g_weaponDropData[ handle ] [ E_PICKUP ] = CreateDynamicPickup( weaponid == WEAPON_HEALTH ? 1240 : GetWeaponModel( weaponid ), 1, X, Y, Z );
new
modelid;
switch ( weaponid ) {
case WEAPON_HEALTH: modelid = 1240;
case WEAPON_MONEY: {
if ( ammo >= 1000 ) {
modelid = 1550;
} else {
modelid = 1212;
}
}
case WEAPON_ARMOUR: modelid = 1242;
default: modelid = GetWeaponModel( weaponid );
}
g_weaponDropData[ handle ] [ E_PICKUP ] = CreateDynamicPickup( modelid, 1, X, Y, Z );
g_weaponDropData[ handle ] [ E_EXPIRE_TIMESTAMP ] = expire_time;
g_weaponDropData[ handle ] [ E_WEAPON_ID ] = weaponid;
g_weaponDropData[ handle ] [ E_AMMO ] = ammo;

View File

@ -152,7 +152,7 @@ new
;
/* ** Weed System ** */
#define MAX_WEED_STORAGE 6
#define MAX_WEED_STORAGE ( 10 )
#define MAX_WEED ( 42 )
enum E_WEED_DATA
{
@ -3071,12 +3071,11 @@ public OnPlayerDeath( playerid, killerid, reason )
TextDrawHideForPlayer( playerid, g_currentXPTD );
HidePlayerTogglableTextdraws( playerid );
/* ** Tax And Medical Fees ** */
/* ** Tax And Medical Fees **
if ( GetPlayerTotalCash( playerid ) > 0 && ! ( IsPlayerInPaintBall( playerid ) || IsPlayerDueling( playerid ) || IsPlayerInEvent( playerid ) ) ) {
ShowPlayerHelpDialog( playerid, 5000, sprintf( "~w~You have paid ~r~$100~w~ in medical fees" ) );
GivePlayerCash( playerid, -100 );
}
/* ** End Of Tax And Medical Fees ** */
} */
new
playerGangId = p_GangID[ playerid ];
@ -4310,45 +4309,6 @@ CMD:race( playerid, params[ ] )
return SendUsage( playerid, "/race [CREATE/INVITE/JOIN/LEAVE/KICK/CONFIG/START/CONTRIBUTE/STOP]" );
}
CMD:dw( playerid, params[ ] ) return cmd_disposeweapon( playerid, params );
CMD:disposeweapon(playerid, params[]) {
if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
new
iCurrentWeapon = GetPlayerWeapon( playerid ),
iWeaponID[ 13 ],
iWeaponAmmo[ 13 ]
;
if ( iCurrentWeapon != 0 )
{
for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ )
{
new
iWeapon,
iAmmo;
GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo );
if ( iWeapon != iCurrentWeapon ) {
GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] );
}
}
ResetPlayerWeapons( playerid );
for( new iSlot = 0; iSlot < sizeof( iWeaponAmmo ); iSlot++ ) {
GivePlayerWeapon( playerid, iWeaponID[ iSlot ], 0 <= iWeaponAmmo[ iSlot ] < 16384 ? iWeaponAmmo[ iSlot ] : 16384 );
}
SetPlayerArmedWeapon( playerid, 0 ); // prevent driveby
return SendServerMessage( playerid, "You have dropped your weapon." );
} else {
return SendError( playerid, "You are not holding any weapon." );
}
}
CMD:suggest( playerid, params[ ] ) return cmd_feedback( playerid, params );
CMD:feedback( playerid, params[ ] )
{
@ -5751,7 +5711,7 @@ CMD:weed( playerid, params[ ] )
else if ( strmatch( params, "collect" ) )
{
if ( !IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You are not a drug dealer." );
if ( p_WeedGrams[ playerid ] >= MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry " #MAX_WEED_STORAGE " grams of weed." );
if ( p_WeedGrams[ playerid ] >= MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry %d grams of weed.", MAX_WEED_STORAGE );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You mustn't be inside a vehicle while collecting weed." );
new count = 0;
@ -5784,7 +5744,7 @@ CMD:weed( playerid, params[ ] )
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 > MAX_WEED_STORAGE ) return SendError( playerid, "You can only sell between 1 to " #MAX_WEED_STORAGE " grams of weed to a player." );
else if ( iAmount < 1 || iAmount > MAX_WEED_STORAGE ) return SendError( playerid, "You can only sell between 1 to %d grams of weed to a player.", MAX_WEED_STORAGE );
else if ( GetDistanceBetweenPlayers( playerid, pID ) < 5.0 )
{
new
@ -5821,7 +5781,7 @@ CMD:weed( playerid, params[ ] )
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 ( !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[ playerid ] + iGrams ) > MAX_WEED_STORAGE ) return SendError( playerid, "You can only carry " #MAX_WEED_STORAGE " grams of 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
{
p_WeedGrams[ playerid ] += iGrams;
@ -5848,7 +5808,7 @@ CMD:weed( playerid, params[ ] )
if ( p_Jailed{ playerid } == true ) return SendError( playerid, "You cannot use this in jail." );
if ( IsPlayerLoadingObjects( playerid ) ) return SendError( playerid, "You're in a object-loading state, please wait." );
if ( IsPlayerAttachedObjectSlotUsed( playerid, 0 ) ) return SendError( playerid, "You cannot use this command since you're robbing." );
if ( IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You cannot use your own products, they are for resale only!" );
// if ( IsPlayerJob( playerid, JOB_DRUG_DEALER ) ) return SendError( playerid, "You cannot use your own products, they are for resale only!" );
if ( IsPlayerInEvent( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an event." );
//if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot use this command in a vehicle." );
//if ( GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_DRIVER || GetPlayerState( playerid ) == PLAYER_STATE_ENTER_VEHICLE_PASSENGER ) return SendError( playerid, "You cannot use this command if you're entering a vehicle." );
@ -15407,7 +15367,7 @@ stock getCurrentTime( )
}
new
p_HideHelpDialogTimer[ MAX_PLAYERS ] = { 0xFFFF, ... };
p_HideHelpDialogTimer[ MAX_PLAYERS ] = { -1, ... };
stock ShowPlayerHelpDialog( playerid, timeout, format[ ], va_args<> )
{
@ -15424,17 +15384,21 @@ stock ShowPlayerHelpDialog( playerid, timeout, format[ ], va_args<> )
PlayerTextDrawShow( playerid, p_HelpBoxTD[ playerid ] );
KillTimer( p_HideHelpDialogTimer[ playerid ] );
p_HideHelpDialogTimer[ playerid ] = -1;
if ( timeout != 0 )
if ( timeout != 0 ) {
p_HideHelpDialogTimer[ playerid ] = SetTimerEx( "HidePlayerHelpDialog", timeout, false, "d", playerid );
}
return 1;
}
function HidePlayerHelpDialog( playerid )
{
p_HideHelpDialogTimer[ playerid ] = 0xFFFF;
PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] );
if ( p_HideHelpDialogTimer[ playerid ] != -1 )
{
p_HideHelpDialogTimer[ playerid ] = -1;
PlayerTextDrawHide( playerid, p_HelpBoxTD[ playerid ] );
}
}
stock fix_NightThermalVisionHack( playerid ) // Created by wups