Guest User

Plant system by PabuLetz

a guest
Jul 19th, 2013
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. // Plant system by PabuLetz.
  2. // Credits:
  3. // PabuLetz- created a system
  4. // Commands:
  5. // -/plant
  6. // -/premove
  7.  
  8. #include <a_samp>
  9.  
  10. new planting[MAX_PLAYERS];
  11. new planting1[MAX_PLAYERS];
  12. new planting2[MAX_PLAYERS];
  13.  
  14. #pragma tabsize 0
  15.  
  16. #if defined FILTERSCRIPT
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. print("\n--------------------------------------");
  21. print(" Planting System Sa:Mp");
  22. print("--------------------------------------\n");
  23. return 1;
  24. }
  25.  
  26. public OnFilterScriptExit()
  27. {
  28. return 1;
  29. }
  30.  
  31. #else
  32.  
  33. main()
  34. {
  35. print("\n----------------------------------");
  36. print(" Planting System Sa:Mp");
  37. print("----------------------------------\n");
  38. }
  39.  
  40. #endif
  41.  
  42. public OnGameModeInit()
  43. {
  44. return 1;
  45. }
  46.  
  47. public OnGameModeExit()
  48. {
  49. return 1;
  50. }
  51.  
  52. public OnPlayerRequestClass(playerid, classid)
  53. {
  54. return 1;
  55. }
  56.  
  57. public OnPlayerConnect(playerid)
  58. {
  59. return 1;
  60. }
  61.  
  62. public OnPlayerDisconnect(playerid, reason)
  63. {
  64. return 1;
  65. }
  66.  
  67. public OnPlayerSpawn(playerid)
  68. {
  69. return 1;
  70. }
  71.  
  72. public OnPlayerDeath(playerid, killerid, reason)
  73. {
  74. return 1;
  75. }
  76.  
  77. public OnVehicleSpawn(vehicleid)
  78. {
  79. return 1;
  80. }
  81.  
  82. public OnVehicleDeath(vehicleid, killerid)
  83. {
  84. return 1;
  85. }
  86.  
  87. public OnPlayerText(playerid, text[])
  88. {
  89. return 1;
  90. }
  91.  
  92. public OnPlayerCommandText(playerid, cmdtext[])
  93. {
  94. if (strcmp("/plant", cmdtext, true, 10) == 0)
  95. {
  96. ShowPlayerDialog(playerid, 2014, DIALOG_STYLE_MSGBOX, "Plant", "Are you sure you want to create a plant?", "Yes", "No");
  97. return 1;
  98. }
  99. if (strcmp("/premove", cmdtext, true, 10) == 0)
  100. {
  101. ShowPlayerDialog(playerid, 2015, DIALOG_STYLE_MSGBOX, "Plant", "Are you sure you want to delete a plant?", "Yes", "No");
  102. return 1;
  103. }
  104. return 0;
  105. }
  106.  
  107. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  108. {
  109. if(dialogid == 2014)
  110. {
  111. if(response)
  112. {
  113. ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
  114. SetTimerEx("planter", 3000, false, "i", playerid);
  115. }
  116. }
  117. if(dialogid == 2015)
  118. {
  119. if(response)
  120. {
  121. DestroyObject(planting[playerid]);
  122. DestroyObject(planting1[playerid]);
  123. DestroyObject(planting2[playerid]);
  124. }
  125. }
  126. if(dialogid == 2013)
  127. {
  128. if(response)
  129. {
  130.  
  131. if(listitem == 0)
  132. {
  133. new Float:X, Float:Y, Float:Z;
  134. GetPlayerPos(playerid, X, Y, Z);
  135. planting[playerid] = CreateObject(870,X,Y+1.5,Z,0.0,0.0,0.0,0.0);
  136. EditObject(playerid, planting[playerid]);
  137. planting[playerid] = 1;
  138. }
  139. if(listitem == 1)
  140. {
  141. new Float:X, Float:Y, Float:Z;
  142. GetPlayerPos(playerid, X, Y, Z);
  143. planting1[playerid] = CreateObject(675,X,Y+1.5,Z,0.0,0.0,0.0,0.0);
  144. EditObject(playerid, planting1[playerid]);
  145. planting1[playerid] = 1;
  146. }
  147. if(listitem == 2)
  148. {
  149. new Float:X, Float:Y, Float:Z;
  150. GetPlayerPos(playerid, X, Y, Z);
  151. planting2[playerid] = CreateObject(869,X,Y+1.5,Z,0.0,0.0,0.0,0.0);
  152. EditObject(playerid, planting2[playerid]);
  153. planting2[playerid] = 1;
  154. }
  155. }
  156. return 1;
  157. }
  158.  
  159. return 0;
  160. }
  161.  
  162. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  163. {
  164. new Float:oldX, Float:oldY, Float:oldZ,
  165. Float:oldRotX, Float:oldRotY, Float:oldRotZ;
  166. GetObjectPos(planting[playerid], oldX, oldY, oldZ);
  167. GetObjectRot(planting[playerid], oldRotX, oldRotY, oldRotZ);
  168. GetObjectPos(planting1[playerid], oldX, oldY, oldZ);
  169. GetObjectRot(planting1[playerid], oldRotX, oldRotY, oldRotZ);
  170. GetObjectPos(planting2[playerid], oldX, oldY, oldZ);
  171. GetObjectRot(planting2[playerid], oldRotX, oldRotY, oldRotZ);
  172. if(!playerobject)
  173. {
  174. if(!IsValidObject(planting[playerid])) return;
  175. MoveObject(planting[playerid], fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
  176. }
  177. if(!playerobject)
  178. {
  179. if(!IsValidObject(planting1[playerid])) return;
  180. MoveObject(planting1[playerid], fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
  181. }
  182. if(!playerobject)
  183. {
  184. if(!IsValidObject(planting2[playerid])) return;
  185. MoveObject(planting2[playerid], fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
  186. }
  187. if(response == EDIT_RESPONSE_FINAL)
  188. {
  189. SendClientMessage(playerid,-1,"Now a plant.");
  190.  
  191. }
  192. }
  193.  
  194. forward planter(playerid);
  195.  
  196. public planter(playerid)
  197. {
  198. ClearAnimations(playerid);
  199. ShowPlayerDialog(playerid, 2013, DIALOG_STYLE_LIST, "Plant", "Floors\nGrass\nFloors 2\n", "Select", "Close");
  200. return 1;
  201. }
Advertisement
Add Comment
Please, Sign In to add comment