Advertisement
Guest User

Dinamican System Jelki by Jevtic

a guest
Dec 27th, 2016
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. /*______________________________________________________________________________
  2.  
  3. Dynamic Jelka System by Jevtic (c)
  4. Radio: Jevtic
  5. Vreme izrade: 30 Min
  6. Credits: Lazar Jevtic a.k.a Jevtic
  7.  
  8. CMD: /maketrees - Kreiranje jelke
  9. CMD: /etrees - Edit Jelke
  10. CMD: /treesport - Port do jelke
  11.  
  12. ________________________________________________________________________________
  13. */
  14. //______________________________________________________________________________
  15.  
  16. #include < a_samp >
  17. #include < sscanf2 >
  18. #include < streamer >
  19. #include < YSI\y_commands >
  20. #include < YSI\y_ini >
  21. //______________________________________________________________________________
  22.  
  23. #define PLAVA "{138ED8}"
  24. #define BELA "{FFFFFF}"
  25. #define INFO "{9CA5A4}"
  26. #define ERROR "{E83232}"
  27. //______________________________________________________________________________
  28.  
  29. #define SCM SendClientMessage
  30.  
  31. //______________________________________________________________________________
  32.  
  33. #define JELKA_OBJEKAT 19076
  34. #define JELKA_FILE "Jelke/JELKA_%d.ini"
  35. #define MAX_JELKA 100
  36.  
  37. //______________________________________________________________________________
  38.  
  39. enum Jelka
  40. {
  41. zPostavljena,
  42. Float:zX,
  43. Float:zY,
  44. Float:zZ,
  45. Float:zAngle,
  46. zObjekat,
  47. aInt,
  48. aVW,
  49. Text3D:zLabelJelke
  50. }
  51. new JI[MAX_JELKA][Jelka], eData[MAX_PLAYERS];
  52. //______________________________________________________________________________
  53.  
  54. public OnFilterScriptInit()
  55. {
  56. for(new i = 0; i < sizeof(JI); i++)
  57. {
  58. new kFile[50];
  59. format(kFile, sizeof(kFile), JELKA_FILE, i);
  60. if(fexist(kFile))
  61. {
  62. INI_ParseFile(kFile, "UcitajJelku", .bExtra = true, .extra = i);
  63. KreirajJelku(i);
  64. }
  65. }
  66. return 1;
  67. }
  68. //______________________________________________________________________________
  69.  
  70. public OnFilterScriptExit()
  71. {
  72. for(new a = 0; a < sizeof(JI); a++) { SacuvajJelku(a); }
  73. return 1;
  74. }
  75. //______________________________________________________________________________
  76.  
  77. public OnPlayerConnect(playerid)
  78. {
  79. //________________________________________________
  80.  
  81. SCM( playerid, -1, ""INFO"INFO: "BELA" ____________________________________________________ " );
  82. SCM( playerid, -1, ""INFO"INFO: "BELA" Ovaj server koristi Dinamican System Jelki by Jevtic" );
  83. SCM( playerid, -1, ""INFO"INFO: "BELA" Facebook: www.fb.com/jevttabrat" );
  84. SCM( playerid, -1, ""INFO"INFO: "BELA" Skype: lazar.jevtic404" );
  85. SCM( playerid, -1, ""INFO"INFO: "BELA" Forum: www.zb-samp.com and www.balkan-samp.com" );
  86. SCM( playerid, -1, ""INFO"INFO: "BELA" ____________________________________________________ " );
  87.  
  88. eData[playerid] = -1;
  89. return 1;
  90. }
  91. //______________________________________________________________________________
  92.  
  93. YCMD:maketrees( playerid , params[] , help )
  94. {
  95. //Dodati proveru : pAdmin i pLoginProvera
  96. #pragma unused help
  97. new idJelka,Float:X,Float:Y,Float:Z,Float:Angle,afajl[60];
  98. GetPlayerPos(playerid,X,Y,Z); GetPlayerFacingAngle(playerid, Angle);
  99. if(sscanf(params, "i",idJelka)) return SCM( playerid, -1,""INFO"KORISTI: "BELA"/maketrees [ID]" );
  100. if(idJelka >= MAX_JELKA) return SCM( playerid, -1, ""ERROR"GRESKA: "BELA"Imate ogranicen broj jelki!" );
  101. format(afajl, sizeof(afajl), JELKA_FILE, idJelka);
  102. if(fexist(afajl)) return SCM( playerid, -1, ""ERROR"GRESKA: "BELA"Taj ID Jelke je vec kreiran!" );
  103. JI[idJelka][zPostavljena] = 1; JI[idJelka][zAngle] = Angle;
  104. JI[idJelka][zX] = X; JI[idJelka][zY] = Y; JI[idJelka][zZ] = Z;
  105. JI[idJelka][aInt] = GetPlayerInterior(playerid); JI[idJelka][aVW] = GetPlayerVirtualWorld(playerid);
  106. KreirajJelku(idJelka); SacuvajJelku(idJelka); SCM( playerid, -1,""PLAVA"INFO: "BELA"Uspesno ste napravili jelku mozete je premestati (/etrees)" );
  107. return 1;
  108. }
  109. //______________________________________________________________________________
  110.  
  111. YCMD:etrees( playerid , params[] , help )
  112. {
  113. //Dodati proveru : pAdmin i pLoginProvera
  114. #pragma unused help
  115. new afajl[80],idJelka;
  116. if(sscanf(params, "i",idJelka)) return SCM( playerid, -1,""INFO"KORISTI: "BELA"/etrees [ID]" );
  117. format(afajl, sizeof(afajl), JELKA_FILE, idJelka);
  118. if(!fexist(afajl)) return SCM( playerid, -1, ""ERROR"GRESKA: "BELA" Unesen id jelke ne postoji!" );
  119. if(!IsPlayerInRangeOfPoint(playerid, 3.0, JI[idJelka][zX], JI[idJelka][zY], JI[idJelka][zZ])) return SCM(playerid,-1,"Niste u blizini tog bankoamta!");
  120. eData[playerid] = idJelka; EditDynamicObject(playerid,JI[idJelka][zObjekat]);
  121. return 1;
  122. }
  123. //______________________________________________________________________________
  124.  
  125. YCMD:treesport(playerid , params[] , help )
  126. {
  127. //Dodati proveru : pAdmin i pLoginProvera
  128. #pragma unused help
  129. new afajl[80],idJelka;
  130. if(sscanf(params, "i",idJelka)) return SCM( playerid, -1,""INFO"KORISTI: "BELA"/treesport [ID]" );
  131. format(afajl, sizeof(afajl), JELKA_FILE, idJelka);
  132. if(!fexist(afajl)) return SCM( playerid,-1, ""ERROR"GRESKA: "BELA"Unesen id jelke ne postoji!" );
  133. SetPlayerPos(playerid,JI[idJelka][zX], JI[idJelka][zY], JI[idJelka][zZ]);
  134. SetPlayerInterior(playerid,0); SetPlayerVirtualWorld(playerid,0);
  135. return 1;
  136. }
  137. //______________________________________________________________________________
  138.  
  139. forward UcitajJelku(Jelkaid, name[], value[]);
  140. public UcitajJelku(Jelkaid, name[], value[])
  141. {
  142. INI_Int("Postavljena",JI[Jelkaid][zPostavljena]);
  143. INI_Float("X",JI[Jelkaid][zX]);
  144. INI_Float("Y",JI[Jelkaid][zY]);
  145. INI_Float("Z",JI[Jelkaid][zZ]);
  146. INI_Float("Angle",JI[Jelkaid][zAngle]);
  147. INI_Int("Int",JI[Jelkaid][aInt]);
  148. INI_Int("VW",JI[Jelkaid][aVW]);
  149. return 1;
  150. }
  151. //______________________________________________________________________________
  152.  
  153. stock SacuvajJelku(Jelkaid)
  154. {
  155. new kFile[80];
  156. format(kFile, sizeof(kFile), JELKA_FILE, Jelkaid);
  157. new INI:File = INI_Open(kFile);
  158. INI_WriteInt(File,"Postavljena",JI[Jelkaid][zPostavljena]);
  159. INI_WriteFloat(File,"X",JI[Jelkaid][zX]);
  160. INI_WriteFloat(File,"Y",JI[Jelkaid][zY]);
  161. INI_WriteFloat(File,"Z",JI[Jelkaid][zZ]);
  162. INI_WriteFloat(File,"Angle",JI[Jelkaid][zAngle]);
  163. INI_WriteInt(File,"Int",JI[Jelkaid][aInt]);
  164. INI_WriteInt(File,"VW",JI[Jelkaid][aVW]);
  165. INI_Close(File);
  166. return 1;
  167. }
  168. //______________________________________________________________________________
  169.  
  170. public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
  171. {
  172. if(response == EDIT_RESPONSE_FINAL)
  173. {
  174. new id = eData[playerid], Float:angle, string[100];
  175. GetPlayerFacingAngle(playerid, angle);
  176. if(id != -1)
  177. {
  178. JI[id][zX] = x;
  179. JI[id][zY] = y;
  180. JI[id][zZ] = z;
  181. JI[id][zAngle] = rz;
  182. DestroyDynamicObject(JI[id][zObjekat]);
  183. KreirajJelku(id);
  184. SacuvajJelku(id);
  185. format(string,sizeof(string),""INFO"INFO: "BELA"Jelka je uspesno kreirana (ID:%d)",id);
  186. SCM(playerid,-1,string);
  187. id = -1;
  188. return 1;
  189. }
  190. }
  191. return 1;
  192. }
  193. //______________________________________________________________________________
  194.  
  195. stock KreirajJelku(idJelka)
  196. {
  197. if(JI[idJelka][zPostavljena] == 1)
  198. {
  199. new string[80];
  200. format(string, sizeof(string), ""PLAVA"["BELA"SRECNE NOVOGODISNJE PRAZNIKE ZELI VAM JEVTIC"PLAVA"]", idJelka);
  201. JI[idJelka][zLabelJelke] = CreateDynamic3DTextLabel(string, 0x1D9F00AA, JI[idJelka][zX], JI[idJelka][zY], JI[idJelka][zZ]+1.5, 25.0,_,_,_, JI[idJelka][aVW], JI[idJelka][aInt],_,_);
  202. JI[idJelka][zObjekat] = CreateDynamicObject(JELKA_OBJEKAT, JI[idJelka][zX], JI[idJelka][zY], JI[idJelka][zZ], 0.0, 0.0, JI[idJelka][zAngle], JI[idJelka][aVW], JI[idJelka][aInt],_,_);
  203. }
  204. return 1;
  205. }
  206. //______________________________________________________________________________
  207.  
  208. stock ZJelkaID(playerid)
  209. {
  210. new idJelka = 0;
  211. while(idJelka != MAX_JELKA)
  212. {
  213. if(IsPlayerInRangeOfPoint(playerid, 5.0, JI[idJelka][zX], JI[idJelka][zY], JI[idJelka][zZ]))
  214. {
  215. return idJelka;
  216. }
  217. idJelka++;
  218. }
  219. return -1;
  220. }
  221. //______________________________________________________________________________
  222.  
  223.  
  224.  
  225.  
  226. // Fest and zuroism
  227.  
  228.  
  229.  
  230.  
  231.  
  232. //______________________________________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement