Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* FS:Bazooka made by Marricio/Mecaurio for SA-MP forums
- I keep the credits as creator of this filterscript.
- Check line 242*/
- #include a_samp
- #include zcmd
- #include MapAndreas
- #define SCRIPT_VERSION "v1.1"
- #define MISSIL_RANGE 55.0
- #define MAX_BAZOOKAS 200
- #define FIRE_SPEED 40
- forward FixAnimation( playerid );
- enum fs_bInfo
- {
- bCreated,
- Float:bx,
- Float:by,
- Float:bz,
- Float:ba,
- Float:bmx,
- Float:bmy,
- Float:bmz,
- bObject,
- bMissil,
- bBeingUsed,
- bPlacedBy[24],
- bDate[64]
- }
- new BazInfo[MAX_BAZOOKAS][fs_bInfo];
- new PlacingBazooka[MAX_PLAYERS];
- new AimingBazooka[MAX_PLAYERS] = -1;
- public OnFilterScriptInit( )
- {
- printf(" FS:Bazooka %s by Marricio is loaded.", SCRIPT_VERSION );
- }
- public OnPlayerDisconnect( playerid )
- {
- PlacingBazooka[playerid] = 0;
- AimingBazooka[playerid] = -1;
- if( IsPlayerAttachedObjectSlotUsed( playerid, 0 ) )
- RemovePlayerAttachedObject( playerid, 0 );
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bBeingUsed] == playerid )
- {
- BazInfo[i][bBeingUsed] = -1;
- break;
- }
- }
- return 1;
- }
- public OnFilterScriptExit( )
- {
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bCreated] == 1 )
- {
- BazInfo[i][bCreated] = 0;
- BazInfo[i][bx] = 0;
- BazInfo[i][by] = 0;
- BazInfo[i][bz] = 0;
- BazInfo[i][bmx] = 0;
- BazInfo[i][bmy] = 0;
- BazInfo[i][bmz] = 0;
- BazInfo[i][ba] = 0;
- BazInfo[i][bBeingUsed] = -1;
- if( IsValidObject( BazInfo[i][bMissil] ) )
- DestroyObject( BazInfo[i][bMissil] );
- if( IsValidObject( BazInfo[i][bObject] ) )
- DestroyObject( BazInfo[i][bObject] );
- format( BazInfo[i][bPlacedBy], 32, "None" );
- format( BazInfo[i][bDate], 64, "-" );
- for( new pi = 0; pi != MAX_PLAYERS; pi++ )
- {
- if( AimingBazooka[pi] == i )
- {
- SetCameraBehindPlayer( pi );
- ClearAnimations( pi );
- TogglePlayerControllable( pi, 1 );
- AimingBazooka[pi] = -1;
- if( IsPlayerAttachedObjectSlotUsed( pi, 0 ) )
- RemovePlayerAttachedObject( pi, 0 );
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerUpdate( playerid )
- {
- new Keys,ud,lr;
- GetPlayerKeys(playerid,Keys,ud,lr);
- if( AimingBazooka[playerid] != -1 )
- {
- if( lr > 0 )
- {
- new Float:fA, Float:lookPos[3];
- GetPlayerPos( playerid, lookPos[0], lookPos[1], lookPos[2] );
- GetPlayerFacingAngle( playerid, fA );
- SetPlayerFacingAngle( playerid, fA-0.6 );
- BazInfo[AimingBazooka[playerid]][ba]-=0.6;
- GetXYInFrontOfPoint( lookPos[0], lookPos[1], fA, MISSIL_RANGE );
- SetPlayerCameraLookAt( playerid, lookPos[0], lookPos[1], lookPos[2] );
- }
- else if( lr < 0 )
- {
- new Float:fA, Float:lookPos[3];
- GetPlayerPos( playerid, lookPos[0], lookPos[1], lookPos[2] );
- GetPlayerFacingAngle( playerid, fA );
- SetPlayerFacingAngle( playerid, fA+0.6 );
- BazInfo[AimingBazooka[playerid]][ba]+=0.8;
- GetXYInFrontOfPoint( lookPos[0], lookPos[1], fA, MISSIL_RANGE );
- SetPlayerCameraPos( playerid, BazInfo[AimingBazooka[playerid]][bx], BazInfo[AimingBazooka[playerid]][by], BazInfo[AimingBazooka[playerid]][bz]+0.8 );
- SetPlayerCameraLookAt( playerid, lookPos[0], lookPos[1], lookPos[2] );
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
- {
- if( newkeys & KEY_SECONDARY_ATTACK )
- {
- if( PlacingBazooka[playerid] == 1 )
- {
- new Float:pPos[4];
- GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );
- GetPlayerFacingAngle( playerid, pPos[3] );
- CreateBazooka( playerid, pPos[0], pPos[1], pPos[2], pPos[3] );
- SendClientMessage( playerid, -1, "You placed a bazooka. | Press your ENTER key to enable shooting | FIRE key to shoot the bazooka |." );
- RemovePlayerAttachedObject( playerid, 0 );
- PlacingBazooka[playerid] = 0;
- return 1;
- }
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bCreated] == 1 )
- {
- if( IsPlayerInRangeOfPoint( playerid, 1.0, BazInfo[i][bx], BazInfo[i][by], BazInfo[i][bz] ) )
- {
- if( AimingBazooka[playerid] != -1 )
- {
- new Float:pPos[4];
- GetPlayerPos( playerid, pPos[0], pPos[1], pPos[2] );
- GetPlayerFacingAngle( playerid, pPos[3] );
- SetPlayerPos( playerid, pPos[0]-0.5, pPos[1]-0.5, pPos[2] );
- AimingBazooka[playerid] = -1;
- SetCameraBehindPlayer( playerid );
- TogglePlayerControllable( playerid, 1 );
- ClearAnimations( playerid );
- if( IsPlayerAttachedObjectSlotUsed( playerid, 0 ) )
- RemovePlayerAttachedObject( playerid, 0 );
- for( new b = 0; b != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[b][bBeingUsed] == playerid )
- {
- BazInfo[b][bObject] = CreateObject( 2600, pPos[0], pPos[1], pPos[2]-0.17, 0, 0, pPos[3] );
- break;
- }
- }
- BazInfo[i][bBeingUsed] = -1;
- return 1;
- }
- else
- {
- if( BazInfo[i][bBeingUsed] == -1 )
- {
- new Float:lookPos[4];
- lookPos[0] = BazInfo[i][bx]; lookPos[1] = BazInfo[i][by]; lookPos[2] = BazInfo[i][bz]; lookPos[3] = BazInfo[i][ba];
- DestroyObject( BazInfo[i][bObject] );
- AimingBazooka[playerid] = i;
- BazInfo[i][bBeingUsed] = playerid;
- SetPlayerPos( playerid, BazInfo[i][bx], BazInfo[i][by], BazInfo[i][bz] );
- SetPlayerFacingAngle( playerid, BazInfo[i][ba] );
- TogglePlayerControllable( playerid, 0 );
- GetXYInFrontOfPoint( lookPos[0], lookPos[1], BazInfo[i][ba], MISSIL_RANGE );
- SetPlayerCameraPos( playerid, BazInfo[i][bx], BazInfo[i][by], BazInfo[i][bz]+0.8 );
- SetPlayerCameraLookAt( playerid, lookPos[0], lookPos[1], lookPos[2] );
- SetTimerEx( "FixAnimation", 200, false, "i", playerid );
- SendClientMessage( playerid, -1, "Use your left and right key to move your angle." );
- if( IsPlayerAttachedObjectSlotUsed( playerid, 0 ) )
- RemovePlayerAttachedObject( playerid, 0 );
- SetPlayerAttachedObject( playerid,0,2600,6,0.227999,0.071999,-0.580999,-173.000030,-172.099990,81.000000,1.000000,1.000000,1.000000 );
- }
- else
- return SendClientMessage( playerid, -1, "Somebody is already using this bazooka." );
- }
- }
- }
- }
- }
- if( newkeys & KEY_FIRE )
- {
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bCreated] == 1 )
- {
- if( !IsValidObject( BazInfo[i][bMissil] ) )
- {
- if( AimingBazooka[playerid] == i )
- {
- new Float:fA;
- GetPlayerFacingAngle( playerid, fA );
- BazInfo[i][bMissil] = CreateObject( 1636, BazInfo[i][bmx], BazInfo[i][bmy], BazInfo[i][bmz]+0.5, 0, 0, fA );
- GetXYInFrontOfPoint( BazInfo[i][bmx], BazInfo[i][bmy], fA, MISSIL_RANGE );
- BazInfo[i][bmz] = 0.0;
- GetPointZPos( BazInfo[i][bmx], BazInfo[i][bmy], BazInfo[i][bmz] ); // You can edit this line if you're not using MapAndreas RydeR's edit.
- MoveObject( BazInfo[i][bMissil], BazInfo[i][bmx], BazInfo[i][bmy], BazInfo[i][bmz], FIRE_SPEED );
- break;
- }
- }
- else
- return SendClientMessage( playerid, -1, "The bazooka is reloading.." );
- }
- }
- }
- return 1;
- }
- public FixAnimation( playerid )
- {
- if( AimingBazooka[playerid] != -1 )
- {
- ClearAnimations( playerid );
- ApplyAnimation(playerid, "SHOP", "SHP_Gun_Aim", 4.0, 0, 1, 0, 1, -1);
- ApplyAnimation(playerid, "SHOP", "SHP_Gun_Aim", 4.0, 0, 1, 0, 1, -1);
- }
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( objectid == BazInfo[i][bMissil] )
- {
- new Float:oPos[3];
- GetObjectPos( objectid, oPos[0], oPos[1], oPos[2] );
- CreateExplosion( oPos[0], oPos[1], oPos[2], 0, 10.0 );
- DestroyObject( objectid );
- BazInfo[i][bMissil] = -1;
- BazInfo[i][bmx] = BazInfo[i][bx];
- BazInfo[i][bmy] = BazInfo[i][by];
- BazInfo[i][bmz] = BazInfo[i][bz];
- GetXYInFrontOfPoint( BazInfo[i][bmx], BazInfo[i][bmy], BazInfo[i][ba], 3 );
- break;
- }
- }
- return 1;
- }
- CMD:bazookainfo( playerid, params[] )
- {
- if( IsPlayerAdmin( playerid ) )
- {
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( IsPlayerInRangeOfPoint( playerid, 2.0, BazInfo[i][bx], BazInfo[i][by], BazInfo[i][bz] ) )
- {
- new szString[128];
- format( szString, 128, "| Bazooka ID: %d | Placed By: %s |", i, BazInfo[i][bPlacedBy] );
- SendClientMessage( playerid, -1, szString );
- format( szString, 128, "| Placed in Time: %s |", BazInfo[i][bDate] );
- SendClientMessage( playerid, -1, szString );
- }
- }
- }
- else
- return SendClientMessage( playerid, -1, "You must be logged in as RCON." );
- return 1;
- }
- CMD:placebazooka( playerid, params[] )
- {
- if( IsPlayerAttachedObjectSlotUsed( playerid, 0 ) )
- RemovePlayerAttachedObject( playerid, 0 );
- new szName[24];
- GetPlayerName( playerid, szName, 24 );
- PlacingBazooka[playerid] = 1;
- SendClientMessage( playerid, -1, "Find a place you want the bazooka to be and click your ENTER key." );
- SetPlayerAttachedObject( playerid,0,2600,6,0.227999,0.071999,-0.580999,-173.000030,-172.099990,81.000000,1.000000,1.000000,1.000000 );
- SetPlayerArmedWeapon( playerid, 0 );
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bCreated] == 1 )
- {
- if( !strcmp( BazInfo[i][bPlacedBy], szName, true ) )
- {
- BazInfo[i][bCreated] = 0;
- BazInfo[i][bx] = 0;
- BazInfo[i][by] = 0;
- BazInfo[i][bz] = 0;
- BazInfo[i][bmx] = 0;
- BazInfo[i][bmy] = 0;
- BazInfo[i][bmz] = 0;
- BazInfo[i][ba] = 0;
- BazInfo[i][bBeingUsed] = -1;
- if( IsValidObject( BazInfo[i][bMissil] ) )
- DestroyObject( BazInfo[i][bMissil] );
- if( IsValidObject( BazInfo[i][bObject] ) )
- DestroyObject( BazInfo[i][bObject] );
- format( BazInfo[i][bPlacedBy], 32, "None" );
- format( BazInfo[i][bDate], 64, "-" );
- break;
- }
- }
- }
- return 1;
- }
- CMD:removebazooka( playerid, params[] )
- {
- if( !IsPlayerAdmin( playerid ) )
- return SendClientMessage( playerid, -1, "You must be logged in as RCON." );
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bCreated] == 1 )
- {
- if( IsPlayerInRangeOfPoint( playerid, 3.0, BazInfo[i][bx], BazInfo[i][by], BazInfo[i][bz] ) )
- {
- BazInfo[i][bCreated] = 0;
- BazInfo[i][bx] = 0;
- BazInfo[i][by] = 0;
- BazInfo[i][bz] = 0;
- BazInfo[i][bmx] = 0;
- BazInfo[i][bmy] = 0;
- BazInfo[i][bmz] = 0;
- BazInfo[i][ba] = 0;
- BazInfo[i][bBeingUsed] = -1;
- if( IsValidObject( BazInfo[i][bMissil] ) )
- DestroyObject( BazInfo[i][bMissil] );
- if( IsValidObject( BazInfo[i][bObject] ) )
- DestroyObject( BazInfo[i][bObject] );
- format( BazInfo[i][bPlacedBy], 32, "None" );
- format( BazInfo[i][bDate], 64, "-" );
- SendClientMessage( playerid, -1, "You succesfully removed your nearest bazooka." );
- break;
- }
- else
- return SendClientMessage( playerid, -1, "You're not near any bazooka." );
- }
- }
- return 1;
- }
- stock GetXYInFrontOfPoint(&Float:x, &Float:y, Float:angle, Float:distance) {
- x += (distance * floatsin(-angle, degrees));
- y += (distance * floatcos(-angle, degrees));
- }
- stock CreateBazooka( playerid, Float:x, Float:y, Float:z, Float:a )
- {
- for( new i = 0; i != MAX_BAZOOKAS; i++ )
- {
- if( BazInfo[i][bCreated] == 0 )
- {
- new szName[24];
- GetPlayerName( playerid, szName, 24 );
- BazInfo[i][bCreated] = 1;
- BazInfo[i][bx] = x+0.5;
- BazInfo[i][by] = y+0.5;
- BazInfo[i][bz] = z-0.17;
- BazInfo[i][bmx] = x;
- BazInfo[i][bmy] = y;
- BazInfo[i][bmz] = z-0.17;
- GetXYInFrontOfPoint( BazInfo[i][bmx], BazInfo[i][bmy], BazInfo[i][ba], 1.3 );
- BazInfo[i][ba] = a;
- BazInfo[i][bBeingUsed] = -1;
- BazInfo[i][bMissil] = -1;
- BazInfo[i][bObject] = CreateObject( 2600, BazInfo[i][bx], BazInfo[i][by], BazInfo[i][bz], 0, 0, a);
- format( BazInfo[i][bPlacedBy], 32, "%s", szName );
- new year, month, day, hour, minute, second;
- gettime( hour, minute, second );
- getdate( year, month, day );
- format( BazInfo[i][bDate], 64, "date: %d-%d-%d | time: %d-%d-%d", year, month, day, hour, minute, second );
- break;
- }
- else
- continue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement