Guest User

Untitled

a guest
Apr 13th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.19 KB | None | 0 0
  1. /*
  2. Business system by [BG][NCS]Abaddon
  3. */
  4.  
  5. #include <a_samp>
  6. #include <sscanf2>
  7. #include <dini>
  8.  
  9. #define FILTERSCRIPT
  10. #if defined FILTERSCRIPT
  11.  
  12. new bizid=0;
  13. new serverinfo[1000];
  14.  
  15. #define DIALOG_BUY 12
  16. #define DIALOG_ENTER 13
  17.  
  18. public OnFilterScriptInit()
  19. {
  20. format(serverinfo,sizeof(serverinfo),"/sInfo.ini");
  21. if(!dini_Exists(serverinfo))
  22. {
  23. dini_Create(serverinfo);
  24. dini_Set(serverinfo,"BizIds","0");
  25. }
  26. else
  27. {
  28. bizid = dini_Int(serverinfo,"BizIds");
  29. LoadBizz(bizid);
  30. }
  31. print("\n--------------------------------------");
  32. print(" Blank Filterscript by your name here");
  33. print("--------------------------------------\n");
  34. return 1;
  35. }
  36.  
  37. public OnFilterScriptExit()
  38. {
  39. return 1;
  40. }
  41.  
  42. #else
  43.  
  44. main()
  45. {
  46. print("\n----------------------------------");
  47. print(" Blank Gamemode by your name here");
  48. print("----------------------------------\n");
  49. }
  50.  
  51. #endif
  52.  
  53.  
  54. strtok(const string[], &index)
  55. {
  56. new length = strlen(string);
  57. while ((index < length) && (string[index] <= ' '))
  58. {
  59. index++;
  60. }
  61.  
  62. new offset = index;
  63. new result[20];
  64. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  65. {
  66. result[index - offset] = string[index];
  67. index++;
  68. }
  69. result[index - offset] = EOS;
  70. return result;
  71. }
  72.  
  73. #define MAX_BIZZS 200
  74.  
  75. enum bInfo
  76. {
  77. bOwner[MAX_PLAYER_NAME],
  78. bool:bOwned,
  79. bType,
  80. bPrice,
  81. bPayOut,
  82. Float:bXcoord,
  83. Float:bYcoord,
  84. Float:bZcoord,
  85. bLocked,
  86. bPickUp
  87. }
  88. new BizInfo[MAX_BIZZS][bInfo];
  89.  
  90. stock GetName(playerid)
  91. {
  92. new pname[MAX_PLAYER_NAME]; pname="Íåâàëèäíî ID íà èãðà÷.";
  93. if(IsPlayerConnected(playerid)) {
  94. GetPlayerName(playerid, pname, sizeof (pname));
  95. }
  96. return pname;
  97. }
  98.  
  99. stock LoadBizz()
  100. {
  101. new biz[256];
  102. for(new b=0;b<bizid+1;b++)
  103. {
  104. format(biz,sizeof(biz),"/%d.ini",b);
  105. format(BizInfo[b][bOwner],MAX_PLAYERS,"%s",dini_Get(biz,"Owner"));
  106. BizInfo[b][bOwned] = dini_Bool(biz,"Owned");
  107. BizInfo[b][bType] = dini_Int(biz,"Type");
  108. BizInfo[b][bPrice] = dini_Int(biz,"Price");
  109. BizInfo[b][bPayOut] = dini_Int(biz,"PayOut");
  110. BizInfo[b][bXcoord] = dini_Float(biz,"Xcoord");
  111. BizInfo[b][bYcoord] = dini_Float(biz,"Ycoord");
  112. BizInfo[b][bZcoord] = dini_Float(biz,"Zcoord");
  113. BizInfo[b][bLocked] = dini_Bool(biz,"Locked");
  114. BizInfo[b][bPickUp] = CreatePickup(1272, 1, BizInfo[b][bXcoord],BizInfo[b][bYcoord],BizInfo[b][bZcoord], -1);
  115. }
  116. return 1;
  117. }
  118.  
  119. stock LoadEBizz(b)
  120. {
  121. new biz[256];
  122. format(biz,sizeof(biz),"/%d.ini",b);
  123. format(BizInfo[b][bOwner],MAX_PLAYERS,"%s",dini_Get(biz,"Owner"));
  124. BizInfo[b][bOwned] = dini_Bool(biz,"Owned");
  125. BizInfo[b][bType] = dini_Int(biz,"Type");
  126. BizInfo[b][bPrice] = dini_Int(biz,"Price");
  127. BizInfo[b][bPayOut] = dini_Int(biz,"PayOut");
  128. BizInfo[b][bXcoord] = dini_Float(biz,"Xcoord");
  129. BizInfo[b][bYcoord] = dini_Float(biz,"Ycoord");
  130. BizInfo[b][bZcoord] = dini_Float(biz,"Zcoord");
  131. BizInfo[b][bLocked] = dini_Bool(biz,"Locked");
  132. BizInfo[b][bPickUp] = CreatePickup(1272, 1, BizInfo[b][bXcoord],BizInfo[b][bYcoord],BizInfo[b][bZcoord], -1);
  133. return 1;
  134. }
  135.  
  136. stock SaveEBiz(b)
  137. {
  138. new biz[256];
  139. format(biz,sizeof(biz),"/%d.ini",b);
  140. dini_Set(biz,"Owner",BizInfo[b][bOwner]);
  141. dini_BoolSet(biz,"Owned",BizInfo[b][bOwned]);
  142. dini_IntSet(biz,"Type",BizInfo[b][bType]);
  143. dini_IntSet(biz,"Price",BizInfo[b][bPrice]);
  144. dini_IntSet(biz,"PayOut",BizInfo[b][bPayOut]);
  145. dini_FloatSet(biz,"Xcoord",BizInfo[b][bXcoord]);
  146. dini_FloatSet(biz,"Ycoord",BizInfo[b][bYcoord]);
  147. dini_FloatSet(biz,"Zcoord",BizInfo[b][bZcoord]);
  148. dini_BoolSet(biz,"Locked",BizInfo[b][bLocked]);
  149. return 1;
  150. }
  151.  
  152. stock BizType(b)
  153. {
  154. new type[30];
  155. switch(BizInfo[b][bType])
  156. {
  157. case 1: type = "Êëóá";
  158. case 2: type = "Áàð";
  159. case 3: type = "Ìàãàçèí çà îðúæèÿ";
  160. }
  161. return type;
  162. }
  163.  
  164. public OnGameModeInit()
  165. {
  166. // Don't use these lines if it's a filterscript
  167. SetGameModeText("Blank Script");
  168. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  169. return 1;
  170. }
  171.  
  172. public OnGameModeExit()
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerRequestClass(playerid, classid)
  178. {
  179. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  180. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  181. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  182. return 1;
  183. }
  184.  
  185. public OnPlayerConnect(playerid)
  186. {
  187. return 1;
  188. }
  189.  
  190. public OnPlayerDisconnect(playerid, reason)
  191. {
  192. return 1;
  193. }
  194.  
  195. public OnPlayerSpawn(playerid)
  196. {
  197. return 1;
  198. }
  199.  
  200. public OnPlayerDeath(playerid, killerid, reason)
  201. {
  202. return 1;
  203. }
  204.  
  205. public OnVehicleSpawn(vehicleid)
  206. {
  207. return 1;
  208. }
  209.  
  210. public OnVehicleDeath(vehicleid, killerid)
  211. {
  212. return 1;
  213. }
  214.  
  215. public OnPlayerText(playerid, text[])
  216. {
  217. return 1;
  218. }
  219.  
  220. public OnPlayerCommandText(playerid, cmdtext[])
  221. {
  222. new cmd[128], idx;
  223. cmd = strtok(cmdtext, idx);
  224. new tmp[128];
  225. new string[2000];
  226. new params[256];
  227. sscanf(cmdtext, "s[28]S()[100]", cmd, params);
  228.  
  229. if(strcmp(cmd,"/createbiz",true)==0)
  230. {
  231. new type,price,payout;
  232. new Float:pX,Float:pY,Float:pZ;
  233. if(sscanf(params,"iii",type,price,payout)) return SendClientMessage(playerid,-1,"Èçïîëçâàé: /createbizz [type][price][payout]");
  234. bizid += 1;
  235. GetPlayerPos(playerid,pX,pY,pZ);
  236. new biz[256];
  237. format(biz,sizeof(biz),"Businesses/%d.ini",bizid);
  238. if(!dini_Exists(biz))
  239. {
  240. dini_Create(biz);
  241. dini_Set(biz,"Owner","Íÿìà");
  242. dini_BoolSet(biz,"Owned",0);
  243. dini_IntSet(biz,"Type",type);
  244. dini_IntSet(biz,"Price",price);
  245. dini_IntSet(biz,"PayOut",payout);
  246. dini_FloatSet(biz,"Xcoord",pX);
  247. dini_FloatSet(biz,"Ycoord",pY);
  248. dini_FloatSet(biz,"Zcoord",pZ);
  249. dini_BoolSet(biz,"Locked",0);
  250. LoadEBizz(bizid);
  251. }
  252. SendClientMessage(playerid,-1,"Bizz has been created");
  253. return 1;
  254. }
  255. return 0;
  256. }
  257.  
  258. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  259. {
  260. return 1;
  261. }
  262.  
  263. public OnPlayerExitVehicle(playerid, vehicleid)
  264. {
  265. return 1;
  266. }
  267.  
  268. public OnPlayerStateChange(playerid, newstate, oldstate)
  269. {
  270. return 1;
  271. }
  272.  
  273. public OnPlayerEnterCheckpoint(playerid)
  274. {
  275. return 1;
  276. }
  277.  
  278. public OnPlayerLeaveCheckpoint(playerid)
  279. {
  280. return 1;
  281. }
  282.  
  283. public OnPlayerEnterRaceCheckpoint(playerid)
  284. {
  285. return 1;
  286. }
  287.  
  288. public OnPlayerLeaveRaceCheckpoint(playerid)
  289. {
  290. return 1;
  291. }
  292.  
  293. public OnRconCommand(cmd[])
  294. {
  295. return 1;
  296. }
  297.  
  298. public OnPlayerRequestSpawn(playerid)
  299. {
  300. return 1;
  301. }
  302.  
  303. public OnObjectMoved(objectid)
  304. {
  305. return 1;
  306. }
  307.  
  308. public OnPlayerObjectMoved(playerid, objectid)
  309. {
  310. return 1;
  311. }
  312.  
  313. public OnPlayerPickUpPickup(playerid, pickupid)
  314. {
  315. for(new b=0;b<bizid+1;b++)
  316. {
  317. if(pickupid == BizInfo[b][bPickUp])
  318. {
  319. if(BizInfo[b][bOwned] == 0)
  320. {
  321. new string[2000];
  322. format(string,sizeof(string),"Ñîáñòâåíèê: %s\nÑòîéíîñò: %s\nÇàïëàùàíå: %s\nÂèä íà áèçíåñ: %s\nID: %d",BizInfo[b][bOwner],BizInfo[b][bPrice],BizInfo[b][bPayOut],BizType(b),b);
  323. ShowPlayerDialog(playerid,DIALOG_BUY,DIALOG_STYLE_MSGBOX,"Áèçíåñ:",string,"Êóïè","Îòêàç");
  324. }
  325. else
  326. {
  327. new string[2000];
  328. format(string,sizeof(string),"Ñîáñòâåíèê: %s\nÑòîéíîñò: %s\nÇàïëàùàíå: %s\nÂèä íà áèçíåñ: %s\nID: %d",BizInfo[b][bOwner],BizInfo[b][bPrice],BizInfo[b][bPayOut],BizType(b),b);
  329. ShowPlayerDialog(playerid,DIALOG_ENTER,DIALOG_STYLE_MSGBOX,"Áèçíåñ:",string,"Âëåç","Îòêàç");
  330. }
  331. }
  332. }
  333. return 1;
  334. }
  335.  
  336. public OnVehicleMod(playerid, vehicleid, componentid)
  337. {
  338. return 1;
  339. }
  340.  
  341. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  342. {
  343. return 1;
  344. }
  345.  
  346. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  347. {
  348. return 1;
  349. }
  350.  
  351. public OnPlayerSelectedMenuRow(playerid, row)
  352. {
  353. return 1;
  354. }
  355.  
  356. public OnPlayerExitedMenu(playerid)
  357. {
  358. return 1;
  359. }
  360.  
  361. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  362. {
  363. return 1;
  364. }
  365.  
  366. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  367. {
  368. return 1;
  369. }
  370.  
  371. public OnRconLoginAttempt(ip[], password[], success)
  372. {
  373. return 1;
  374. }
  375.  
  376. public OnPlayerUpdate(playerid)
  377. {
  378. return 1;
  379. }
  380.  
  381. public OnPlayerStreamIn(playerid, forplayerid)
  382. {
  383. return 1;
  384. }
  385.  
  386. public OnPlayerStreamOut(playerid, forplayerid)
  387. {
  388. return 1;
  389. }
  390.  
  391. public OnVehicleStreamIn(vehicleid, forplayerid)
  392. {
  393. return 1;
  394. }
  395.  
  396. public OnVehicleStreamOut(vehicleid, forplayerid)
  397. {
  398. return 1;
  399. }
  400.  
  401. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  402. {
  403. if(dialogid == DIALOG_BUY)
  404. {
  405. for(new b=0;b<bizid+1;b++)
  406. {
  407. if(response)
  408. {
  409. if(IsPlayerInRangeOfPoint(playerid,2.0,BizInfo[b][bXcoord],BizInfo[b][bYcoord],BizInfo[b][bZcoord]))
  410. {
  411. if(GetPlayerMoney(playerid) >= BizInfo[b][bPrice])
  412. {
  413. GivePlayerMoney(playerid, -BizInfo[b][bPrice]);
  414. format(BizInfo[b][bOwner],MAX_PLAYERS,"%s",GetName(playerid));
  415. BizInfo[b][bOwned] = 1;
  416. SaveEBiz(b);
  417. LoadEBizz(b);
  418. }
  419. }
  420. }
  421. }
  422. }
  423. return 1;
  424. }
  425.  
  426. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  427. {
  428. return 1;
  429. }
Advertisement
Add Comment
Please, Sign In to add comment