Guest User

Untitled

a guest
Jan 14th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3.  
  4. new ENABLE_AUTO_RETURN = 1; //Automatisch zur Ausgangsposition zurückkehren 1 = Ja | 0 = Nein
  5. #define RETURN_INTERVALL 3 //Sekunden bis das Objekt wieder zur Ausgangsposition zurückkehrt
  6. #define OBJECT_RANGE 20 //Entfernung vom Objekt
  7. #define MAX_ADDED_OBJECTS 30 // Maximale Anzahl der Objekte, die hinzugefügt werden können (Mehr werden nicht geladen)
  8.  
  9. forward obj_return();
  10. new moved_id;
  11.  
  12. enum o_Vars
  13. {
  14. _objectid,
  15. Float:s_x,
  16. Float:s_y,
  17. Float:s_z,
  18. Float:r_x,
  19. Float:r_y,
  20. Float:r_z,
  21. Float:e_x,
  22. Float:e_y,
  23. Float:e_z,
  24. }
  25. new obj_info[1][o_Vars] = {
  26. {3055,1588.591796875,-1638.009765625,14.624265670776,0.0,0.0,359.99645996094,1588.591796875,-1638.009765625,9.3742656707764} //Testtor am LSPD
  27. };
  28.  
  29. public OnFilterScriptInit()
  30. {
  31. create_objects();
  32. return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37. destroy_objects();
  38. return 1;
  39. }
  40.  
  41. public OnPlayerSpawn(playerid)
  42. {
  43. return 1;
  44. }
  45.  
  46. public OnObjectMoved(objectid)
  47. {
  48. if(ENABLE_AUTO_RETURN == 1)
  49. {
  50. SetTimer("obj_return",RETURN_INTERVALL*1000,0);
  51. moved_id = objectid;
  52. }
  53. return 1;
  54. }
  55.  
  56. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  57. {
  58. new id = GetNearestObject(playerid,OBJECT_RANGE);
  59. new listid=id-1;
  60. if(newkeys & KEY_YES)
  61. {
  62. MoveObject(id,obj_info[listid][e_x],obj_info[listid][e_y],obj_info[listid][e_z],2.0);
  63. }
  64. if(newkeys & KEY_NO)
  65. {
  66. if(ENABLE_AUTO_RETURN == 0)
  67. {
  68. MoveObject(id,obj_info[listid][s_x],obj_info[listid][s_y],obj_info[listid][s_z],2.0);
  69. }
  70. }
  71. return 1;
  72. }
  73.  
  74. public obj_return()
  75. {
  76. new id = moved_id;
  77. new listid = moved_id -1;
  78. MoveObject(id,obj_info[listid][s_x],obj_info[listid][s_y],obj_info[listid][s_z],2.0);
  79. }
  80.  
  81. stock GetNearestObject(playerid,Float:radius)
  82. {
  83. new Float:x,Float:y,Float:z, id=-1, Float:temp;
  84. for(new i;i<MAX_ADDED_OBJECTS;i++)
  85. {
  86. GetObjectPos(i,x,y,z);
  87. temp = GetPlayerDistanceFromPoint(playerid,x,y,z);
  88. if(temp < radius)
  89. {
  90. id = i;
  91. radius = temp;
  92. }
  93. }
  94. return id;
  95. }
  96.  
  97. stock create_objects()
  98. {
  99. for(new id;id<MAX_ADDED_OBJECTS;id++)
  100. {
  101. CreateObject(obj_info[id][_objectid],obj_info[id][s_x],obj_info[id][s_y],obj_info[id][s_z],obj_info[id][r_x],obj_info[id][r_y],obj_info[id][r_z]);
  102. }
  103. }
  104.  
  105. stock destroy_objects()
  106. {
  107. for(new id;id<MAX_ADDED_OBJECTS;id++){DestroyObject(id);}
  108. }
Advertisement
Add Comment
Please, Sign In to add comment