Advertisement
Guest User

Update DPP by Shomy

a guest
Nov 15th, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.70 KB | None | 0 0
  1. //=-=-=-=-=-=-=-=-=-= DINAMICNO KREIRANJE PICKUPA BY SHOMY =-=-=-=-=-=-=-=-=-=//
  2.  
  3. // = INCLUDE = //
  4.  
  5. #include < a_samp >
  6. #include < YSI\y_ini >
  7. #include < YSI\y_commands >
  8. #include < sscanf2 >
  9.  
  10. // = DEFINE = //
  11.  
  12. #undef MAX_PICKUPS
  13. #define MAX_PICKUPS 250
  14. #define PFile "/Pickups/%d.ini"
  15. #define SCM SendClientMessage
  16.  
  17. // = ENUM = //
  18.  
  19. enum pInfo
  20. {
  21. Float:UlazX,
  22. Float:UlazY,
  23. Float:UlazZ,
  24. Float:IzlazX,
  25. Float:IzlazY,
  26. Float:IzlazZ,
  27. Model,
  28. pInterior,
  29. pText[80],
  30. BojaTexta
  31. }
  32.  
  33. // = NEW = //
  34.  
  35. new PickupInfo[MAX_PICKUPS][pInfo];
  36. new Text3D:label[sizeof(PickupInfo)];
  37. new ipickup,upickup,PravljeniPickupIzlaz,PravljeniPickup;
  38.  
  39. // = PUBLICS = //
  40.  
  41. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  42. {
  43. if(newkeys == KEY_SECONDARY_ATTACK )
  44. {
  45. for(new i; i < MAX_PICKUPS; i++)
  46. {
  47. if(IsPlayerInRangeOfPoint(playerid, 2.5, PickupInfo[i][UlazX], PickupInfo[i][UlazY], PickupInfo[i][UlazZ]))
  48. {
  49. SetPlayerPos(playerid, PickupInfo[i][IzlazX], PickupInfo[i][IzlazY], PickupInfo[i][IzlazZ]);
  50. SetPlayerInterior(playerid, PickupInfo[i][pInterior]);
  51. }
  52. else if(IsPlayerInRangeOfPoint(playerid, 2.5, PickupInfo[i][IzlazX], PickupInfo[i][IzlazY], PickupInfo[i][IzlazZ]))
  53. {
  54. SetPlayerPos(playerid, PickupInfo[i][UlazX], PickupInfo[i][UlazY], PickupInfo[i][UlazZ]);
  55. SetPlayerInterior(playerid, 0);
  56. }
  57. }
  58. }
  59. return 1;
  60. }
  61. public OnFilterScriptInit()
  62. {
  63. for(new id = 0; id < sizeof(PickupInfo); id++)
  64. {
  65. new pFile[50];
  66. format(pFile, sizeof(pFile), PFile, id);
  67. if(fexist(pFile))
  68. {
  69. INI_ParseFile(pFile, "UcitajPickups", .bExtra = true, .extra = id);
  70. upickup = CreatePickup(PickupInfo[id][Model], 1, PickupInfo[id][UlazX], PickupInfo[id][UlazY], PickupInfo[id][UlazZ], -1);
  71. ipickup = CreatePickup(PickupInfo[id][Model], 1, PickupInfo[id][IzlazX], PickupInfo[id][IzlazY], PickupInfo[id][IzlazZ], -1);
  72. new str[80];
  73. format(str,sizeof(str), "%s", PickupInfo[id][pText]);
  74. label[upickup] = Create3DTextLabel(str, PickupInfo[PravljeniPickup][BojaTexta], PickupInfo[id][UlazX], PickupInfo[id][UlazY], PickupInfo[id][UlazZ], 10.0, 0, 0);
  75. }
  76. }
  77. return 1;
  78. }
  79. public OnPlayerPickUpPickup(playerid, pickupid)
  80. {
  81. if(pickupid == upickup) return 0;
  82. if(pickupid == ipickup) return 0;
  83. if(pickupid == PravljeniPickupIzlaz) return 0;
  84. return 1;
  85. }
  86. forward UcitajPickups(id, name[], value[]);
  87. public UcitajPickups(id, name[], value[])
  88. {
  89. INI_Float("Ulaz X", PickupInfo[id][UlazX]);
  90. INI_Float("Ulaz Y", PickupInfo[id][UlazY]);
  91. INI_Float("Ulaz Z", PickupInfo[id][UlazZ]);
  92. INI_Float("Izlaz X", PickupInfo[id][IzlazX]);
  93. INI_Float("Izlaz Y", PickupInfo[id][IzlazY]);
  94. INI_Float("Izlaz Z", PickupInfo[id][IzlazZ]);
  95. INI_Int("Model", PickupInfo[id][Model]);
  96. INI_Int("Interior", PickupInfo[id][pInterior]);
  97. INI_Int("Text", PickupInfo[id][pText]);
  98. INI_Int("Boja Texta", PickupInfo[id][BojaTexta]);
  99. return 1;
  100. }
  101.  
  102. // = CMDS = //
  103.  
  104. YCMD:kreirajpickup(playerid, params[], help)
  105. {
  106. #pragma unused help
  107. if(IsPlayerAdmin(playerid))
  108. {
  109. new model,text[80],inte,Float:iX,Float:iY,Float:iZ,Float:X,Float:Y,Float:Z,bt;
  110. if(sscanf(params, "ds[80]dfffd", model, text, bt, iX, iY, iZ, inte))
  111. {
  112. SCM(playerid, -1, "Koristite /kreirajpickup [Model] [Text] [Boja texta] [Izlaz X] [Izlaz Y] [Izlaz Z] [Interior]");
  113. SCM(playerid, -1, "Boja 1 - Bela || Boja 2 - Crvena || Boja 3 - Plava || Boja 4 - Narandzasta || Boja 5 - Roza");
  114. SCM(playerid, -1, "Boja 6 - Crna || Boja 7 - Zelena || Boja 8 - Ljubicasta || Boja 9 - Tamno Plava || Boja 10 - Zuta");
  115. }
  116. if(model > 19999 || model < 1) return SCM(playerid, -1, "Model ne moze biti manji od 1 ili veci od 19999");
  117. GetPlayerPos(playerid, X,Y,Z);
  118. PravljeniPickup = CreatePickup(model, 1, X,Y,Z, -1);
  119. new str[80];
  120. format(str,sizeof(str), "%s", text);
  121. if(bt < 1 || bt > 10) return SCM(playerid, -1, "Boja texta ne moze biti manji od 1 ili veci od 10 !");
  122. if(bt == 1) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFFFFFFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFFFFFFFF; }
  123. if(bt == 2) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFF1414FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFF1414FF; }
  124. if(bt == 3) { label[PravljeniPickup] = Create3DTextLabel(str, 0x6EF0FFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x6EF0FFFF; }
  125. if(bt == 4) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFF8000FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFF8000FF; }
  126. if(bt == 5) { label[PravljeniPickup] = Create3DTextLabel(str, 0xFF0090FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xFF0090FF; }
  127. if(bt == 6) { label[PravljeniPickup] = Create3DTextLabel(str, 0x000000FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x000000FF; }
  128. if(bt == 7) { label[PravljeniPickup] = Create3DTextLabel(str, 0x09FF00FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x09FF00FF; }
  129. if(bt == 8) { label[PravljeniPickup] = Create3DTextLabel(str, 0x9900FFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x9900FFFF; }
  130. if(bt == 9) { label[PravljeniPickup] = Create3DTextLabel(str, 0x0008FFFF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0x0008FFFF; }
  131. if(bt == 10) { label[PravljeniPickup] = Create3DTextLabel(str, 0xF2FF00FF, X,Y,Z, 10.0, 0, 0); PickupInfo[PravljeniPickup][BojaTexta] = 0xF2FF00FF; }
  132. PravljeniPickupIzlaz = CreatePickup(model, 1, iX,iY,iZ, -1);
  133. PickupInfo[PravljeniPickup][UlazX] = X;
  134. PickupInfo[PravljeniPickup][UlazY] = Y;
  135. PickupInfo[PravljeniPickup][UlazZ] = Z;
  136. PickupInfo[PravljeniPickup][IzlazX] = iX;
  137. PickupInfo[PravljeniPickup][IzlazY] = iY;
  138. PickupInfo[PravljeniPickup][IzlazZ] = iZ;
  139. PickupInfo[PravljeniPickup][Model] = model;
  140. PickupInfo[PravljeniPickup][pInterior] = inte;
  141. PickupInfo[PravljeniPickup][pText] = text;
  142. SavePickup(PravljeniPickup);
  143. }
  144. else return SCM(playerid, -1, "Niste RCON Admin !");
  145. return 1;
  146. }
  147. YCMD:movepickup(playerid, params[], help)
  148. {
  149. #pragma unused help
  150. if(IsPlayerAdmin(playerid))
  151. {
  152. new pFile[50], id, Float:iX,Float:iY,Float:iZ,Float:X,Float:Y,Float:Z, inte;
  153. if(sscanf(params, "dfffd", id, iX, iY, iZ, inte)) return SCM(playerid, -1, "Koristite /movepickup [ID] [Izlaz X] [Izlaz Y] [Izlaz Z] [Interior]");
  154. format(pFile,sizeof(pFile), PFile, id);
  155. if(fexist(pFile))
  156. {
  157. GetPlayerPos(playerid, X,Y,Z);
  158. DestroyPickup(id);
  159. Delete3DTextLabel(label[id]);
  160. PravljeniPickup = CreatePickup(PickupInfo[id][Model], 1, X,Y,Z, -1);
  161. new str[80];
  162. format(str,sizeof(str), "%s", PickupInfo[id][pText]);
  163. label[PravljeniPickup] = Create3DTextLabel(str, PickupInfo[PravljeniPickup][BojaTexta], X,Y,Z, 10.0, 0, 0);
  164. PravljeniPickupIzlaz = CreatePickup(PickupInfo[id][Model], 1, iX,iY,iZ, -1);
  165. PickupInfo[PravljeniPickup][UlazX] = X;
  166. PickupInfo[PravljeniPickup][UlazY] = Y;
  167. PickupInfo[PravljeniPickup][UlazZ] = Z;
  168. PickupInfo[PravljeniPickup][IzlazX] = iX;
  169. PickupInfo[PravljeniPickup][IzlazY] = iY;
  170. PickupInfo[PravljeniPickup][IzlazZ] = iZ;
  171. PickupInfo[PravljeniPickup][pInterior] = inte;
  172. SavePickup(PravljeniPickup);
  173. }
  174. else return SCM(playerid, -1, "Taj ID Pickupa ne postoji !");
  175. }
  176. else return SCM(playerid, -1, "Niste RCON Admin !");
  177. return 1;
  178. }
  179. YCMD:unistipickup(playerid, params[], help)
  180. {
  181. #pragma unused help
  182. if(IsPlayerAdmin(playerid))
  183. {
  184. new pFile[50], id, str[20];
  185. if(sscanf(params, "d", id)) return SCM(playerid, -1, "Koristite /unistipickup [ID]");
  186. format(pFile,sizeof(pFile), PFile, id);
  187. if(fexist(pFile))
  188. {
  189. fremove(pFile);
  190. DestroyPickup(id);
  191. Delete3DTextLabel(label[id]);
  192. format(str,sizeof(str), "Unistili ste pickup ID %d.", id);
  193. SCM(playerid, -1, str);
  194. }
  195. else return SCM(playerid, -1, "Taj ID Pickupa ne postoji !");
  196. }
  197. else return SCM(playerid, -1, "Niste RCON Admin !");
  198. return 1;
  199. }
  200.  
  201. // = STOCK = //
  202.  
  203. stock SavePickup(id)
  204. {
  205. new pFile[100];
  206. format(pFile,sizeof(pFile), PFile, id);
  207. new INI:File = INI_Open(pFile);
  208. INI_WriteFloat(File, "Ulaz X", PickupInfo[id][UlazX]);
  209. INI_WriteFloat(File, "Ulaz Y", PickupInfo[id][UlazY]);
  210. INI_WriteFloat(File, "Ulaz Z", PickupInfo[id][UlazZ]);
  211. INI_WriteFloat(File, "Izlaz X", PickupInfo[id][IzlazX]);
  212. INI_WriteFloat(File, "Izlaz Y", PickupInfo[id][IzlazY]);
  213. INI_WriteFloat(File, "Izlaz Z", PickupInfo[id][IzlazZ]);
  214. INI_WriteInt(File, "Model", PickupInfo[id][Model]);
  215. INI_WriteInt(File, "Interior", PickupInfo[id][pInterior]);
  216. INI_WriteInt(File, "Text", PickupInfo[id][pText]);
  217. INI_WriteInt(File, "Boja Texta", PickupInfo[id][BojaTexta]);
  218. INI_Close(File);
  219. return 1;
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement