Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2012
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.83 KB | None | 0 0
  1. /*
  2.  
  3. IEE 1.2 by Mike (MP2)
  4.  
  5.  
  6. ### Changelog ###
  7.  
  8. 1.2:
  9. - No longer using y_hooks include
  10. - Added 'OnPlayerEnterExitInterior' callback (OnPlayerEnterExitInterior(playerid, enterexitid, oldinterior, newinterior, Float:x, Float:y, Float:z))
  11. - returning 0 in OnPlayerEnterExitInterior will disable the teleport.
  12.  
  13. 1.1:
  14. - Now using y_hooks to hook callbacks
  15. - Fixed an issue with using your own pickups alongside this include
  16. - 'world2' parameter in CreateEnterExit now set to -1 by default.
  17.   This will prevent the player's world being changed on teleport
  18.  
  19. 1.0:
  20.  - Initial release
  21.  
  22. */
  23.  
  24. // The 3 lines here will allow you to type "CreateEnterExit(" into pawno and a message will apear with the parameters in - useful as there's quite a few parameters
  25. /*
  26. native CreateEnterExit(ieeworld, Float:ieex, Float:ieey, Float:ieez, Float:ieex2, Float:ieey2, Float:ieez2, Float:ieea, ieeinterior, ieeworld2, ieemsg[] = "", ieemodel=19198);
  27. native DeleteEnterExit(iee_id);
  28. native IsEnterExitCreated(iee_id);
  29. */
  30.  
  31. forward OnPlayerEnterExitInterior(playerid, enterexitid, oldinterior, newinterior, Float:x, Float:y, Float:z);
  32.  
  33. #define IEE_COLOR 0xFFFFFFFF // Color for messages
  34. #define PICKUP_HEIGHT_ADDITION 0.4 // Perfect height for using /save to get coordinates
  35. #define MAX_IEE 500 // Maximum number of interior enter/exits
  36.  
  37. enum iee_enum
  38. {
  39.     iee_created, // Stored whether a pickup 'slot' is used
  40.     iee_pickupid, // The ID of the pickup
  41.     Float:iee_x, // Coordinate of teleport
  42.     Float:iee_y, // Coordinate of teleport
  43.     Float:iee_z, // Coordinate of teleport
  44.     Float:iee_a, // Angle of teleport
  45.     iee_int, // Interior of teleport
  46.     iee_world, // World of teleport
  47.     iee_msg[128] // A message to display to players when they enter the pickup
  48. };
  49.  
  50. new iee_data[MAX_IEE][iee_enum];
  51.  
  52. public OnPlayerPickUpPickup(playerid, pickupid)
  53. {
  54.     for(new i=0; i<MAX_IEE; i++) // Loop through all IEE slots
  55.     {
  56.         if(iee_data[i][iee_pickupid] == pickupid && iee_data[i][iee_created]) // Found
  57.         {
  58.             if(CallLocalFunction("OnPlayerEnterExitInterior", "iiiifff", playerid, i, GetPlayerInterior(playerid), iee_data[i][iee_int], iee_data[i][iee_x], iee_data[i][iee_y], iee_data[i][iee_z]) || funcidx("OnPlayerEnterExitInterior") == -1)
  59.             // If you return 0 in OnPlayerEnterExitInterior, the player will not be teleported. If you return nothing in that callback, the same applies.
  60.             {
  61.                 SetPlayerPos(playerid, iee_data[i][iee_x], iee_data[i][iee_y], iee_data[i][iee_z]);
  62.                 SetPlayerFacingAngle(playerid, iee_data[i][iee_a]);
  63.                 SetPlayerInterior(playerid, iee_data[i][iee_int]);
  64.                 if(iee_data[i][iee_world] != -1) SetPlayerVirtualWorld(playerid, iee_data[i][iee_world]); // Only change world if one was set
  65.                 SetCameraBehindPlayer(playerid);
  66.                 if(strlen(iee_data[i][iee_msg])) SendClientMessage(playerid, IEE_COLOR, iee_data[i][iee_msg]);
  67.             }
  68.             return 1;
  69.         }
  70.     }
  71.     return CallLocalFunction("iee_OnPlayerPickUpPickup", "ii", playerid, pickupid); // Hooking method
  72. }
  73.  
  74. #if defined _ALS_OnPlayerPickUpPickup
  75.     #undef OnPlayerPickUpPickup
  76. #else
  77.     #define _ALS_OnPlayerPickUpPickup
  78. #endif
  79. #define OnPlayerPickUpPickup iee_OnPlayerPickUpPickup
  80. forward iee_OnPlayerPickUpPickup(playerid, pickupid);
  81.  
  82. /*  CreateEnterExit
  83.  
  84.     ieeworld - The virtual world that the pickup is shown in
  85.     Float:ieex, Float:ieey, Float:ieez - The coordinates at which to create the pickup
  86.     Float:ieex2, Float:ieey2, Float:ieez2 - The coordinates of where the teleport players that enter the pickup
  87.     Float:ieea - The angle at which to set for the player when teleported
  88.     ieeinterior - The interior to set when players teleport
  89.     ieeworld2 - The world to set when players teleport (use for interiors used for several exteriors)
  90.     ieemsg - A message to display to players when they enter the pickup (leave blank ( "" ) to disable)
  91.     ieemodel=19198 - Custom object model for the pickup (defaults to the yellow cone)
  92.  
  93.     RETURNS:
  94.         This function returns the 'slot' that the pickup was assigned to, or -1 if the limit (MAX_IEE) was reached.
  95. */
  96.  
  97. stock CreateEnterExit(ieeworld, Float:ieex, Float:ieey, Float:ieez, Float:ieex2, Float:ieey2, Float:ieez2, Float:ieea, ieeinterior, ieeworld2 = -1, ieemsg[] = "", ieemodel=19198)
  98. {
  99.     for(new i=0; i<MAX_IEE; i++)
  100.     {
  101.         if(iee_data[i][iee_created]) continue;
  102.         if(ieemodel == 19198) iee_data[i][iee_pickupid] = CreatePickup(ieemodel, 1, ieex, ieey, ieez+PICKUP_HEIGHT_ADDITION, ieeworld);
  103.         else iee_data[i][iee_pickupid] = CreatePickup(ieemodel, 1, ieex, ieey, ieez, ieeworld);
  104.         iee_data[i][iee_x] = ieex2;
  105.         iee_data[i][iee_y] = ieey2;
  106.         iee_data[i][iee_z] = ieez2;
  107.         iee_data[i][iee_a] = ieea;
  108.         iee_data[i][iee_int] = ieeinterior;
  109.         iee_data[i][iee_world] = ieeworld2;
  110.         format(iee_data[i][iee_msg], 128, "%s", ieemsg);
  111.        
  112.         iee_data[i][iee_created] = 1;
  113.         return i;
  114.     }
  115.     return -1;
  116. }
  117.  
  118. /*  DeleteEnterExit
  119.  
  120.     iee_id - The ID of the enter/exit to delete (returned by CreateEnterExit)
  121.  
  122.     RETURNS:
  123.         This function returns 1 if the enter/exit was deleted or 0 if it did not exist
  124.  
  125.  
  126. */
  127.  
  128. stock DeleteEnterExit(iee_id)
  129. {
  130.     if(iee_id > MAX_IEE-1) return 0;
  131.     if(iee_data[iee_id][iee_created] == 0) return 0;
  132.     DestroyPickup(iee_data[iee_id][iee_pickupid]);
  133.     iee_data[iee_id][iee_created] = 0;
  134.     return 1;
  135. }
  136.  
  137. /*  IsEnterExitCreated
  138.  
  139.     iee_id - The ID of the enter/exit to check for existance
  140.  
  141.     RETURNS:
  142.         This function returns 1 if the enter/exit exists or 0 if not
  143.  
  144.  
  145. */
  146.  
  147. stock IsEnterExitCreated(iee_id)
  148. {
  149.     if(iee_id > MAX_IEE-1) return 0;
  150.     if(iee_data[iee_id][iee_created] == 0) return 0;
  151.     return 1;
  152. }
  153.  
  154. // Internal
  155.  
  156. stock iee_close() // Destroys all interior enter/exits - place " iee_close(); " under your OnGameModeExit callback.
  157. {
  158.     for(new i=0; i<MAX_IEE; i++) // Loop through all IEE slots
  159.     {
  160.         if(iee_data[i][iee_created]) // Found
  161.         {
  162.             DestroyPickup(iee_data[i][iee_pickupid]);
  163.         }
  164.     }
  165.     return 1;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement