Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- h_interiors 1.0, 31.07.2011, by Hauke Marquardt alias |-|auke
- This code is free: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- You´re not allowed to copy any code from this, into your code without
- naming authors name in credits!
- */
- //========== Custom setup
- #define INTERIOR_QUANTITY 10 /* Number of maximal Interiors */
- #define LANG "Press ENTER to return" /* shown message if pickup is usable on key ENTER */
- #define WAIT_TIME 1000 /* Textdraw and pickup-locktime in milliseconds */
- //========== Additional setup
- #define STANDARD_PICKUPMODEL 1318
- #define STANDARD_PICKUPTYPE 3
- #define STANDARD_INTERIOR 0
- #define STANDARD_VIRTUALWORLD 0
- #define STANDARD_GAMETEXTSTYLE 1
- #define _CreatePickup CreatePickup /* must return specific id! */
- //========== Developer setup
- #include <a_samp>
- #define OFFSET 16235277 /* in H Coder - extrem trinary "H" */
- #define NULL -1
- #define DIALOG_IDS 432
- forward ResetInterior ( playerid );
- forward __AddInterior ( iM[ ] , iVW , iI , Float:iX , Float:iY , Float:iZ , Float:iA , iPT , iPM , iG , iAK , oM[ ] , oVW , oI , Float:oX , Float:oY , Float:oZ , Float:oA , oPT , oPM , oG , oAK );
- forward __RemoveInterior ( interior );
- enum Interior {
- GetInMessage[ 64 ],
- InVirtualWorld,
- InInteriorID,
- Float:InX,
- Float:InY,
- Float:InZ,
- Float:InAngle,
- InPickupType,
- InPickupModel,
- InGameTextStyle,
- InAllowKey,
- GetOutMessage[ 64 ],
- OutVirtualWorld,
- OutInteriorID,
- Float:OutX,
- Float:OutY,
- Float:OutZ,
- Float:OutAngle,
- OutPickupType,
- OutPickupModel,
- OutGameTextStyle,
- OutAllowKey
- }
- new const Interiors[ INTERIOR_QUANTITY ][ Interior ];
- new Interior_Pickups[ INTERIOR_QUANTITY ][ 2 ] , LastInterior[ MAX_PLAYERS ];
- public __AddInterior ( iM[ ] , iVW , iI , Float:iX , Float:iY , Float:iZ , Float:iA , iPT , iPM , iG , iAK , oM[ ] , oVW , oI , Float:oX , Float:oY , Float:oZ , Float:oA , oPT , oPM , oG , oAK ) {
- new interior = GetFreeSlot ( );
- if ( interior == NULL )
- return -1;
- format ( Interiors[ interior ][ GetInMessage ] , 64 , iM );
- Interiors[ interior ][ InVirtualWorld ] = iVW == NULL ? STANDARD_VIRTUALWORLD : iVW;
- Interiors[ interior ][ InInteriorID ] = iI;
- Interiors[ interior ][ InX ] = iX;
- Interiors[ interior ][ InY ] = iY;
- Interiors[ interior ][ InZ ] = iZ;
- Interiors[ interior ][ InAngle ] = iA;
- Interiors[ interior ][ InPickupType ] = iPT;
- Interiors[ interior ][ InPickupModel ] = iPM;
- Interiors[ interior ][ InGameTextStyle ] = iG;
- Interiors[ interior ][ InAllowKey ] = iAK;
- format ( Interiors [ interior ][ GetOutMessage ] , 64 , oM );
- Interiors[ interior ][ OutVirtualWorld ] = oVW;
- Interiors[ interior ][ OutInteriorID ] = oI;
- Interiors[ interior ][ OutX ] = oX;
- Interiors[ interior ][ OutY ] = oY;
- Interiors[ interior ][ OutZ ] = oZ;
- Interiors[ interior ][ OutAngle ] = oA;
- Interiors[ interior ][ OutPickupType ] = oPT;
- Interiors[ interior ][ OutPickupModel ] = oPM;
- Interiors[ interior ][ OutGameTextStyle ] = oG;
- Interiors[ interior ][ OutAllowKey ] = oAK;
- Interior_Pickups[ interior ][ 0 ] = _CreatePickup ( ( Interiors[ interior ][ InPickupModel ] == NULL ) ? STANDARD_PICKUPMODEL : Interiors[ interior ][ InPickupModel ] , ( Interiors[ interior ][ InPickupType ] == NULL ) ? STANDARD_PICKUPTYPE : Interiors[ interior ][ InPickupType ] , Interiors[ interior ][ InX ] , Interiors[ interior ][ InY ] , Interiors[ interior ][ InZ ] , Interiors[ interior ][ OutVirtualWorld ] ) + OFFSET;
- Interior_Pickups[ interior ][ 1 ] = _CreatePickup ( ( Interiors[ interior ][ OutPickupModel ] == NULL ) ? STANDARD_PICKUPMODEL : Interiors[ interior ][ OutPickupModel ] , ( Interiors[ interior ][ OutPickupType ] == NULL ) ? STANDARD_PICKUPTYPE : Interiors[ interior ][ OutPickupType ] , Interiors[ interior ][ OutX ] , Interiors[ interior ][ OutY ] , Interiors[ interior ][ OutZ ] , Interiors[ interior ][ InVirtualWorld ] ) + OFFSET;
- return interior;
- }
- public __RemoveInterior ( interior ) {
- if ( !IsInterior ( interior ) )
- return false;
- DestroyPickup ( Interior_Pickups[ interior ][ 0 ] - OFFSET );
- DestroyPickup ( Interior_Pickups[ interior ][ 1 ] - OFFSET );
- Interior_Pickups[ interior ][ 0 ] = 0;
- return true;
- }
- public OnFilterScriptInit ( ) {
- printf ( " H Interiors is loading..." );
- #if WAIT_TIME < 500
- printf ( " H_Interiors: FilterScript is set incorrectly! ( WAIT_TIME is less than 500 )" );
- SendRconCommand ( "exit" );
- #endif
- #if OFFSET < 1
- printf ( " H_Interiors: FilterScript is set incorrectly! ( OFFSET is less than 1 )" );
- SendRconCommand ( "exit" );
- #endif
- printf ( " H Interiors was setted up correctly and was started now!" );
- }
- public OnFilterScriptExit ( ) {
- return 1;
- }
- public OnPlayerPickUpPickup ( playerid , pickupid )
- for ( new interior; interior < sizeof Interiors; interior++ )
- if ( Interior_Pickups[ interior ][ 0 ] == pickupid + OFFSET && LastInterior[ playerid ] != interior + OFFSET && IsInterior ( interior ) ) {
- GoInInterior ( playerid , interior );
- break;
- }
- else if ( Interior_Pickups[ interior ][ 1 ] == pickupid + OFFSET && LastInterior[ playerid ] != interior + OFFSET && IsInterior ( interior ) ) {
- GoOutInterior ( playerid , interior );
- break;
- }
- public OnPlayerKeyStateChange ( playerid , newkeys , oldkeys )
- if(newkeys & KEY_SECONDARY_ATTACK)
- for ( new interior; interior < sizeof Interiors; interior++ )
- if ( IsPlayerInRangeOfPoint ( playerid , 2 , Interiors[ interior ][ InX ], Interiors[ interior ][ InY ], Interiors[ interior ][ InZ ] ) && Interiors[ interior ][ OutAllowKey ] && GetPlayerVirtualWorld ( playerid ) == Interiors[ interior ][ InVirtualWorld ] && IsInterior ( interior ) )
- GoInInterior ( playerid , interior );
- else if ( IsPlayerInRangeOfPoint ( playerid , 2 , Interiors[ interior ][ OutX ], Interiors[ interior ][ OutY ], Interiors[ interior ][ OutZ ] ) && Interiors[ interior ][ InAllowKey ] && GetPlayerVirtualWorld ( playerid ) == Interiors[ interior ][ OutVirtualWorld ] && IsInterior ( interior ) )
- GoOutInterior ( playerid , interior );
- public ResetInterior ( playerid )
- return LastInterior[ playerid ] = 0 - ( OFFSET + 1 );
- stock GoInInterior ( playerid , interior ) {
- new msg[128];
- if ( Interiors[ interior ][ InAllowKey ] )
- format ( msg , 128 , "%s~n~~y~%s" , Interiors[ interior ][ GetInMessage ] , LANG );
- else
- format ( msg , 128 , Interiors[ interior ][ GetInMessage ] );
- LastInterior[ playerid ] = interior + OFFSET;
- SetPlayerInterior ( playerid , ( Interiors[ interior ][ OutInteriorID ] == NULL ) ? STANDARD_INTERIOR : Interiors[ interior ][ OutInteriorID ] );
- SetPlayerPos ( playerid , Interiors[ interior ][ OutX ] , Interiors[ interior ][ OutY ] , Interiors[ interior ][ OutZ ] );
- SetPlayerFacingAngle ( playerid , Interiors[ interior ][ OutAngle ] );
- SetPlayerVirtualWorld ( playerid , Interiors[ interior ][ OutVirtualWorld ] );
- GameTextForPlayer ( playerid , msg , WAIT_TIME - 500 , ( Interiors[ interior ][ OutGameTextStyle ] == NULL ) ? STANDARD_GAMETEXTSTYLE : Interiors[ interior ][ OutGameTextStyle ] );
- SetTimerEx ( "ResetInterior" , WAIT_TIME , 0 , "i" , playerid );
- }
- stock GoOutInterior ( playerid , interior ) {
- new msg[128];
- if ( Interiors[ interior ][ OutAllowKey ] )
- format ( msg , 128 , "%s~n~~y~%s" , Interiors[ interior ][ GetOutMessage ] , LANG );
- else
- format ( msg , 128 , Interiors[ interior ][ GetInMessage ] );
- LastInterior[ playerid ] = interior + OFFSET;
- SetPlayerInterior ( playerid , ( Interiors[ interior ][ InInteriorID ] == NULL ) ? STANDARD_INTERIOR : Interiors[ interior ][ InInteriorID ] );
- SetPlayerPos ( playerid , Interiors[ interior ][ InX ] , Interiors[ interior ][ InY ] , Interiors[ interior ][ InZ ] );
- SetPlayerFacingAngle ( playerid , Interiors[ interior ][ InAngle ] );
- SetPlayerVirtualWorld ( playerid , Interiors[ interior ][ InVirtualWorld ] );
- GameTextForPlayer ( playerid , msg , WAIT_TIME - 500 , ( Interiors[ interior ][ InGameTextStyle ] == NULL ) ? STANDARD_GAMETEXTSTYLE : Interiors[ interior ][ InGameTextStyle ] );
- SetTimerEx ( "ResetInterior" , WAIT_TIME , 0 , "i" , playerid );
- }
- stock GetFreeSlot ( ) {
- for ( new interior; interior < sizeof Interiors; interior++ )
- if ( !Interior_Pickups[ interior ][ 0 ] )
- return interior;
- return NULL;
- }
- stock IsInterior ( interior )
- return Interior_Pickups[ interior ][ 0 ] ? true : false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement