Code:
#include < a_samp >
#define MAX_MINIGUNS 10000
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new
dinmgun[ MAX_MINIGUNS ]
,minigunnum = 0
,vehhasminigun[ MAX_VEHICLES ]
,dinlaser[ MAX_PLAYERS ]
;
for( new i = 0; i < MAX_VEHICLES; ++i )
{
new model = GetVehicleModel( i );
if( model == 473 )
{
if( vehhasminigun[ i ] == 0 )
{
vehhasminigun[ i ] = 1;
dinmgun[ dinminigunnum ] = CreateObject( 2985, 0, 0, 0, 0, 0, 0 );
AttachObjectToVehicle( dinmgun[ dinminigunnum ], i, 0.000000, 1.289999, 0.000000, 0.000000, 0.000000, 90); //Object Model: 2985 |
minigunnum ++;
}
}
}
PUB:destroy( i )
{
DestroyObject( dinlaser[ i ] );
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehid = GetPLayerVehicleID(playerid);
new model = GetVehicleModel(vehid);
if(pressed(KEY_FIRE) && IsPlayerInAnyVehicle(playerid) && vehhasminigun[vehid])
{
if(model == 473)
{
dinlaser[ i ] = CreateObject( 19084, 0.75, 3.84, 0.86, 0.00, 0.00, 92.61 );
AttachObjectToVehicle( dinlaser[ i ], vehicleid, -0.014999, 1.289999, 1.129999, 0.000000, 0.000000, 90); //Object Model: 19084 |
PlayerPlaySound( i, 1135, 0.0, 0.0, 0.0 );
SetTimerEx( "destroy", 250, 0, "i", i );
new
Float:x
,Float:y
,Float:z
,Float:x2
,Float:y2
;
GetPlayerPos( i, x2, y2, z );
#pragma unused x2
#pragma unused y2
GetXYInFrontOfPlayer( i, x, y, 5.0 );
for( new u = 0; u < MAX_PLAYERS; ++u )
{
if( IsPlayerInRangeOfPoint( u, 6.0, x, y, z ) && u != i )
{
if( !IsPlayerInAnyVehicle( u ) )
{
new
Float:hp
,Float:hp2
;
GetPlayerHealth( u, hp );
SetPlayerHealth( u, hp - 20 );
GetPlayerHealth( u, hp2 );
PlayerPlaySound( u, 1135, 0.0, 0.0, 0.0 );
if( hp2 < 1 )CallRemoteFunction( "OnPlayerDeath", "ddd", u, i, 38 );
}
else
{
new
Float:hp
,Float:hp2
,veh
;
veh = GetPlayerVehicleID(u);
GetVehicleHealth( veh, hp );
SetVehicleHealth( veh, hp - 150 );
GetPlayerHealth( u, hp2 );
PlayerPlaySound( u, 1135, 0.0, 0.0, 0.0 );
if( hp2 < 1 )CallRemoteFunction( "OnPlayerDeath", "ddd", u, i, 38 );
}
}
}
}
}
return 1;
}
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
GetXYBehindPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
x -= (distance * floatsin(-a, degrees));
y -= (distance * floatcos(-a, degrees));
}