Advertisement
Hauke

h_interiors_og1.1

Jul 31st, 2011
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.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 METHOD_KEY 0
  35. #define METHOD_PICKUP 1
  36.  
  37. forward ResetInterior ( playerid );
  38. 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 );
  39. forward __RemoveInterior ( interior );
  40.  
  41. enum Interior {
  42.     GetInMessage[ 64 ],
  43.     InVirtualWorld,
  44.     InInteriorID,
  45.     Float:InX,
  46.     Float:InY,
  47.     Float:InZ,
  48.     Float:InAngle,
  49.     InPickupType,
  50.     InPickupModel,
  51.     InGameTextStyle,
  52.     InAllowKey,
  53.     GetOutMessage[ 64 ],
  54.     OutVirtualWorld,
  55.     OutInteriorID,
  56.     Float:OutX,
  57.     Float:OutY,
  58.     Float:OutZ,
  59.     Float:OutAngle,
  60.     OutPickupType,
  61.     OutPickupModel,
  62.     OutGameTextStyle,
  63.     OutAllowKey
  64. }
  65.  
  66. new const Interiors[ INTERIOR_QUANTITY ][ Interior ];
  67. new Interior_Pickups[ INTERIOR_QUANTITY ][ 2 ] , LastInterior[ MAX_PLAYERS ];
  68.  
  69. 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 ) {
  70.     new interior = GetFreeSlot ( );
  71.     if ( interior == NULL )
  72.         return -1;
  73.     format ( Interiors[ interior ][ GetInMessage ] , 64 , iM );
  74.     Interiors[ interior ][ InVirtualWorld ] = iVW == NULL ? STANDARD_VIRTUALWORLD : iVW;
  75.     Interiors[ interior ][ InInteriorID ] = iI;
  76.     Interiors[ interior ][ InX ] = iX;
  77.     Interiors[ interior ][ InY ] = iY;
  78.     Interiors[ interior ][ InZ ] = iZ;
  79.     Interiors[ interior ][ InAngle ] = iA;
  80.     Interiors[ interior ][ InPickupType ] = iPT;
  81.     Interiors[ interior ][ InPickupModel ] = iPM;
  82.     Interiors[ interior ][ InGameTextStyle ] = iG;
  83.     Interiors[ interior ][ InAllowKey ] = iAK;
  84.     format ( Interiors [ interior ][ GetOutMessage ] , 64 , oM );
  85.     Interiors[ interior ][ OutVirtualWorld ] = oVW;
  86.     Interiors[ interior ][ OutInteriorID ] = oI;
  87.     Interiors[ interior ][ OutX ] = oX;
  88.     Interiors[ interior ][ OutY ] = oY;
  89.     Interiors[ interior ][ OutZ ] = oZ;
  90.     Interiors[ interior ][ OutAngle ] = oA;
  91.     Interiors[ interior ][ OutPickupType ] = oPT;
  92.     Interiors[ interior ][ OutPickupModel ] = oPM;
  93.     Interiors[ interior ][ OutGameTextStyle ] = oG;
  94.     Interiors[ interior ][ OutAllowKey ] = oAK;
  95.     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;
  96.     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;
  97.     return interior;
  98. }
  99.  
  100. public __RemoveInterior ( interior ) {
  101.     if ( !IsInterior ( interior ) )
  102.         return false;
  103.     DestroyPickup ( Interior_Pickups[ interior ][ 0 ] - OFFSET );
  104.     DestroyPickup ( Interior_Pickups[ interior ][ 1 ] - OFFSET );
  105.     Interior_Pickups[ interior ][ 0 ] = 0;
  106.     return true;
  107. }
  108.  
  109. public OnFilterScriptInit ( ) {
  110.     printf ( "    H Interiors is loading..." );
  111.     #if WAIT_TIME < 500
  112.         printf ( "    H_Interiors: FilterScript is set incorrectly!  ( WAIT_TIME is less than 500 )" );
  113.         SendRconCommand ( "exit" );
  114.     #endif
  115.     #if OFFSET < 1
  116.         printf ( "    H_Interiors: FilterScript is set incorrectly!  ( OFFSET is less than 1 )" );
  117.         SendRconCommand ( "exit" );
  118.     #endif
  119.     printf ( "    H Interiors was setted up correctly and was started now!" );
  120. }
  121.  
  122. public OnPlayerPickUpPickup ( playerid , pickupid )
  123.     for ( new interior; interior < sizeof Interiors; interior++ )
  124.         if ( Interior_Pickups[ interior ][ 0 ] == pickupid + OFFSET && LastInterior[ playerid ] != interior + OFFSET && IsInterior ( interior ) ) {
  125.             if ( CallEmulatedCallback ( "OnPlayerEnterInterior" , playerid , interior , METHOD_PICKUP ) == 1 ) {
  126.                 GoInInterior ( playerid , interior );
  127.                 CallEmulatedCallback ( "OnPlayerEnteredInterior" , playerid , interior , METHOD_PICKUP );
  128.             }
  129.             break;
  130.         }
  131.         else if ( Interior_Pickups[ interior ][ 1 ] == pickupid + OFFSET && LastInterior[ playerid ] != interior + OFFSET && IsInterior ( interior ) ) {
  132.             if ( CallEmulatedCallback ( "OnPlayerLeaveInterior" , playerid , interior , METHOD_PICKUP ) == 1 ) {
  133.                 GoOutInterior ( playerid , interior );
  134.                 CallEmulatedCallback ( "OnPlayerLeavedInterior" , playerid , interior , METHOD_PICKUP );
  135.             }
  136.             break;
  137.         }
  138.  
  139. public OnPlayerKeyStateChange ( playerid , newkeys , oldkeys )
  140.     if(newkeys & KEY_SECONDARY_ATTACK)
  141.         for ( new interior; interior < sizeof Interiors; interior++ )
  142.             if ( IsPlayerInRangeOfPoint ( playerid , 2 , Interiors[ interior ][ InX ], Interiors[ interior ][ InY ], Interiors[ interior ][ InZ ] ) && Interiors[ interior ][ OutAllowKey ] && GetPlayerVirtualWorld ( playerid ) == Interiors[ interior ][ InVirtualWorld ] && IsInterior ( interior ) ) {
  143.                 if ( CallEmulatedCallback ( "OnPlayerEnterInterior" , playerid , interior , METHOD_KEY ) == 1 ) {
  144.                     GoInInterior ( playerid , interior );
  145.                     CallEmulatedCallback ( "OnPlayerEnteredInterior" , playerid , interior , METHOD_KEY );
  146.                 }
  147.             }
  148.             else if ( IsPlayerInRangeOfPoint ( playerid , 2 , Interiors[ interior ][ OutX ], Interiors[ interior ][ OutY ], Interiors[ interior ][ OutZ ] ) && Interiors[ interior ][ InAllowKey ] && GetPlayerVirtualWorld ( playerid ) == Interiors[ interior ][ OutVirtualWorld ] && IsInterior ( interior ) )
  149.                 if ( CallEmulatedCallback ( "OnPlayerLeaveInterior" , playerid , interior , METHOD_KEY ) == 1 ) {
  150.                     GoOutInterior ( playerid , interior );
  151.                     CallEmulatedCallback ( "OnPlayerLeavedInterior" , playerid , interior , METHOD_KEY );
  152.                 }
  153.  
  154. public ResetInterior ( playerid )
  155.     return LastInterior[ playerid ] = 0 - ( OFFSET + 1 );
  156.  
  157. stock GoInInterior ( playerid , interior ) {
  158.     new msg[128];
  159.     if ( Interiors[ interior ][ InAllowKey ] )
  160.         format ( msg , 128 , "%s~n~~y~%s" , Interiors[ interior ][ GetInMessage ] , LANG );
  161.     else
  162.         format ( msg , 128 , Interiors[ interior ][ GetInMessage ] );
  163.     LastInterior[ playerid ] = interior + OFFSET;
  164.     SetPlayerInterior ( playerid , ( Interiors[ interior ][ OutInteriorID ] == NULL ) ? STANDARD_INTERIOR : Interiors[ interior ][ OutInteriorID ] );
  165.     SetPlayerPos ( playerid , Interiors[ interior ][ OutX ] , Interiors[ interior ][ OutY ] , Interiors[ interior ][ OutZ ] );
  166.     SetPlayerFacingAngle ( playerid , Interiors[ interior ][ OutAngle ] );
  167.     SetPlayerVirtualWorld ( playerid , Interiors[ interior ][ OutVirtualWorld ] );
  168.     GameTextForPlayer ( playerid , msg , WAIT_TIME - 500 , Interiors[ interior ][ OutGameTextStyle ] == NULL ? STANDARD_GAMETEXTSTYLE : Interiors[ interior ][ OutGameTextStyle ] );
  169.     SetTimerEx ( "ResetInterior" , WAIT_TIME , 0 , "i" , playerid );
  170. }
  171.  
  172. stock GoOutInterior ( playerid , interior ) {
  173.     new msg[128];
  174.     if ( Interiors[ interior ][ OutAllowKey ] )
  175.         format ( msg , 128 , "%s~n~~y~%s" , Interiors[ interior ][ GetOutMessage ] , LANG );
  176.     else
  177.         format ( msg , 128 , Interiors[ interior ][ GetInMessage ] );
  178.     LastInterior[ playerid ] = interior + OFFSET;
  179.     SetPlayerInterior ( playerid , ( Interiors[ interior ][ InInteriorID ] == NULL ) ? STANDARD_INTERIOR : Interiors[ interior ][ InInteriorID ] );
  180.     SetPlayerPos ( playerid , Interiors[ interior ][ InX ] , Interiors[ interior ][ InY ] , Interiors[ interior ][ InZ ] );
  181.     SetPlayerFacingAngle ( playerid , Interiors[ interior ][ InAngle ] );
  182.     SetPlayerVirtualWorld ( playerid , Interiors[ interior ][ InVirtualWorld ] );
  183.     GameTextForPlayer ( playerid , msg , WAIT_TIME - 500 , Interiors[ interior ][ InGameTextStyle ] == NULL ? STANDARD_GAMETEXTSTYLE : Interiors[ interior ][ InGameTextStyle ] );
  184.     SetTimerEx ( "ResetInterior" , WAIT_TIME , 0 , "i" , playerid );
  185. }
  186.  
  187. stock GetFreeSlot ( ) {
  188.     for ( new interior; interior < sizeof Interiors; interior++ )
  189.         if ( !Interior_Pickups[ interior ][ 0 ] )
  190.             return interior;
  191.     return NULL;
  192. }
  193.  
  194. stock IsInterior ( interior )
  195.     return Interior_Pickups[ interior ][ 0 ] ? true : false;
  196.    
  197. stock CallEmulatedCallback ( callback [ ] , playerid , interior , method )
  198.     return CallRemoteFunction ( callback , "ddd" , playerid , interior , method ) == 1 ? true : false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement