Advertisement
Guest User

Untitled

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