Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < a_samp >
- #include <foreach>
- #include <streamer>
- #include <zcmd>
- #define function%0(%1) \
- forward%0(%1); public%0(%1) // Thanks Ryder`
- // Change these if you wish to change the accuracy, be careful with it tho
- /* DEFAULT VALUES:
- * MAX_VEHICLE_SHOOT_DISTANCE 5.0
- * MAX_PLAYER_SHOOT_DISTANCE 5.0
- * DISTANCE_FROM_VEHICLE 10.0
- */
- #define MAX_VEHICLE_SHOOT_DISTANCE 5.0 // maximum distance a hotrod can shoot another vehicle
- #define MAX_PLAYER_SHOOT_DISTANCE 5.0 // maximum distance a hotrod can shoot a player
- #define DISTANCE_FROM_VEHICLE 10.0 // distance away from the car infront of the car
- // Change these to your whatever you feel is right
- /* DEFAULT VALUES:
- * PLAYER_HEALTH_LOSS 5.0
- * OCCUPIED_VEHICLE_HEALTH_LOSS 75.0
- * UNOCCUPIED_VEHICLE_HEALTH_LOSS 125.0
- */
- #define PLAYER_HEALTH_LOSS 5.0 // amount of health a player loses when someone shoots him with a hotrod
- #define OCCUPIED_VEHICLE_HEALTH_LOSS 75.0 // amount of health an occupied vehicle loses when someone shoots it with a hotrod
- #define UNOCCUPIED_VEHICLE_HEALTH_LOSS 125.0 // amount of health an unoccupied vehicle loses when someone shoots it with a hotrod
- // change these to yours
- #undef MAX_VEHICLES
- #define MAX_VEHICLES 2000 // change this to your max vehicles.
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100 // change this to your max players.
- //native IsValidVehicle(vehicleid); // uncomment this if you don't have this native defined in your a_samp.inc
- enum E_MINIGUN_DATA
- {
- E_MINIGUN_OBJECT[ 2 ],
- E_MINIGUN_FLASH[ 2 ]
- };
- new updateTimer;
- new gMiniguns[ MAX_VEHICLES ][ E_MINIGUN_DATA ];
- new gHasMiniguns[ MAX_VEHICLES ] = { false, false, false };
- public OnFilterScriptInit( )
- {
- updateTimer = SetTimer( "update", 200, 1 );
- return 1;
- }
- public OnFilterScriptExit( )
- {
- KillTimer( updateTimer );
- for( new i = 0; i < MAX_VEHICLES; i++ )
- {
- if( GetVehicleModel( i ) == 434 && gHasMiniguns[ i ] )
- {
- DestroyMiniguns( i );
- DestroyMinigunFlashes( i );
- DestroyVehicle( i );
- }
- }
- return 1;
- }
- CMD:hotrod( playerid, params[ ] )
- {
- new Float:x, Float:y, Float:z, Float:angle;
- GetPlayerPos( playerid, x, y, z );
- GetPlayerFacingAngle( playerid, angle );
- new vehicle = CreateHotrod( playerid, x, y, z, angle );
- PutPlayerInVehicle( playerid, vehicle, 0 );
- return 1;
- }
- public OnVehicleDeath( vehicleid, killerid )
- {
- if( GetVehicleModel( vehicleid ) == 434 && gHasMiniguns[ vehicleid ] )
- {
- DestroyMiniguns( vehicleid );
- DestroyMinigunFlashes( vehicleid );
- DestroyVehicle( vehicleid );
- }
- return 1;
- }
- public OnVehicleSpawn( vehicleid )
- {
- if( GetVehicleModel( vehicleid ) == 434 && gHasMiniguns[ vehicleid ] )
- {
- DestroyMiniguns( vehicleid );
- DestroyMinigunFlashes( vehicleid );
- AttachMinigunsToHotrod( vehicleid );
- }
- return 1;
- }
- public OnPlayerDeath( playerid, killerid, reason )
- {
- //CallRemoteFunction( "OnPlayerDeath", "iii", playerid, killerid, reason );
- return 1;
- }
- function CreateHotrod( playerid, Float:x, Float:y, Float:z, Float:rot )
- {
- new Hotrod = CreateVehicle( 434, x, y, z, rot, -1, -1, -1 ); // Hotrod vehicle
- SetVehicleVirtualWorld( Hotrod, GetPlayerVirtualWorld( playerid ) );
- AttachMinigunsToHotrod( Hotrod );
- return Hotrod; // returns the vehicleid of the hotrod
- }
- function update( )
- {
- new
- keys,
- ud,
- lr,
- vehicleid,
- Float:x,
- Float:y,
- Float:z,
- Float:health
- ;
- foreach( new i : Player)
- {
- if( !IsPlayerInAnyVehicle( i ) ) continue;
- vehicleid = GetPlayerVehicleID( i );
- if( GetVehicleModel( vehicleid ) == 434 && gHasMiniguns[ vehicleid ] ) // hotknife
- {
- GetPlayerKeys( i, keys, ud, lr );
- if( ( ( keys & ( KEY_FIRE ) )== ( KEY_FIRE ) ) )
- {
- DestroyMinigunFlashes( vehicleid );
- gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 0 ] = CreateDynamicObject( 18695, 0, 0, 0, 0, 0, 0, GetVehicleVirtualWorld( vehicleid ), -1, -1, 200.0, 200.0 );
- AttachDynamicObjectToVehicle( gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 0 ], vehicleid, 0.299999,2.035000,-1.485000,0.000000,0.000000,0.000000 );
- gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 1 ] = CreateDynamicObject( 18695, 0, 0, 0, 0, 0, 0, GetVehicleVirtualWorld( vehicleid ), -1, -1, 200.0, 200.0 );
- AttachDynamicObjectToVehicle( gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 1 ], vehicleid, -0.310000,2.035000,-1.485000,0.000000,0.000000,0.000000 );
- PlaySoundForPlayer( i, 1135 ); // gunsound
- GetPlayerPos( i, x, y, z );
- GetXYInFrontOfPlayer( i, x, y, DISTANCE_FROM_VEHICLE );
- for( new u = 0; u < MAX_VEHICLES; u++ )
- {
- if( !IsValidVehicle( u ) ) continue;
- if( GetVehicleDistanceFromPoint( u, x, y, z ) < MAX_VEHICLE_SHOOT_DISTANCE && u != vehicleid )
- {
- GetVehicleHealth( u, health );
- if( health > 240 )
- SetVehicleHealth( u, health - UNOCCUPIED_VEHICLE_HEALTH_LOSS );
- }
- }
- foreach( new u : Player)
- {
- if( IsPlayerInRangeOfPoint( u, MAX_PLAYER_SHOOT_DISTANCE, x, y, z ) && u != i )
- {
- if( IsPlayerInAnyVehicle( u ) )
- {
- GetVehicleHealth( GetPlayerVehicleID( u ), health );
- SetVehicleHealth( GetPlayerVehicleID( u ), health - OCCUPIED_VEHICLE_HEALTH_LOSS );
- }
- else
- {
- GetPlayerHealth( u, health );
- SetPlayerHealth( u, health - PLAYER_HEALTH_LOSS );
- }
- PlayerPlaySound( u, 1135, 0.0, 0.0, 0.0 ); // gunsound
- }
- }
- }
- }
- }
- return 1;
- }
- stock AttachMinigunsToHotrod( vehicleid )
- {
- gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 0 ] = CreateDynamicObject( 362, 0, 0, 0, 0, 0, 0, GetVehicleVirtualWorld( vehicleid ), -1, -1, 200.0, 200.0 ); // minigun object
- AttachDynamicObjectToVehicle( gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 0 ], vehicleid, 0.450000,0.824999,0.290000,27.000003,27.000001,94.499977 );
- gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 1 ] = CreateDynamicObject( 362, 0, 0, 0, 0, 0, 0, GetVehicleVirtualWorld( vehicleid ), -1, -1, 200.0, 200.0 ); // minigun object
- AttachDynamicObjectToVehicle( gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 1 ], vehicleid, -0.449999,0.824999,0.260000,-54.000007,32.400001,94.499977 );
- gHasMiniguns[ vehicleid ] = true;
- return 1;
- }
- stock PlaySoundForPlayer( playerid, soundid )
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos( playerid, x, y, z );
- PlayerPlaySound( playerid, soundid, x, y, z );
- return 1;
- }
- stock DestroyMiniguns( vehicleid )
- {
- if( IsValidDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 0 ] ) )
- DestroyDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 0 ] );
- if( IsValidDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 1 ] ) )
- DestroyDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_OBJECT ][ 1 ] );
- gHasMiniguns[ vehicleid ] = false;
- return 1;
- }
- stock DestroyMinigunFlashes( vehicleid )
- {
- if( IsValidDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 0 ] ) )
- DestroyDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 0 ] );
- if( IsValidDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 1 ] ) )
- DestroyDynamicObject( gMiniguns[ vehicleid ][ E_MINIGUN_FLASH ][ 1 ] );
- return 1;
- }
- GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) // Thanks whoever made this
- {
- 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));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement