removes the ability for LEOs to purchase a chainsaw, while also reworking certain functions to make them more accessible for global use
This commit is contained in:
parent
b9066187e6
commit
00beb49466
@ -49,6 +49,13 @@ hook OnPlayerDeath( playerid, killerid, reason )
|
||||
return 1;
|
||||
}
|
||||
|
||||
hook OnPlayerUpdate( playerid )
|
||||
{
|
||||
if ( IsPlayerAnyLEO( playerid ) && CheckIfPlayerHasWeapon( playerid, 9 ) )
|
||||
RemoveSpecificPlayerWeapon( playerid, 9, false );
|
||||
return 1;
|
||||
}
|
||||
|
||||
hook OnPlayerSpawn( playerid )
|
||||
{
|
||||
if ( 0 <= playerid < MAX_PLAYERS )
|
||||
@ -300,3 +307,26 @@ stock AC_CreateDynamicPickup( modelid, type, Float: x, Float: y, Float: z, world
|
||||
#define _ALS_CreateDynamicPickup
|
||||
#endif
|
||||
#define CreateDynamicPickup AC_CreateDynamicPickup
|
||||
|
||||
stock CheckIfPlayerHasWeapon( playerid, weaponid )
|
||||
{
|
||||
new
|
||||
iCurrentWeapon = GetPlayerWeapon( playerid ),
|
||||
iWeapon,
|
||||
iAmmo
|
||||
;
|
||||
|
||||
if ( iCurrentWeapon == weaponid )
|
||||
return true;
|
||||
else
|
||||
{
|
||||
for ( new iSlot = 0; iSlot < 13; iSlot++ )
|
||||
{
|
||||
GetPlayerWeaponData( playerid, iSlot, iWeapon, iAmmo );
|
||||
|
||||
if ( iWeapon == weaponid )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -489,3 +489,11 @@ stock IsPlayerPolice( playerid )
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
stock IsPlayerAnyLEO( playerid )
|
||||
{
|
||||
if ( IsPlayerPolice( playerid ) || IsPlayerArmy( playerid ) || IsPlayerCIA( playerid ) || IsPlayerFBI( playerid ) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
@ -317,42 +317,12 @@ 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 ]
|
||||
iCurrentWeapon = GetPlayerWeapon( playerid )
|
||||
;
|
||||
|
||||
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, .nonpassive_only = false ) != 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
|
||||
RemoveSpecificPlayerWeapon( playerid, iCurrentWeapon, true );
|
||||
return SendServerMessage( playerid, "You have dropped your weapon." );
|
||||
} else {
|
||||
return SendError( playerid, "You are not holding any weapon." );
|
||||
@ -439,3 +409,46 @@ stock ClearInactiveWeaponDrops( )
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
stock RemoveSpecificPlayerWeapon( playerid, weaponid, bool:createpickup )
|
||||
{
|
||||
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 || iWeapon != weaponid ) {
|
||||
GetPlayerWeaponData( playerid, iSlot, iWeaponID[ iSlot ], iWeaponAmmo[ iSlot ] );
|
||||
}
|
||||
else if ( createpickup )
|
||||
{
|
||||
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, .nonpassive_only = false ) != 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 1;
|
||||
}
|
@ -5039,6 +5039,7 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
case 17 .. 22: weaponid = listitem - 12;
|
||||
case 23 .. 24: weaponid = listitem - 9;
|
||||
}
|
||||
if ( IsPlayerAnyLEO( playerid ) && weaponid == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." );
|
||||
GivePlayerWeapon( playerid, weaponid, 0xFFFF );
|
||||
SendServerMessage( playerid, "You have redeemed a %s.", ReturnWeaponName( weaponid ) );
|
||||
p_VIPWeaponRedeem[ playerid ] = g_iTime + ( p_VIPLevel[ playerid ] == VIP_PLATINUM ? 60 : 300 );
|
||||
@ -5566,6 +5567,8 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||
{
|
||||
if ( x == listitem )
|
||||
{
|
||||
// Chainsaw Removal for LEO through Ammunation
|
||||
if ( IsPlayerAnyLEO( playerid ) && g_AmmunationWeapons[ i ] [ E_WEPID ] == 9 ) return SendError( playerid, "You cannot purchase a chainsaw as a Law Enforcement Officer." );
|
||||
if ( g_AmmunationWeapons[ i ] [ E_PRICE ] > GetPlayerCash( playerid ) )
|
||||
{
|
||||
SendError( playerid, "You don't have enough money for this." );
|
||||
|
Loading…
Reference in New Issue
Block a user