Advertisement
Hauke

h_interiors_og

Jul 31st, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.94 KB | None | 0 0
  1. /*
  2.     h_interiors 1.0, 31.07.2011, by Hauke Marquardt alias |-|auke
  3.  
  4.     This code is free: you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation, either version 3 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This code is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16.     You´re not allowed to copy any code from this, into your code without
  17.     naming authors name in credits!
  18. */
  19. //========== Custom setup
  20. #define INTERIOR_QUANTITY 10                /* Number of maximal Interiors */
  21. #define LANG "Press ENTER to return"        /* shown message if pickup is usable on key ENTER */
  22. #define WAIT_TIME 1000                      /* Textdraw and pickup-locktime in milliseconds */
  23. //========== Additional setup
  24. #define STANDARD_PICKUPMODEL 1318
  25. #define STANDARD_PICKUPTYPE 3
  26. #define STANDARD_INTERIOR 0
  27. #define STANDARD_VIRTUALWORLD 0
  28. #define STANDARD_GAMETEXTSTYLE 1
  29. #define _CreatePickup CreatePickup          /* must return specific id! */
  30. //========== Developer setup
  31. #include <a_samp>
  32. #define OFFSET 16235277                     /* in H Coder - extrem trinary "H" */
  33. #define NULL -1
  34. #define DIALOG_IDS 432
  35.  
  36. forward ResetInterior ( playerid );
  37. 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 );
  38. forward __RemoveInterior ( interior );
  39.  
  40. enum Interior {
  41.     GetInMessage[ 64 ],
  42.     InVirtualWorld,
  43.     InInteriorID,
  44.     Float:InX,
  45.     Float:InY,
  46.     Float:InZ,
  47.     Float:InAngle,
  48.     InPickupType,
  49.     InPickupModel,
  50.     InGameTextStyle,
  51.     InAllowKey,
  52.     GetOutMessage[ 64 ],
  53.     OutVirtualWorld,
  54.     OutInteriorID,
  55.     Float:OutX,
  56.     Float:OutY,
  57.     Float:OutZ,
  58.     Float:OutAngle,
  59.     OutPickupType,
  60.     OutPickupModel,
  61.     OutGameTextStyle,
  62.     OutAllowKey
  63. }
  64.  
  65. new const Interiors[ INTERIOR_QUANTITY ][ Interior ];
  66. new Interior_Pickups[ INTERIOR_QUANTITY ][ 2 ] , LastInterior[ MAX_PLAYERS ];
  67.  
  68. 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 ) {
  69.     new interior = GetFreeSlot ( );
  70.     if ( interior == NULL )
  71.         return -1;
  72.     format ( Interiors[ interior ][ GetInMessage ] , 64 , iM );
  73.     Interiors[ interior ][ InVirtualWorld ] = iVW == NULL ? STANDARD_VIRTUALWORLD : iVW;
  74.     Interiors[ interior ][ InInteriorID ] = iI;
  75.     Interiors[ interior ][ InX ] = iX;
  76.     Interiors[ interior ][ InY ] = iY;
  77.     Interiors[ interior ][ InZ ] = iZ;
  78.     Interiors[ interior ][ InAngle ] = iA;
  79.     Interiors[ interior ][ InPickupType ] = iPT;
  80.     Interiors[ interior ][ InPickupModel ] = iPM;
  81.     Interiors[ interior ][ InGameTextStyle ] = iG;
  82.     Interiors[ interior ][ InAllowKey ] = iAK;
  83.     format ( Interiors [ interior ][ GetOutMessage ] , 64 , oM );
  84.     Interiors[ interior ][ OutVirtualWorld ] = oVW;
  85.     Interiors[ interior ][ OutInteriorID ] = oI;
  86.     Interiors[ interior ][ OutX ] = oX;
  87.     Interiors[ interior ][ OutY ] = oY;
  88.     Interiors[ interior ][ OutZ ] = oZ;
  89.     Interiors[ interior ][ OutAngle ] = oA;
  90.     Interiors[ interior ][ OutPickupType ] = oPT;
  91.     Interiors[ interior ][ OutPickupModel ] = oPM;
  92.     Interiors[ interior ][ OutGameTextStyle ] = oG;
  93.     Interiors[ interior ][ OutAllowKey ] = oAK;
  94.     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;
  95.     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;
  96.     return interior;
  97. }
  98.  
  99. public __RemoveInterior ( interior ) {
  100.     if ( !IsInterior ( interior ) )
  101.         return false;
  102.     DestroyPickup ( Interior_Pickups[ interior ][ 0 ] - OFFSET );
  103.     DestroyPickup ( Interior_Pickups[ interior ][ 1 ] - OFFSET );
  104.     Interior_Pickups[ interior ][ 0 ] = 0;
  105.     return true;
  106. }
  107.  
  108. public OnFilterScriptInit ( ) {
  109.     printf ( "    H Interiors is loading..." );
  110.     #if WAIT_TIME < 500
  111.         printf ( "    H_Interiors: FilterScript is set incorrectly!  ( WAIT_TIME is less than 500 )" );
  112.         SendRconCommand ( "exit" );
  113.     #endif
  114.     #if OFFSET < 1
  115.         printf ( "    H_Interiors: FilterScript is set incorrectly!  ( OFFSET is less than 1 )" );
  116.         SendRconCommand ( "exit" );
  117.     #endif
  118.     printf ( "    H Interiors was setted up correctly and was started now!" );
  119. }
  120.  
  121. public OnFilterScriptExit ( ) {
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerPickUpPickup ( playerid , pickupid )
  126.     for ( new interior; interior < sizeof Interiors; interior++ )
  127.         if ( Interior_Pickups[ interior ][ 0 ] == pickupid + OFFSET && LastInterior[ playerid ] != interior + OFFSET && IsInterior ( interior ) ) {
  128.             GoInInterior ( playerid , interior );
  129.             break;
  130.         }
  131.         else if ( Interior_Pickups[ interior ][ 1 ] == pickupid + OFFSET && LastInterior[ playerid ] != interior + OFFSET && IsInterior ( interior ) ) {
  132.             GoOutInterior ( playerid , interior );
  133.             break;
  134.         }
  135.  
  136. public OnPlayerKeyStateChange ( playerid , newkeys , oldkeys )
  137.     if(newkeys & KEY_SECONDARY_ATTACK)
  138.         for ( new interior; interior < sizeof Interiors; interior++ )
  139.             if ( IsPlayerInRangeOfPoint ( playerid , 2 , Interiors[ interior ][ InX ], Interiors[ interior ][ InY ], Interiors[ interior ][ InZ ] ) && Interiors[ interior ][ OutAllowKey ] && GetPlayerVirtualWorld ( playerid ) == Interiors[ interior ][ InVirtualWorld ] && IsInterior ( interior ) )
  140.                 GoInInterior ( playerid , interior );
  141.             else if ( IsPlayerInRangeOfPoint ( playerid , 2 , Interiors[ interior ][ OutX ], Interiors[ interior ][ OutY ], Interiors[ interior ][ OutZ ] ) && Interiors[ interior ][ InAllowKey ] && GetPlayerVirtualWorld ( playerid ) == Interiors[ interior ][ OutVirtualWorld ] && IsInterior ( interior ) )
  142.                 GoOutInterior ( playerid , interior );
  143.  
  144. public ResetInterior ( playerid )
  145.     return LastInterior[ playerid ] = 0 - ( OFFSET + 1 );
  146.  
  147. stock GoInInterior ( playerid , interior ) {
  148.     new msg[128];
  149.     if ( Interiors[ interior ][ InAllowKey ] )
  150.         format ( msg , 128 , "%s~n~~y~%s" , Interiors[ interior ][ GetInMessage ] , LANG );
  151.     else
  152.         format ( msg , 128 , Interiors[ interior ][ GetInMessage ] );
  153.     LastInterior[ playerid ] = interior + OFFSET;
  154.     SetPlayerInterior ( playerid , ( Interiors[ interior ][ OutInteriorID ] == NULL ) ? STANDARD_INTERIOR : Interiors[ interior ][ OutInteriorID ] );
  155.     SetPlayerPos ( playerid , Interiors[ interior ][ OutX ] , Interiors[ interior ][ OutY ] , Interiors[ interior ][ OutZ ] );
  156.     SetPlayerFacingAngle ( playerid , Interiors[ interior ][ OutAngle ] );
  157.     SetPlayerVirtualWorld ( playerid , Interiors[ interior ][ OutVirtualWorld ] );
  158.     GameTextForPlayer ( playerid , msg , WAIT_TIME - 500 , ( Interiors[ interior ][ OutGameTextStyle ] == NULL ) ? STANDARD_GAMETEXTSTYLE : Interiors[ interior ][ OutGameTextStyle ] );
  159.     SetTimerEx ( "ResetInterior" , WAIT_TIME , 0 , "i" , playerid );
  160. }
  161.  
  162. stock GoOutInterior ( playerid , interior ) {
  163.     new msg[128];
  164.     if ( Interiors[ interior ][ OutAllowKey ] )
  165.         format ( msg , 128 , "%s~n~~y~%s" , Interiors[ interior ][ GetOutMessage ] , LANG );
  166.     else
  167.         format ( msg , 128 , Interiors[ interior ][ GetInMessage ] );
  168.     LastInterior[ playerid ] = interior + OFFSET;
  169.     SetPlayerInterior ( playerid , ( Interiors[ interior ][ InInteriorID ] == NULL ) ? STANDARD_INTERIOR : Interiors[ interior ][ InInteriorID ] );
  170.     SetPlayerPos ( playerid , Interiors[ interior ][ InX ] , Interiors[ interior ][ InY ] , Interiors[ interior ][ InZ ] );
  171.     SetPlayerFacingAngle ( playerid , Interiors[ interior ][ InAngle ] );
  172.     SetPlayerVirtualWorld ( playerid , Interiors[ interior ][ InVirtualWorld ] );
  173.     GameTextForPlayer ( playerid , msg , WAIT_TIME - 500 , ( Interiors[ interior ][ InGameTextStyle ] == NULL ) ? STANDARD_GAMETEXTSTYLE : Interiors[ interior ][ InGameTextStyle ] );
  174.     SetTimerEx ( "ResetInterior" , WAIT_TIME , 0 , "i" , playerid );
  175. }
  176.  
  177. stock GetFreeSlot ( ) {
  178.     for ( new interior; interior < sizeof Interiors; interior++ )
  179.         if ( !Interior_Pickups[ interior ][ 0 ] )
  180.             return interior;
  181.     return NULL;
  182. }
  183.  
  184. stock IsInterior ( interior )
  185.     return Interior_Pickups[ interior ][ 0 ] ? true : false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement