Advertisement
Guest User

DaVe Property System 1.0

a guest
Feb 19th, 2015
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.54 KB | None | 0 0
  1. /*
  2. ============================================================================
  3. **** ****** ****
  4. ***** ******* ******
  5. ** ** ** ** ** **
  6. ** ** ******* ***
  7. ** ** ****** ***
  8. ***** ** ** ***
  9. **** ** *******
  10. ** *****
  11. ============================================================================
  12. DaVe Property System include v1.0 | Vytvoril: DaVe 20.2.2015
  13. ============================================================================
  14. *Jak na to?
  15. 1) napiseme do vaseho modu upne nahoru #include <DPS>
  16.  
  17. 2) musime priradit funkce do publicu nasledovne:
  18.  
  19. public OnGameModeInit() { DPS_OnGameModeInit(); }
  20. public OnGameModeExit() { DPS_OnGameModeExit(); }
  21. public OnPlayerConnect(playerid) { DPS_OnPlayerConnect(playerid); }
  22. public OnPlayerPickUpPickup(playerid, pickupid) { DPS_OnPlayerPickUpPickup(playerid, pickupid); }
  23. public OnPlayerSelectedMenuRow(playerid, row) { DPS_OnPlayerSelectedMenuRow(playerid, row); }
  24.  
  25. 3) vyuzijeme funkci(tuto funkci zadavame do public GameModeInit() ve vasem modu):
  26. AddProperty(nazev[],barvatextu,Float:x,Float:y,Float:z,cena,prumernyzisk,mapicon)
  27. nazev = Jmeno nemovitosti
  28. barvatextu = barva, kterou bude nemovitost popsana pomoci Create3DTextLabel
  29. Float:X, Float:Y, Float:Z = pozice pro pickup nemovitosti
  30. cena = Cena nemovitosti
  31. prumernyzisk = Prumerný výnos nemovitosti
  32. mapicon = ikona, kterou bude nemovitost označena na mapě
  33.  
  34. 4) nadefinujte MAX_NEMOVITOSTI na počet vašich nemovitostí:
  35. #define MAX_NEMOVITOSTI [počet využitých nemovitostí bez těchto hranatých závorek]
  36. Příklad:
  37. #define MAX_NEMOVITOSTI 3
  38.  
  39.  
  40. ! Je velice důležité dodržet návod, v případě nedodržení váš mód může spamovat peníze a texty !
  41.  
  42. 5) ostatní definice:
  43. pokud chcete nemovitosti ukládat do jiné složky, než má nastavený include,
  44. nadefinujte:
  45. SYSTEM_FOLDER "vase slozka s uvozovkama bez koncoveho lomitka"
  46. příklad:
  47. #define SYSTEM_FOLDER "Nemovitosti"
  48.  
  49. nadefinujte si timer výnosů z nemovitostí pomocí definice:
  50. TIME_ZISK [sekundy bez zavorek, jedna sekunda = 1000, tudíž minuta = 60000]
  51. příklad:
  52. #define TIME_ZISK 60000 //tato definice vám bude dávat zisky po minutě
  53.  
  54. ============================================================================
  55. */
  56. #include <a_samp>
  57.  
  58. #define MAX_NEMOVITOSTI 20
  59. #define SYSTEM_FOLDER "Nemovitosti"
  60. #define TIME_ZISK 60000
  61. #define NEVLASTNICI "Nikdo"
  62.  
  63.  
  64. enum INFO
  65. {
  66. Float:X,
  67. Float:Y,
  68. Float:Z,
  69. Vlastnik[MAX_PLAYER_NAME],
  70. Cena,
  71. PrumernyZisk,
  72. ikona,
  73. Nazev[70]
  74. };
  75.  
  76. new Nemovitost[MAX_NEMOVITOSTI][INFO],VytvorenoNemovitosti = 0, DPSI[100], File: DPSS;
  77. new Menu: NemovitostMenu, NaseMenu[MAX_PLAYERS];
  78.  
  79.  
  80. forward Zisky();
  81.  
  82. stock DPS_OnGameModeInit()
  83. {
  84. NemovitostMenu = CreateMenu("Nemovitost",1, 50.0, 180.0, 400.0, 200.0);
  85. AddMenuItem(NemovitostMenu,0,"Koupit");
  86. AddMenuItem(NemovitostMenu,0,"Prodat");
  87. AddMenuItem(NemovitostMenu,0,"Vydelky");
  88. AddMenuItem(NemovitostMenu,0,"Nic");
  89.  
  90. SetTimer("Zisky",TIME_ZISK,true);
  91.  
  92. for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
  93. {
  94. format(Nemovitost[DPS][Vlastnik],MAX_PLAYER_NAME,NEVLASTNICI);
  95.  
  96. format(DPSI,50,"%s/N.%d",SYSTEM_FOLDER,DPS);
  97. if(fexist(DPSI))
  98. {
  99. DPSS = fopen(DPSI,io_read);
  100. {
  101. fread(DPSS,Nemovitost[DPS][Vlastnik]);
  102. }
  103. fclose(DPSS);
  104. }
  105. }
  106. }
  107.  
  108. stock DPS_OnGameModeExit()
  109. {
  110. if(!fexist(SYSTEM_FOLDER))
  111. {
  112. SendClientMessageToAll(-1,"[ DaVe Property System include ]: Nemovitosti nemohly být uloženy, složka neexistuje!");
  113. printf("[ DaVe Property System include ]: Nemovitosti nemohly být uloženy, složka neexistuje!");
  114. }else{
  115. for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
  116. {
  117. format(DPSI,50,"%s/N.%d",SYSTEM_FOLDER,DPS);
  118. DPSS = fopen(DPSI,io_write);
  119. {
  120. fwrite(DPSS,Nemovitost[DPS][Vlastnik]);
  121. }
  122. fclose(DPSS);
  123. }
  124. }
  125. }
  126.  
  127.  
  128. stock DPS_OnPlayerConnect(playerid)
  129. {
  130. for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
  131. {
  132. #if defined Streamer_IncludeFileVersion
  133. CreateDynamicMapIcon(Nemovitost[DPS][X],Nemovitost[DPS][Y],Nemovitost[DPS][Z],Nemovitost[DPS][ikona],-1,-1,-1,-1,100);
  134. #else
  135. SetPlayerMapIcon(playerid,DPS,Nemovitost[DPS][X],Nemovitost[DPS][Y],Nemovitost[DPS][Z],Nemovitost[DPS][ikona],DPS,MAPICON_GLOBAL);
  136. #endif
  137. }
  138. }
  139.  
  140.  
  141. stock DPS_OnPlayerPickUpPickup(playerid, pickupid)
  142. {
  143. #pragma unused pickupid
  144. for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
  145. {
  146. if(IsPlayerInRangeOfPoint(playerid,2,Nemovitost[DPS][X],Nemovitost[DPS][Y],Nemovitost[DPS][Z]))
  147. {
  148. ShowMenuForPlayer(NemovitostMenu,playerid);
  149. NaseMenu[playerid] = DPS;
  150. }
  151. }
  152. }
  153.  
  154. stock DPS_OnPlayerSelectedMenuRow(playerid, row)
  155. {
  156. new Menu:zvoleno; zvoleno = GetPlayerMenu(playerid);
  157. if(zvoleno == NemovitostMenu)
  158. {
  159. switch(row)
  160. {
  161. case 0: {
  162. if(strcmp(Nemovitost[NaseMenu[playerid]][Vlastnik],NEVLASTNICI,false))
  163. {
  164. format(DPSI,100,"[ CHYBA ]: Tuto nemovitost vlastní hráč %s",Nemovitost[NaseMenu[playerid]][Vlastnik]);
  165. SendClientMessage(playerid,-1,DPSI);
  166. return 1;
  167. }
  168. if(GetPlayerMoney(playerid) < Nemovitost[NaseMenu[playerid]][Cena])
  169. {
  170. format(DPSI,100,"[ CHYBA ]: Nemáte dostatek peněz ( %d$ )",Nemovitost[NaseMenu[playerid]][Cena]);
  171. SendClientMessage(playerid,-1,DPSI);
  172. return 1;
  173. }
  174. GivePlayerMoney(playerid,-Nemovitost[NaseMenu[playerid]][Cena]);
  175. format(Nemovitost[NaseMenu[playerid]][Vlastnik],MAX_PLAYER_NAME,GetPlayerNick(playerid));
  176. format(DPSI,100,"Hráč %s koupil nemovitost %s",GetPlayerNick(playerid),Nemovitost[NaseMenu[playerid]][Nazev]);
  177. SendClientMessageToAll(-1,DPSI);
  178. }
  179. case 1: {
  180. if(strcmp(Nemovitost[NaseMenu[playerid]][Vlastnik],GetPlayerNick(playerid),false))
  181. {
  182. format(DPSI,100,"[ CHYBA ]: Tato nemovitost neni vase!");
  183. SendClientMessage(playerid,-1,DPSI);
  184. return 1;
  185. }
  186. GivePlayerMoney(playerid,Nemovitost[NaseMenu[playerid]][Cena]);
  187. format(Nemovitost[NaseMenu[playerid]][Vlastnik],MAX_PLAYER_NAME,NEVLASTNICI);
  188. format(DPSI,100,"Hráč %s prodal nemovitost %s",GetPlayerNick(playerid),Nemovitost[NaseMenu[playerid]][Nazev]);
  189. SendClientMessageToAll(-1,DPSI);
  190. }
  191. case 2: {
  192. format(DPSI,100,"Průměrný zisk této nemovitosti činí %d$",Nemovitost[NaseMenu[playerid]][PrumernyZisk]);
  193. SendClientMessage(playerid,-1,DPSI);
  194. }
  195. case 3: return 1;
  196. }
  197. }
  198. return 1;
  199. }
  200.  
  201. stock AddProperty(nazev[],barvatextu,Float:x,Float:y,Float:z,cena,prumernyzisk,mapicon)
  202. {
  203. if(VytvorenoNemovitosti == MAX_NEMOVITOSTI)
  204. {
  205. printf("[ DaVe Property System ]: ERROR -> Překročený počet MAX_NEMOVITOSTI");
  206. }else{
  207. Nemovitost[VytvorenoNemovitosti][X] = x; Nemovitost[VytvorenoNemovitosti][Y] = y; Nemovitost[VytvorenoNemovitosti][Z] = z;
  208. Nemovitost[VytvorenoNemovitosti][Cena] = cena; Nemovitost[VytvorenoNemovitosti][PrumernyZisk] = prumernyzisk;
  209. Nemovitost[VytvorenoNemovitosti][ikona] = mapicon;
  210. format(Nemovitost[VytvorenoNemovitosti][Nazev],70,nazev);
  211. Create3DTextLabel(nazev,barvatextu,x,y,z,100,0);
  212. CreatePickup(1272,1,x,y,z);
  213. VytvorenoNemovitosti++;
  214. }
  215. }
  216.  
  217. stock GetPlayerNick(playerid)
  218. {
  219. new j[MAX_PLAYER_NAME];
  220. if(IsPlayerConnected(playerid))
  221. {
  222. GetPlayerName(playerid,j,MAX_PLAYER_NAME);
  223. }
  224. return j;
  225. }
  226.  
  227. public Zisky()
  228. {
  229. for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
  230. {
  231. new castka; castka = Nemovitost[DPS][PrumernyZisk];
  232. switch(random(4))
  233. {
  234. case 0: castka-=1400;
  235. case 1: castka-=5250;
  236. case 2: castka+=6502;
  237. case 3: castka+=9600;
  238. }
  239. for(new i=0; i<MAX_PLAYERS; i++)
  240. {
  241. if(IsPlayerConnected(i))
  242. {
  243. if(!strcmp(Nemovitost[DPS][Vlastnik],GetPlayerNick(i),false))
  244. {
  245. format(DPSI,100,"[ VÝNOSY Z NEMOVITOSTÍ ] %s vám vynesl %d$",Nemovitost[DPS][Nazev],castka);
  246. SendClientMessage(i,-1,DPSI);
  247. GivePlayerMoney(i,castka);
  248. }
  249. }
  250. }
  251. }
  252. return 1;
  253. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement