Advertisement
Guest User

Business system by Flaken/EquinoX

a guest
Feb 22nd, 2014
2,007
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.60 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4.  
  5. #include <a_samp>
  6. #include <ZCMD>
  7. #include <dini>
  8. #include <dudb>
  9. #include <dutils>
  10. #include <YSI\y_ini>
  11. #include <streamer>
  12. #include <sscanf2>
  13. #include <foreach>
  14.  
  15. #pragma tabsize 0
  16. #define FILTERSCRIPT
  17. // Color Defines
  18. #define COLOR_WHITE 0xFFFFFFFF
  19. #define COLOR_FADE1 0xE6E6E6E6
  20. #define COLOR_PM1 0xA65FC7FF
  21. #define COLOR_PM2 0xD35FC7FF
  22. #define COLOR_FADE2 0xC8C8C8C8
  23. #define COLOR_FADE3 0xAAAAAAAA
  24. #define COLOR_FADE4 0x8C8C8C8C
  25. #define COLOR_FADE5 0x6E6E6E6E
  26. #define COLOR_OOC 0xE0FFFFFF
  27. #define COLOR_GREY 0xAFAFAFFF
  28. #define COLOR_LIGHTGREEN 0xADFF2FFF
  29. #define COLOR_LIGHTRED 0xFF6347FF
  30. #define COLOR_DARKRED 0xAA3333FF
  31. #define COLOR_RED 0xFF0606FF
  32. #define COLOR_LIGHTBLUE 0x33CCFFFF
  33. #define COLOR_GREEN 0x33AA33FF
  34. #define COLOR_YELLOW 0xFFFF00FF
  35. #define COLOR_PURPLE 0xC2A2DAFF
  36. #define COLOR_ORANGE 0xFF9900FF
  37. #define COLOR_REPORT 0xFFFF91FF
  38. #define COLOR_RADIO 0x8D8DFFFF
  39. #define COLOR_DEPTRADIO 0xFFD700FF
  40. #define COLOR_BLUE 0x2641FEFF
  41. #define COLOR_MEDIC 0xFF8282FF
  42. #define COLOR_NEWBIE 0x7DAEFFFF
  43. #define COLOR_LIME 0x00FF00FF
  44. #define COLOR_NEWS 0x049C7100
  45. #define COLOR_CYAN 0x01FCFFFF
  46. #define COLOR_VIP 0xC93CCEFF
  47. #define COLOR_GOLD 0xFFD700FF
  48.  
  49. // Biz Defines
  50. #define MAX_BIZ 201
  51. #define COE "{F07B0F}"
  52. #define CWE "{FFFFFF}"
  53. #define CGE "{2A8A07}"
  54.  
  55. enum pInfo
  56. {
  57. pAdmin,
  58. pCash,
  59. pBiz,
  60. pMaskOn,
  61. pHideOn,
  62. pVBiz
  63. };
  64. new PlayerInfo[MAX_PLAYERS][pInfo];
  65.  
  66. enum bizInfo
  67. {
  68. bType,
  69. bStatus,
  70. bOwner[32],
  71. Float:bX,
  72. Float:bY,
  73. Float:bZ,
  74. bPickup,
  75. bMoney,
  76. bProducts,
  77. Text3D:bText,
  78. bSold,
  79. bLevel,
  80. bPrice,
  81. bAP
  82. }
  83. new BizInfo[MAX_BIZ][bizInfo];
  84.  
  85. public OnFilterScriptInit()
  86. {
  87. LoadBiz();
  88. print("\n--------------------------------------");
  89. print(" Business System By EquinoX/Flaken");
  90. print("--------------------------------------\n");
  91. return 1;
  92. }
  93.  
  94. public OnFilterScriptExit()
  95. {
  96. SaveBiz();
  97. return 1;
  98. }
  99. stock CheckFiles()
  100. {
  101. if(!dini_Exists("businesses.cfg")) dini_Create("businesses.cfg");
  102. return 1;
  103. }
  104. stock LoadBiz()
  105. {
  106. if(!fexist("businesses.cfg")) fcreate("businesses.cfg");
  107. new binfo[12][32];
  108. new string[256];
  109. new File:file = fopen("businesses.cfg", io_read);
  110. if(file)
  111. {
  112. new idx = 1;
  113. while(idx < MAX_BIZ)
  114. {
  115. fread(file, string);
  116. split(string, binfo, '|');
  117. BizInfo[idx][bType] = strval(binfo[0]);
  118. BizInfo[idx][bStatus] = strval(binfo[1]);
  119. format(BizInfo[idx][bOwner], 32, "%s", binfo[2]);
  120. BizInfo[idx][bX] = floatstr(binfo[3]);
  121. BizInfo[idx][bY] = floatstr(binfo[4]);
  122. BizInfo[idx][bZ] = floatstr(binfo[5]);
  123. BizInfo[idx][bMoney] = strval(binfo[6]);
  124. BizInfo[idx][bProducts] = strval(binfo[7]);
  125. BizInfo[idx][bSold] = strval(binfo[8]);
  126. BizInfo[idx][bLevel] = strval(binfo[9]);
  127. BizInfo[idx][bPrice] = strval(binfo[10]);
  128. BizInfo[idx][bAP] = strval(binfo[11]);
  129. if(BizInfo[idx][bType]) // If Business is owned
  130. {
  131. BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], 0);
  132. if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  133. //else format(string, sizeof(string), "ID: %d\n%s\nOwner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  134. else format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  135. BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]+0.3, 15);
  136. }
  137. idx++;
  138. }
  139. }
  140. print("Businesses loaded successfully.");
  141. return 1;
  142. }
  143.  
  144. stock SaveBiz()
  145. {
  146. if(!fexist("businesses.cfg")) fcreate("businesses.cfg");
  147. new idx = 1, File:file;
  148. new string[256];
  149. while(idx < MAX_BIZ)
  150. {
  151. format(string, sizeof(string), "%d|%d|%s|%f|%f|%f|%d|%d|%d|%d|%d|%d\r\n", BizInfo[idx][bType], BizInfo[idx][bStatus], BizInfo[idx][bOwner], BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ], BizInfo[idx][bMoney], BizInfo[idx][bProducts], BizInfo[idx][bSold], BizInfo[idx][bLevel], BizInfo[idx][bPrice], BizInfo[idx][bAP]);
  152. if(idx == 1)
  153. {
  154. file = fopen("businesses.cfg", io_write);
  155. }
  156. else
  157. {
  158. file = fopen("businesses.cfg", io_append);
  159. }
  160. fwrite(file, string);
  161. fclose(file);
  162. idx++;
  163. }
  164. print("Businesses saved successfully.");
  165. }
  166. public OnPlayerConnect( playerid )
  167. {
  168. SendClientMessage(playerid, COLOR_GREY,"This server is using Flaken's business system!");
  169. return 1;
  170. }
  171.  
  172. CMD:createbiz(playerid, params[])
  173. {
  174. new type, string[128];
  175. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  176. if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  177. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  178. if(sscanf(params, "i", type))
  179. {
  180. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createbiz [type]");
  181. SendClientMessage(playerid, COLOR_GREY, "TYPES: 1) 24/7 | 2) Clothes Shop | 3) Ammunation | 4) Club | 5) Advertisement Agency | 6) Fast Food | 7) Casino");
  182. return 1;
  183. }
  184. if(type < 1 || type > 7) return SendClientMessage(playerid, COLOR_GREY, "Businesses are between 1 and 7.");
  185. for(new idx=1; idx<MAX_BIZ; idx++)
  186. {
  187. if(!BizInfo[idx][bType])
  188. {
  189. //g_bizRobber[idx] = -1;
  190. // Getting Business Setup
  191. new Float:X, Float:Y, Float:Z;
  192. GetPlayerPos(playerid, X, Y, Z);
  193. // Making Business
  194. BizInfo[idx][bType] = type;
  195. BizInfo[idx][bStatus] = 0;
  196. format(BizInfo[idx][bOwner], 32, "The State");
  197. BizInfo[idx][bX] = X;
  198. BizInfo[idx][bY] = Y;
  199. BizInfo[idx][bZ] = Z;
  200. BizInfo[idx][bMoney] = 0;
  201. BizInfo[idx][bProducts] = 0;
  202. BizInfo[idx][bSold] = 0;
  203. BizInfo[idx][bLevel] = 1;
  204. BizInfo[idx][bPrice] = 500000;
  205. BizInfo[idx][bPickup] = CreateDynamicPickup(1272, 1, X, Y, Z, 0);
  206. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  207. BizInfo[idx][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, X, Y, Z, 15);
  208. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created business ID %d.", RPN(playerid), idx);
  209. //SendAdminMessage(COLOR_DARKRED, 1, string);
  210. Log("logs/business.log", string);
  211. idx = MAX_BIZ;
  212. }
  213. }
  214. return 1;
  215. }
  216.  
  217. CMD:deletebiz(playerid, params[])
  218. {
  219. new id, string[128];
  220. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  221. if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  222. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  223. if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deletebiz [bizid]");
  224. if(!BizInfo[id][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  225. foreach(Player, i)
  226. {
  227. if(IsPlayerConnected(i) && PlayerInfo[i][pBiz] == id)
  228. {
  229. PlayerInfo[playerid][pBiz] = 0;
  230. format(string, sizeof(string), " Adminstrator %s has deleted your business.", RPN(playerid));
  231. SendClientMessage(i, COLOR_WHITE, string);
  232. }
  233. }
  234. if(!strcmp("The State", BizInfo[id][bOwner]))
  235. {
  236. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has deleted business ID %d.", RPN(playerid), id);
  237. }
  238. else
  239. {
  240. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has deleted %s's business. (ID %d)", RPN(playerid), BizInfo[id][bOwner], id);
  241. }
  242. //SendAdminMessage(COLOR_DARKRED, 1, string);
  243. Log("logs/business.log", string);
  244. BizInfo[id][bType] = 0;
  245. BizInfo[id][bStatus] = 0;
  246. format(BizInfo[id][bOwner], 32, "");
  247. BizInfo[id][bX] = 0;
  248. BizInfo[id][bY] = 0;
  249. BizInfo[id][bZ] = 0;
  250. BizInfo[id][bMoney] = 0;
  251. BizInfo[id][bProducts] = 0;
  252. DestroyDynamicPickup(BizInfo[id][bPickup]);
  253. DestroyDynamic3DTextLabel(BizInfo[id][bText]);
  254. return 1;
  255. }
  256. CMD:bizhelp(playerid, params[])
  257. {
  258. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  259. SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS: {FFFFFF}/buybiz");
  260. if(PlayerInfo[playerid][pBiz] || PlayerInfo[playerid][pVBiz]) SendClientMessage(playerid, COLOR_YELLOW, "BUSINESS OWNER: {FFFFFF}/vault /lock /buyproducts /sellbiztomarket");
  261. return 1;
  262. }
  263. CMD:vault(playerid, params[])
  264. {
  265. new value, string[128];
  266. new idx = PlayerInfo[playerid][pBiz];
  267. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  268. if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a busines.");
  269. if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  270. if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
  271. {
  272. idx = PlayerInfo[playerid][pVBiz];
  273. if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  274. }
  275. if(sscanf(params, "s[32]", params))
  276. {
  277. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault [option]");
  278. SendClientMessage(playerid, COLOR_GREY, "OPTIONS: withdraw | deposit");
  279. return 1;
  280. }
  281. if(!strcmp(params, "withdraw", false, 8))
  282. {
  283. if(sscanf(params, "s[32]i", params, value))
  284. {
  285. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault withdraw [amount]");
  286. format(string, sizeof(string), "Current Vault Money: $%d", BizInfo[idx][bMoney]);
  287. SendClientMessage(playerid, COLOR_GREY, string);
  288. return 1;
  289. }
  290. if(value > BizInfo[idx][bMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have this much money in your business vault.");
  291. BizInfo[idx][bMoney] -= value;
  292. GivePlayerCash(playerid, value);
  293. format(string, sizeof(string), "* %s has withdrawn money from their business vault.", RPN(playerid));
  294. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  295. format(string, sizeof(string), " You have withdrawn $%d from your business vault, amount left: $%d", value, BizInfo[idx][bMoney]);
  296. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  297. }
  298. else if(!strcmp(params, "deposit", false, 7))
  299. {
  300. if(sscanf(params, "s[32]i", params, value))
  301. {
  302. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /vault deposit [amount]");
  303. format(string, sizeof(string), "Current Vault Money: $%d", BizInfo[idx][bMoney]);
  304. SendClientMessage(playerid, COLOR_GREY, string);
  305. return 1;
  306. }
  307. if(value > PlayerInfo[playerid][pCash]) return SendClientMessage(playerid, COLOR_GREY, "You don't have this much money on you.");
  308. BizInfo[idx][bMoney] += value;
  309. GivePlayerCash(playerid, -value);
  310. format(string, sizeof(string), "* %s has deposited money to their business vault.", RPN(playerid));
  311. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  312. format(string, sizeof(string), " You have deposited $%d to your business vault, current amount: $%d", value, BizInfo[idx][bMoney]);
  313. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  314. }
  315. return 1;
  316. }
  317. /*CMD:buyproducts(playerid, params[])
  318. {
  319. new amount, price, string[128];
  320. new idx = PlayerInfo[playerid][pBiz];
  321. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  322. if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
  323. if(GetPlayerVirtualWorld(playerid)-100 != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  324. if(GetPlayerVirtualWorld(playerid)-100 != idx && PlayerInfo[playerid][pVBiz])
  325. {
  326. idx = PlayerInfo[playerid][pVBiz];
  327. if(GetPlayerVirtualWorld(playerid)-100 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your business.");
  328. }
  329. if(sscanf(params, "i", amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buyproducts [amount]");
  330. if(amount < 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid products amount.");
  331. if(Products < amount)
  332. {
  333. format(string, sizeof(string), "The products dropoff currently has %d products only.", Products);
  334. SendClientMessage(playerid, COLOR_GREY, string);
  335. return 1;
  336. }
  337. price = amount*20;
  338. if(PlayerInfo[playerid][pCash] < price)
  339. {
  340. format(string, sizeof(string), "You don't have that much money on you. ($%d)", price);
  341. SendClientMessage(playerid, COLOR_GREY, string);
  342. return 1;
  343. }
  344. if(BizInfo[idx][bProducts]+amount > 500) return SendClientMessage(playerid, COLOR_GREY, "Your business can't hold that much products.");
  345. GivePlayerCash(playerid, -price);
  346. BizInfo[idx][bProducts] += amount;
  347. Products -= amount;
  348. format(string, sizeof(string), "* %s has purchased %d products for $%d.", RPN(playerid), amount, price);
  349. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  350. format(string, sizeof(string), "Packages Dropoff\n{FFFF00}/deliverpackages to deliver crates\nAvailable Products: %d/20000", Products);
  351. UpdateDynamic3DTextLabelText(ProductsText, COLOR_RED, string);
  352. return 1;
  353. }*/
  354. /*CMD:lockb(playerid, params[])
  355. {
  356. new string[128], idx, done, lockdone;
  357. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  358. if(PlayerInfo[playerid][pBiz])
  359. {
  360. if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
  361. {
  362. if(!BizInfo[PlayerInfo[playerid][pBiz]][bStatus])
  363. {
  364. BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 1;
  365. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", PlayerInfo[playerid][pBiz], RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], RBS(PlayerInfo[playerid][pBiz]));
  366. UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
  367. format(string, sizeof(string), "* %s takes out their business keys and unlocks it.", RPN(playerid));
  368. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  369. GameTextForPlayer(playerid, "~g~Business Unlocked", 3500, 3);
  370. }
  371. else if(BizInfo[PlayerInfo[playerid][pBiz]][bStatus])
  372. {
  373. BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 0;
  374. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", PlayerInfo[playerid][pBiz], RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], RBS(PlayerInfo[playerid][pBiz]));
  375. UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
  376. format(string, sizeof(string), "* %s takes out their business keys and locks it.", RPN(playerid));
  377. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  378. GameTextForPlayer(playerid, "~r~Business Locked", 3500, 3);
  379. }
  380. done = 1;
  381. lockdone = 1;
  382. }
  383. }
  384. return 1;
  385. }*/
  386. CMD:buybiz(playerid, params[])
  387. {
  388. new string[128], done;
  389. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  390. if(PlayerInfo[playerid][pBiz] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already own a businesses.");
  391. //if(PlayerInfo[playerid][pBiz] && PlayerInfo[playerid][pVIP] < 4) return SendClientMessage(playerid, COLOR_GREY, "You already own a business.");
  392. for(new idx=1; idx<MAX_BIZ; idx++)
  393. {
  394. if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
  395. {
  396. if(!strcmp("The State", BizInfo[idx][bOwner], false))
  397. {
  398. if(GetPlayerMoney(playerid) < BizInfo[idx][bPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this business.");
  399. {
  400. GivePlayerCash(playerid, -BizInfo[idx][bPrice]);
  401. if(PlayerInfo[playerid][pBiz]) PlayerInfo[playerid][pVBiz] = idx;
  402. else PlayerInfo[playerid][pBiz] = idx;
  403. format(BizInfo[idx][bOwner], 32, "%s", RPNU(playerid));
  404. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  405. UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
  406. SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a business.");
  407. SendClientMessage(playerid, COLOR_WHITE, " Type /bizhelp to view your business commands.");
  408. BizInfo[idx][bProducts] = 99999;
  409. format(string, sizeof(string), "%s has bought business id %d.", RPN(playerid), idx);
  410. Log("logs/business.log", string);
  411. idx = MAX_BIZ;
  412. done = 1;
  413. }
  414. if(idx == MAX_BIZ-1 && !done)
  415. {
  416. SendClientMessage(playerid, COLOR_GREY, "This business is owned by someone else.");
  417. }
  418. }
  419. if(idx == MAX_BIZ-1 && !done)
  420. {
  421. SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable business.");
  422. }
  423. }
  424. }
  425. return 1;
  426. }
  427.  
  428.  
  429.  
  430. CMD:sellbiztomarket(playerid, params[])
  431. {
  432. new string[128];
  433. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  434. if(!PlayerInfo[playerid][pBiz] && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a business.");
  435. if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellbiztomarket confirm");
  436. if(!strcmp(params, "confirm", true))
  437. {
  438. new done;
  439. if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[PlayerInfo[playerid][pBiz]][bX], BizInfo[PlayerInfo[playerid][pBiz]][bY], BizInfo[PlayerInfo[playerid][pBiz]][bZ]))
  440. {
  441. GivePlayerCash(playerid, (75*BizInfo[PlayerInfo[playerid][pBiz]][bPrice])/100);
  442. BizInfo[PlayerInfo[playerid][pBiz]][bStatus] = 0;
  443. format(BizInfo[PlayerInfo[playerid][pBiz]][bOwner], 32, "The State");
  444. format(string, sizeof(string), "[Business ID:% d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", PlayerInfo[playerid][pBiz], RBT(PlayerInfo[playerid][pBiz]), BizInfo[PlayerInfo[playerid][pBiz]][bOwner], BizInfo[PlayerInfo[playerid][pBiz]][bPrice]);
  445. UpdateDynamic3DTextLabelText(BizInfo[PlayerInfo[playerid][pBiz]][bText], COLOR_WHITE, string);
  446. SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your business to The State. (75 percent of original price was paid back)");
  447. format(string, sizeof(string), "%s has sold business id %d to the market.", RPN(playerid), PlayerInfo[playerid][pBiz]);
  448. Log("logs/business.log", string);
  449. PlayerInfo[playerid][pBiz] = 0;
  450. done = 1;
  451. }
  452. if(!done)
  453. {
  454. new idx = PlayerInfo[playerid][pVBiz];
  455. if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
  456. {
  457. GivePlayerCash(playerid, (75*BizInfo[idx][bPrice])/100);
  458. BizInfo[idx][bStatus] = 0;
  459. format(BizInfo[idx][bOwner], 32, "The State");
  460. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  461. UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITE, string);
  462. SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your business to The State. (75 percent of original price was paid back)");
  463. format(string, sizeof(string), "%s has sold business id %d to the market.", RPN(playerid), idx);
  464. Log("logs/business.log", string);
  465. PlayerInfo[playerid][pVBiz] = 0;
  466. done = 1;
  467. }
  468. }
  469. if(!done)
  470. {
  471. SendClientMessage(playerid, COLOR_GREY, "You are not near your business.");
  472. return 1;
  473. }
  474. }
  475. return 1;
  476. }
  477. CMD:enter(playerid, params[])
  478. {
  479. new string[128];
  480. for(new idx=1; idx<MAX_BIZ; idx++)
  481. {
  482. if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]))
  483. {
  484. if(!BizInfo[idx][bStatus] && PlayerInfo[playerid][pBiz] != idx && !PlayerInfo[playerid][pVBiz]) return SendClientMessage(playerid, COLOR_GREY, "This business is closed.");
  485. if(BizInfo[idx][bType] == 1) // 24/7 Business
  486. {
  487. format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  488. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  489. SetPlayerPos(playerid, -27.3025,-57.6649,1003.5469);
  490. SetPlayerFacingAngle(playerid, 357.5915);
  491. SetCameraBehindPlayer(playerid);
  492. SetPlayerInterior(playerid, 6);
  493. SetPlayerVirtualWorld(playerid, idx+100);
  494. format(string, sizeof(string), "** Welcome to %s's 24/7 Market (( /list & /buy )) **", BizInfo[idx][bOwner]);
  495. SendClientMessage(playerid, COLOR_ORANGE, string);
  496. return 1;
  497. }
  498. else if(BizInfo[idx][bType] == 2) // Clothes Shop Business
  499. {
  500. format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  501. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  502. SetPlayerPos(playerid, 207.0638,-139.9965,1003.5078);
  503. SetPlayerFacingAngle(playerid, 356.3849);
  504. SetCameraBehindPlayer(playerid);
  505. SetPlayerInterior(playerid, 3);
  506. SetPlayerVirtualWorld(playerid, idx+100);
  507. format(string, sizeof(string), "** Welcome to %s's Clothes Shop (( /buyclothes(old) & /buytoys )) **", BizInfo[idx][bOwner]);
  508. SendClientMessage(playerid, COLOR_ORANGE, string);
  509. return 1;
  510. }
  511. else if(BizInfo[idx][bType] == 3) // Ammunation Business
  512. {
  513. format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  514. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  515. SetPlayerPos(playerid, 285.8044,-85.9956,1001.5229);
  516. SetPlayerFacingAngle(playerid, 358.9898);
  517. SetCameraBehindPlayer(playerid);
  518. SetPlayerInterior(playerid, 4);
  519. SetPlayerVirtualWorld(playerid, idx+100);
  520. format(string, sizeof(string), "** Welcome to %s's Ammunation (( /list & /buy /buyweapon )) **", BizInfo[idx][bOwner]);
  521. SendClientMessage(playerid, COLOR_ORANGE, string);
  522. return 1;
  523. }
  524. else if(BizInfo[idx][bType] == 4) // Club Business
  525. {
  526. format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  527. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  528. SetPlayerPos(playerid, 493.4252,-24.3061,1000.6797);
  529. SetPlayerFacingAngle(playerid, 0.2432);
  530. SetCameraBehindPlayer(playerid);
  531. SetPlayerInterior(playerid, 17);
  532. SetPlayerVirtualWorld(playerid, idx+100);
  533. format(string, sizeof(string), "** Welcome to %s's Club (( /list & /buy )) **", BizInfo[idx][bOwner]);
  534. SendClientMessage(playerid, COLOR_ORANGE, string);
  535. return 1;
  536. }
  537. else if(BizInfo[idx][bType] == 5) // Advertisement Agency
  538. {
  539. format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  540. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  541. SetPlayerPos(playerid, 834.1631,7.4883,1004.1797);
  542. SetPlayerFacingAngle(playerid, 86.7239);
  543. SetCameraBehindPlayer(playerid);
  544. SetPlayerInterior(playerid, 3);
  545. SetPlayerVirtualWorld(playerid, idx+100);
  546. format(string, sizeof(string), "** Welcome to %s's Advertisement Agency (( /ad )) **", BizInfo[idx][bOwner]);
  547. SendClientMessage(playerid, COLOR_ORANGE, string);
  548. return 1;
  549. }
  550. else if(BizInfo[idx][bType] == 6) // Fast Food
  551. {
  552. format(string, sizeof(string), "* %s pushes the door and enters the shop.", RPN(playerid));
  553. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  554. SetPlayerPos(playerid, 372.3830,-133.2579,1001.4922);
  555. SetPlayerFacingAngle(playerid, 0.4216);
  556. SetCameraBehindPlayer(playerid);
  557. SetPlayerInterior(playerid, 5);
  558. SetPlayerVirtualWorld(playerid, idx+100);
  559. format(string, sizeof(string), "** Welcome to %s's Fast Food (( /list /buy )) **", BizInfo[idx][bOwner]);
  560. SendClientMessage(playerid, COLOR_ORANGE, string);
  561. return 1;
  562. }
  563. else if(BizInfo[idx][bType] == 7) // Casino
  564. {
  565. format(string, sizeof(string), "* %s pushes the door and enters the casino.", RPN(playerid));
  566. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  567. SetPlayerPos(playerid, 2233.8032,1712.2303,1011.7632);
  568. SetPlayerFacingAngle(playerid, 0.4216);
  569. SetCameraBehindPlayer(playerid);
  570. SetPlayerInterior(playerid, 1);
  571. SetPlayerVirtualWorld(playerid, idx+100);
  572. format(string, sizeof(string), "** Welcome to %s's Casino (( /list /buy )) **", BizInfo[idx][bOwner]);
  573. SendClientMessage(playerid, COLOR_ORANGE, string);
  574. return 1;
  575. }
  576. }
  577. }
  578. return 1;
  579. }
  580. CMD:exit(playerid, params[])
  581. {
  582. new done, string[128];
  583. if(IsPlayerInRangeOfPoint(playerid, 5, 2233.8032,1712.2303,1011.7632) || IsPlayerInRangeOfPoint(playerid, 2, -27.3025,-57.6649,1003.5469) || IsPlayerInRangeOfPoint(playerid, 2, 207.0638,-139.9965,1003.5078) || IsPlayerInRangeOfPoint(playerid, 2, 285.8044,-85.9956,1001.5229) || IsPlayerInRangeOfPoint(playerid, 2, 493.4252,-24.3061,1000.6797) || IsPlayerInRangeOfPoint(playerid, 2, 834.1631,7.4883,1004.1797) || IsPlayerInRangeOfPoint(playerid, 2, 372.3830,-133.2579,1001.4922))
  584. {
  585. new idx;
  586. idx = GetPlayerVirtualWorld(playerid)-100;
  587. if(!done && idx < MAX_BIZ && BizInfo[idx][bType])
  588. {
  589. if(BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ])
  590. {
  591. idx = GetPlayerVirtualWorld(playerid)-100;
  592. if(!done && idx < MAX_BIZ && BizInfo[idx][bType])
  593. {
  594. SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
  595. SetPlayerInterior(playerid, 0);
  596. SetPlayerVirtualWorld(playerid, 0);
  597. }
  598. done = 1;
  599. return 1;
  600. }
  601. format(string, sizeof(string), "* %s pushes the door and exits the shop.", RPN(playerid));
  602. if(PlayerInfo[playerid][pMaskOn] == 1)
  603. {
  604. format(string, sizeof(string), "* Stranger pushes the door and exits the shop.");
  605. }
  606. else
  607. {
  608. format(string, sizeof(string), "* %s pushes the door and exits the shop.", RPN(playerid));
  609. }
  610. SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  611. SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
  612. SetPlayerInterior(playerid, 0);
  613. SetPlayerVirtualWorld(playerid, 0);
  614. }
  615. done = 1;
  616. }
  617. return 1;
  618. }
  619. CMD:bused(playerid, params[])
  620. {
  621. new string[128];
  622. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  623. if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
  624. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  625. SendClientMessage(playerid, COLOR_ORANGE, "[Used Businesses]:");
  626. for(new idx=1; idx<MAX_BIZ; idx++)
  627. {
  628. if(BizInfo[idx][bType])
  629. {
  630. format(string, sizeof(string), "ID: %d | Type: %s | Level: %d | Price: $%d | Products: %d | Vault: $%d | Owner: %s", idx, RBT(idx), BizInfo[idx][bLevel], BizInfo[idx][bPrice],BizInfo[idx][bProducts], BizInfo[idx][bMoney], BizInfo[idx][bOwner]);
  631. SendClientMessage(playerid, COLOR_ORANGE, string);
  632. }
  633. }
  634. return 1;
  635. }
  636. CMD:bedit(playerid, params[])
  637. {
  638. new bizid, string[128], input;
  639. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  640. if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  641. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  642. if(sscanf(params, "s[32]", params))
  643. {
  644. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit [option] [bizid]");
  645. SendClientMessage(playerid, COLOR_GREY, "OPTIONS: location | price | level | products | vault | truckers");
  646. return 1;
  647. }
  648. if(!strcmp(params, "location", true, 8))
  649. {
  650. if(sscanf(params, "s[32]i", params, bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit location [bizid]");
  651. new idx=bizid;
  652. if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  653. GetPlayerPos(playerid, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ]);
  654. DestroyDynamicPickup(BizInfo[bizid][bPickup]);
  655. BizInfo[bizid][bPickup] = CreateDynamicPickup(1272, 1, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ], 0);
  656. DestroyDynamic3DTextLabel(BizInfo[bizid][bText]);
  657. if(!strcmp("The State", BizInfo[idx][bOwner])) format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", idx, RBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
  658. else format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: %s", idx, RBT(idx), BizInfo[idx][bOwner], RBS(idx));
  659. BizInfo[bizid][bText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, BizInfo[bizid][bX], BizInfo[bizid][bY], BizInfo[bizid][bZ]+0.3, 15);
  660. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has changed business ID %d's location.", NORPN(playerid), bizid);
  661. //SendAdminMessage(COLOR_DARKRED, 1, string);
  662. Log("logs/business.log", string);
  663. }
  664. else if(!strcmp(params, "price", true, 5))
  665. {
  666. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit price [bizid] [price]");
  667. if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  668. if(strcmp("The State", BizInfo[bizid][bOwner])) return SendClientMessage(playerid, COLOR_GREY, "You can't edit the price of owned businesses.");
  669. BizInfo[bizid][bPrice] = input;
  670. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", bizid, RBT(bizid), BizInfo[bizid][bOwner], BizInfo[bizid][bPrice]);
  671. UpdateDynamic3DTextLabelText(BizInfo[bizid][bText], COLOR_WHITE, string);
  672. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's price to $%d.", NORPN(playerid), bizid, input);
  673. //SendAdminMessage(COLOR_DARKRED, 1, string);
  674. Log("logs/business.log", string);
  675. }
  676. else if(!strcmp(params, "level", true, 5))
  677. {
  678. // L1: 0 | L2: 100 | L3: 300 | L4: 700 | L5: 1200
  679. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit level [bizid] [level]");
  680. if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  681. if(input < 0 || input > 5) return SendClientMessage(playerid, COLOR_GREY, "Levels are between 1 and 5.");
  682. BizInfo[bizid][bLevel] = input;
  683. if(input == 1) BizInfo[bizid][bSold] = 0;
  684. if(input == 2) BizInfo[bizid][bSold] = 100;
  685. if(input == 3) BizInfo[bizid][bSold] = 300;
  686. if(input == 4) BizInfo[bizid][bSold] = 700;
  687. if(input == 5) BizInfo[bizid][bSold] = 1200;
  688. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's level to %d.", NORPN(playerid), bizid, input);
  689. //SendAdminMessage(COLOR_DARKRED, 1, string);
  690. Log("logs/business.log", string);
  691. }
  692. else if(!strcmp(params, "products", true, 8))
  693. {
  694. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit products [bizid] [amount]");
  695. if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  696. if(input < 0) return SendClientMessage(playerid, COLOR_GREY, "Products can't be negative.");
  697. BizInfo[bizid][bProducts] = input;
  698. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's products to %d.", NORPN(playerid), bizid, input);
  699. //SendAdminMessage(COLOR_DARKRED, 1, string);
  700. Log("logs/business.log", string);
  701. }
  702. else if(!strcmp(params, "vault", true, 5))
  703. {
  704. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit vault [bizid] [amount]");
  705. if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  706. if(input < 0) return SendClientMessage(playerid, COLOR_GREY, "Vault money can't be negative.");
  707. BizInfo[bizid][bMoney] = input;
  708. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d's vault money to $%d.", NORPN(playerid), bizid, input);
  709. //SendAdminMessage(COLOR_DARKRED, 1, string);
  710. Log("logs/business.log", string);
  711. }
  712. else if(!strcmp(params, "truckers", true, 8))
  713. {
  714. if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bedit truckers [bizid] [type] (1=Accepting | 2=NotAccepting");
  715. if(!BizInfo[bizid][bAP])
  716. {
  717. BizInfo[bizid][bAP] = 1;
  718. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d to accept truckers.", NORPN(playerid), bizid);
  719. //SendAdminMessage(COLOR_DARKRED, 1, string);
  720. Log("logs/business.log", string);
  721. }
  722. else
  723. {
  724. BizInfo[bizid][bAP] = 0;
  725. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set business ID %d to NOT accept truckers.", NORPN(playerid), bizid);
  726. //SendAdminMessage(COLOR_DARKRED, 1, string);
  727. Log("logs/business.log", string);
  728. }
  729. }
  730. return 1;
  731. }
  732. CMD:gotobiz(playerid, params[])
  733. {
  734. new idx, string[128];
  735. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  736. if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  737. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  738. if(sscanf(params, "i", idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotobiz [bizid]");
  739. if(!BizInfo[idx][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  740. SetPlayerVirtualWorld(playerid, 0);
  741. SetPlayerInterior(playerid, 0);
  742. SetPlayerPos(playerid, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ]);
  743. format(string, sizeof(string), " You have teleported to business ID %d.", idx);
  744. SendClientMessage(playerid, COLOR_WHITE, string);
  745. return 1;
  746. }
  747.  
  748. CMD:asellbiz(playerid, params[])
  749. {
  750. new bizid, string[128];
  751. if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  752. if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an authorized to use this command.");
  753. // if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
  754. if(sscanf(params, "i", bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /asellbiz [bizid]");
  755. if(!BizInfo[bizid][bType]) return SendClientMessage(playerid, COLOR_GREY, "Invalid business id.");
  756. if(!strcmp("The State", BizInfo[bizid][bOwner], true)) return SendClientMessage(playerid, COLOR_GREY, "This business is not owned by anybody.");
  757. foreach(Player, i)
  758. {
  759. if(IsPlayerConnected(i) && PlayerInfo[i][pBiz] == bizid)
  760. {
  761. PlayerInfo[i][pBiz] = 0;
  762. format(string, sizeof(string), " Administrator %s has sold your business.", RPN(playerid));
  763. SendClientMessage(i, COLOR_WHITE, string);
  764. }
  765. }
  766. format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has sold %s's business. (ID %d)", RPN(playerid), BizInfo[bizid][bOwner], bizid);
  767. //SendAdminMessage(COLOR_DARKRED, 1, string);
  768. Log("logs/business.log", string);
  769. BizInfo[bizid][bStatus] = 0;
  770. format(BizInfo[bizid][bOwner], 32, "The State");
  771. format(string, sizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d", bizid, RBT(bizid), BizInfo[bizid][bOwner], BizInfo[bizid][bPrice]);
  772. UpdateDynamic3DTextLabelText(BizInfo[bizid][bText], COLOR_WHITE, string);
  773. return 1;
  774. }
  775. stock GivePlayerCash(playerid, money)
  776. {
  777. SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")+money);
  778. GivePlayerMoney(playerid, money);
  779. return 1;
  780. }
  781. stock fcreate(filename[])
  782. {
  783. if (fexist(filename)) return false;
  784. new File:fhnd;
  785. fhnd=fopen(filename,io_write);
  786. if (fhnd) {
  787. fclose(fhnd);
  788. return true;
  789. }
  790. return false;
  791. }
  792. stock RBT(bizid)
  793. {
  794. new string[24];
  795. if(!BizInfo[bizid][bType]) format(string, sizeof(string), "None");
  796. else if(BizInfo[bizid][bType] == 1) format(string, sizeof(string), "24/7 Market");
  797. else if(BizInfo[bizid][bType] == 2) format(string, sizeof(string), "Clothes Shop");
  798. else if(BizInfo[bizid][bType] == 3) format(string, sizeof(string), "Ammunation");
  799. else if(BizInfo[bizid][bType] == 4) format(string, sizeof(string), "Club");
  800. //else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Advertisement Agency");
  801. else if(BizInfo[bizid][bType] == 5) format(string, sizeof(string), "Adv. Agency");
  802. else if(BizInfo[bizid][bType] == 6) format(string, sizeof(string), "Fast Food");
  803. else if(BizInfo[bizid][bType] == 7) format(string, sizeof(string), "Casino");
  804. return string;
  805. }
  806. stock RHS(bizid)
  807. {
  808. new string[16];
  809. if(!HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Closed");
  810. else if(HouseInfo[bizid][hStatus]) format(string, sizeof(string), "Open");
  811. return string;
  812. }
  813.  
  814. stock RBS(bizid)
  815. {
  816. new string[16];
  817. if(!BizInfo[bizid][bStatus]) format(string, sizeof(string), "Closed");
  818. else if(BizInfo[bizid][bStatus]) format(string, sizeof(string), "Open");
  819. return string;
  820. }
  821.  
  822. stock RPBP(playerid)
  823. {
  824. new string[32];
  825. if(!PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "None");
  826. else if(PlayerInfo[playerid][pBiz]) format(string, sizeof(string), "%d", BizInfo[PlayerInfo[playerid][pBiz]][bProducts]);
  827. return string;
  828. }
  829. stock RPN(playerid)
  830. {
  831. new string[25];
  832. if(PlayerInfo[playerid][pMaskOn] == 0)format(string, sizeof(string), "%s", RemoveUnderScore(playerid));
  833. else if(PlayerInfo[playerid][pMaskOn] == 1)format(string, sizeof(string), "Stranger");
  834. return string;
  835. }
  836. stock Log(sz_fileName[], sz_input[]) {
  837.  
  838. new sz_logEntry[156], i_dateTime[2][3], File: fileHandle = fopen(sz_fileName, io_append);
  839. gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
  840. getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
  841. format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
  842. fwrite(fileHandle, sz_logEntry);
  843. return fclose(fileHandle);
  844. }
  845. stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
  846. {
  847. new Float:x, Float:y, Float:z;
  848. GetPlayerPos(playerid, x, y, z);
  849. new Float:ix, Float:iy, Float:iz;
  850. new Float:cx, Float:cy, Float:cz;
  851. foreach(Player, i)
  852. {
  853. if(IsPlayerConnected(i))
  854. {
  855. if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  856. {
  857. GetPlayerPos(i, ix, iy, iz);
  858. cx = (x - ix);
  859. cy = (y - iy);
  860. cz = (z - iz);
  861. if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
  862. {
  863. SendClientMessage(i, col1, string);
  864. }
  865. else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
  866. {
  867. SendClientMessage(i, col2, string);
  868. }
  869. else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
  870. {
  871. SendClientMessage(i, col3, string);
  872. }
  873. else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
  874. {
  875. SendClientMessage(i, col4, string);
  876. }
  877. else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
  878. {
  879. SendClientMessage(i, col5, string);
  880. }
  881. }
  882. }
  883. }
  884. return 1;
  885. }
  886. stock RPNU(playerid)
  887. {
  888. new name[MAX_PLAYER_NAME];
  889. GetPlayerName(playerid, name, sizeof(name));
  890. return name;
  891. }
  892. stock NORPN(playerid)
  893. {
  894. new astring[25];
  895. if(PlayerInfo[playerid][pHideOn] == 0)format(astring, sizeof(astring), "%s", RemoveUnderScore(playerid));
  896. else if(PlayerInfo[playerid][pHideOn] == 1)format(astring, sizeof(astring), "Anon");
  897. return astring;
  898. }
  899. stock RemoveUnderScore(playerid)
  900. {
  901. new name[MAX_PLAYER_NAME];
  902. GetPlayerName(playerid,name,sizeof(name));
  903. for(new i = 0; i < MAX_PLAYER_NAME; i++)
  904. {
  905. if(name[i] == '_') name[i] = ' ';
  906. }
  907. return name;
  908. }
  909. stock split(const strsrc[], strdest[][], delimiter)
  910. {
  911. new i, li;
  912. new aNum;
  913. new len;
  914. while(i <= strlen(strsrc))
  915. {
  916. if(strsrc[i] == delimiter || i == strlen(strsrc))
  917. {
  918. len = strmid(strdest[aNum], strsrc, li, i, 128);
  919. strdest[aNum][len] = 0;
  920. li = i+1;
  921. aNum++;
  922. }
  923. i++;
  924. }
  925. return 1;
  926. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement