Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2013
1,357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.98 KB | None | 0 0
  1. /*
  2.  
  3. (  ___  )(  ____ \(  ____ \   ( \      \__   __/(  ____ \\__   __/
  4. | (   ) || (    \/| (    \/   | (         ) (   | (    \/   ) (
  5. | (___) || |      | |         | |         | |   | (__       | |
  6. |  ___  || |      | |         | |         | |   |  __)      | |
  7. | (   ) || |      | |         | |         | |   | (         | |
  8. | )   ( || (____/\| (____/\   | (____/\___) (___| )         | |
  9. |/     \|(_______/(_______/   (_______/\_______/|/          )_(
  10.  
  11. ACC_Lift filterscript for SA:MP 0.3d by Mike
  12.  
  13. Feel free to modify and distribute this as you wish.
  14.  
  15. Version: 1.0
  16.  
  17. Changelogs
  18.  
  19. 2.0:
  20.  
  21. - Moved to an include
  22. - Added defines for lift IDs (LIFT_MAIN and LIFT_SIDE)
  23. - Added an option to disable the test commands (/lift and /sidelift) - see USE_TRYME
  24. - TO-DO: Added sounds when lifts are moving
  25. - TO-DO: Added ACC_StopLift(lift) to stop a lift at it's current position
  26. - TO-DO: Added ACC_GetLiftPos(lift, &Float:liftx, &Float:lifty, &Float:liftz) - Returns the position of the lift object
  27. - TO-DO: Added ACC_DeleteLifts() - Deletes the lifts
  28. - TO-DO: Added ACC_GetLiftObjectID(lift) - Returns the object ID of the lifts
  29. - TO-DO: Updated for new MoveObject behaviour in 0.3d RC5
  30.  
  31. 1.0: Initial release.
  32.  
  33. */
  34.  
  35. #define REMOVE_OBJECTS // Removing this line will disable THIS SCRIPT from removing the default lifts. Please see the topic for this filterscript for more info
  36. #define USE_TRYME // Remove this line to disable /sidelift and /list (or comment it out)
  37.  
  38. #include <a_samp>
  39.  
  40. #define LIFT_STATUS_UP 0
  41. #define LIFT_STATUS_LOWERING 1
  42. #define LIFT_STATUS_RISING 2
  43. #define LIFT_STATUS_DOWN 3
  44.  
  45. #define LIFT_MAIN 0
  46. #define LIFT_SIDE 1
  47.  
  48. new lift_object_id[2];
  49. new lift_status[2];
  50.  
  51. new Float:lift_coords[2][6] = { // xyz for raised pos, xyz for lowered pos
  52. {-1456.700805, 501.301513, 16.903375, -1456.700805, 501.301513, 9.863378}, // Main lift
  53. {-1414.450439, 516.463256, 16.679367, -1414.450439, 516.463256, 9.649368} // Side lift
  54. };
  55.  
  56. public OnFilterScriptInit()
  57. {
  58.     #if defined REMOVE_OBJECTS
  59.     for(new i=0; i<GetMaxPlayers(); i++)
  60.     {
  61.         if(!IsPlayerConnected(i)) continue;
  62.         RemoveBuildingForPlayer(i, 3114, -1430.3319,503.3230,19.7853, 123); // Aircraft Carrier Lift
  63.         RemoveBuildingForPlayer(i, 3115, -1430.3319,503.3230,19.7853, 123); // Aircraft Carrier Lift
  64.     }
  65.     #endif
  66.    
  67.     lift_object_id[0] = CreateObject(3115, -1456.714721, 501.301513, 16.914375, 0.000000, 0.000000, 0.000000);
  68.     lift_object_id[1] = CreateObject(3114, -1414.450439, 516.463256, 16.679368, 0.000000, 0.000000, 0.000000);
  69.     return 1;
  70. }
  71.  
  72. public OnFilterScriptExit()
  73. {
  74.     DestroyObject(lift_object_id[0]);
  75.     DestroyObject(lift_object_id[1]);
  76.     return 1;
  77. }
  78.  
  79. public OnPlayerConnect(playerid)
  80. {
  81.     #if defined REMOVE_OBJECTS
  82.     RemoveBuildingForPlayer(playerid, 3114, -1430.3319,503.3230,19.7853, 123); // Aircraft Carrier Lift
  83.     RemoveBuildingForPlayer(playerid, 3115, -1430.3319,503.3230,19.7853, 123); // Aircraft Carrier Lift
  84.     #endif
  85.     return 1;
  86. }
  87.  
  88. stock ACC_MoveLift(lift, updown=-1, Float:speed=1.0)
  89. {
  90.     if(lift != 0 && lift != 1)
  91.     {
  92.         printf("Invalid lift ID passed to ACC_MoveLift (%i)", lift);
  93.         return -1;
  94.     }
  95.    
  96.     new Float:lift_speed = speed;
  97.     if(speed == 0.0) lift_speed = 1.0; // If speed was set to 0, set it to 1
  98.  
  99.     if(lift == 0)
  100.     {
  101.         switch(updown)
  102.         {
  103.             case -1: // Move depending on current status
  104.             {
  105.                 if(lift_status[0] == LIFT_STATUS_UP || lift_status[0] == LIFT_STATUS_RISING) // If it's rising or up
  106.                 {
  107.                     StopObject(lift_object_id[0]);
  108.                     MoveObject(lift_object_id[0], lift_coords[0][3], lift_coords[0][4], lift_coords[0][5], lift_speed); // Lower it
  109.                     lift_status[0] = LIFT_STATUS_LOWERING;
  110.                 }
  111.                 else // It's down or lowering, raise it
  112.                 {
  113.                     StopObject(lift_object_id[0]);
  114.                     MoveObject(lift_object_id[0], lift_coords[0][0], lift_coords[0][1], lift_coords[0][2], lift_speed); // Raise it
  115.                     lift_status[0] = LIFT_STATUS_RISING;
  116.                 }
  117.             }
  118.             case 0, 2: // Raise
  119.             {
  120.                 print("Raising.");
  121.             }
  122.             case 1, 3: // Lower
  123.             {
  124.                 print("Lowering.");
  125.             }
  126.             default: printf("Invalid 'updown' value passed to ACC_Move_Lift.", updown);
  127.         }
  128.     }
  129.     else
  130.     {
  131.         switch(updown)
  132.         {
  133.             case -1: // Move depending on current status
  134.             {
  135.                 if(lift_status[1] == LIFT_STATUS_UP || lift_status[1] == LIFT_STATUS_RISING) // If it's rising or up
  136.                 {
  137.                     StopObject(lift_object_id[1]);
  138.                     MoveObject(lift_object_id[1], lift_coords[1][3], lift_coords[1][4], lift_coords[1][5], lift_speed); // Lower it
  139.                     lift_status[1] = LIFT_STATUS_LOWERING;
  140.                 }
  141.                 else // It's down or lowering, raise it
  142.                 {
  143.                     StopObject(lift_object_id[1]);
  144.                     MoveObject(lift_object_id[1], lift_coords[1][0], lift_coords[1][1], lift_coords[1][2], lift_speed); // Raise it
  145.                     lift_status[1] = LIFT_STATUS_RISING;
  146.                 }
  147.             }
  148.             case 0, 2: // Raise
  149.             {
  150.                 StopObject(lift_object_id[1]);
  151.                 MoveObject(lift_object_id[1], lift_coords[1][0], lift_coords[1][1], lift_coords[1][2], lift_speed); // Raise it
  152.                 lift_status[1] = LIFT_STATUS_RISING;
  153.             }
  154.             case 1, 3: // Lower
  155.             {
  156.                 StopObject(lift_object_id[1]);
  157.                 MoveObject(lift_object_id[1], lift_coords[1][3], lift_coords[1][4], lift_coords[1][5], lift_speed); // Lower it
  158.                 lift_status[1] = LIFT_STATUS_LOWERING;
  159.             }
  160.             default: printf("Invalid 'updown' value passed to ACC_Move_Lift.", updown);
  161.         }
  162.     }
  163.     return 1;
  164. }
  165.  
  166. stock ACC_GetLiftStatus(lift)
  167. {
  168.     if(lift != 0 && lift != 1)
  169.     {
  170.         printf("Invalid lift ID passed to ACC_MoveLift (%i)", lift);
  171.         return -1;
  172.     }
  173.     return lift_status[lift];
  174. }
  175.  
  176. public OnObjectMoved(objectid)
  177. {
  178.     if(objectid == lift_object_id[0])
  179.     {
  180.         if(lift_status[0] == LIFT_STATUS_RISING) lift_status[0] = LIFT_STATUS_UP;
  181.         else  lift_status[0] = LIFT_STATUS_DOWN;
  182.     }
  183.     else if(objectid == lift_object_id[1])
  184.     {
  185.         if(lift_status[1] == LIFT_STATUS_RISING) lift_status[1] = LIFT_STATUS_UP;
  186.         else  lift_status[1] = LIFT_STATUS_DOWN;
  187.     }
  188. }
  189.  
  190. #if defined USE_TRYME
  191.  
  192. // Example usage:
  193.  
  194. #define dcmd(%1,%2,%3) if((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  195. #define ACC_COLOR 0x148b8bFF
  196.  
  197. public OnPlayerCommandText(playerid, cmdtext[])
  198. {
  199.     dcmd(lift, 4, cmdtext);
  200.     dcmd(sidelift, 8, cmdtext);
  201.     return 0;
  202. }
  203.  
  204. dcmd_lift(playerid, params[])
  205. {
  206.     ACC_MoveLift(0, -1, floatstr(params));
  207.     if(ACC_GetLiftStatus(0) == LIFT_STATUS_RISING) SendClientMessage(playerid, ACC_COLOR, "Lift rising.");
  208.     else SendClientMessage(playerid, ACC_COLOR, "Lift lowering.");
  209.     return 1;
  210. }
  211.  
  212. dcmd_sidelift(playerid, params[])
  213. {
  214.     ACC_MoveLift(1, -1, floatstr(params));
  215.     if(ACC_GetLiftStatus(1) == LIFT_STATUS_RISING) SendClientMessage(playerid, ACC_COLOR, "Side lift rising.");
  216.     else SendClientMessage(playerid, ACC_COLOR, "Side lift lowering.");
  217.     return 1;
  218. }
  219.  
  220. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement