Guest User

Jueixs banking

a guest
Dec 23rd, 2013
820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.21 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <Dini>
  4. #include <dudb>
  5. #include <foreach>
  6. #include <sscanf2>
  7. #include <streamer>
  8.  
  9. //ATM Crap
  10. #define MAX_ATM 100
  11. #define MAX_BANK 100
  12. #define MAX_DISTANCE_TO_PROP 1.5
  13. new ATMObject[MAX_ATM];
  14. new Text3D:ATMLabel[MAX_ATM];
  15. new Object[MAX_PLAYERS];
  16. new oModel[MAX_PLAYERS];
  17. new ATMi;
  18. new ATMm[MAX_PLAYERS];
  19. new atms;
  20. new Banks;
  21. new BankObject[MAX_ATM];
  22. new Text3D:BankLabel[MAX_ATM];
  23.  
  24. enum abInfo
  25. {
  26. Float:ATMx,
  27. Float:ATMy,
  28. Float:ATMz,
  29. Float:ATMrx,
  30. Float:ATMry,
  31. Float:ATMrz,
  32. ATMint,
  33. ATMvw,
  34. ATMMoney
  35. }
  36. new ATMInfo[MAX_ATM][abInfo];
  37.  
  38. enum bInfo
  39. {
  40. Float:Bankx,
  41. Float:Banky,
  42. Float:Bankz,
  43. Float:Bankrx,
  44. Float:Bankry,
  45. Float:Bankrz,
  46. Bankint,
  47. Bankvw,
  48. BankMoney
  49. }
  50. new BankInfo[MAX_BANK][bInfo];
  51.  
  52. enum pInfo
  53. {
  54. pBank,
  55. playerenterbankid
  56. }
  57. new PlayerInfo[MAX_PLAYERS][pInfo];
  58. #define ATM_USER_FILE "ATMs/ATMUsers/%s.ini"
  59. //COLOR DEFINES
  60. #define COLOR_YELLOW 0xD8D8D8FF
  61. #define COLOR_FADE1 0xE6E6E6E6
  62. #define COLOR_FADE2 0xC8C8C8C8
  63. #define COLOR_FADE3 0xAAAAAAAA
  64. #define COLOR_FADE4 0x8C8C8C8C
  65. #define COLOR_FADE5 0x6E6E6E6E
  66. #define COLOR_FADE 0xC8C8C8C8
  67. #define COLOR_WHITE 0xFFFFFFAA
  68. #define COLOR_GRAD2 0xBFC0C2FF
  69. #define COLOR_DARKRED 0x8B0000AA
  70. #define COLOR_RED 0xFF0000AA
  71. #define COLOR_LIGHTBLUE 0x33CCFFAA
  72. #define COLOR_GREY 0xAFAFAFAA
  73. #define COLOR_PINK 0xDC00DDAA
  74. #define COLOR_BLUE 0x0259EAAA
  75. #define COLOR_GREEN 0x00A800AA
  76. #define COLOR_ORANGE 0xFF8000AA
  77. #define COLOR_CYAN 0xFF8080AA
  78. #define COLOR_WHITE 0xFFFFFFAA
  79. #define COLOR_DARKBLUE 0x0000A0AA
  80. #define COLOR_BLACK 0x000000AA
  81. #define COLOR_DARKGOLD 0x808000AA
  82. #define COLOR_PURPLE 0xC2A2DAAA
  83. #define COLOR_BROWN 0x804000AA
  84. #define COLOR_BLACK2 0x000000ff
  85. #define COL_EASY "{FFF1AF}"
  86. #define COL_WHITE "{FFFFFF}"
  87. #define COL_BLACK "{0E0101}"
  88. #define COL_GREY "{C3C3C3}"
  89. #define COL_GREEN "{6EF83C}"
  90. #define COL_RED "{F81414}"
  91. #define COL_YELLOW "{F3FF02}"
  92. #define COL_ORANGE "{FFAF00}"
  93. #define COL_LIME "{B7FF00}"
  94. #define COL_CYAN "{00FFEE}"
  95. #define COL_LIGHTBLUE "{00C0FF}"
  96. #define COL_BLUE "{0049FF}"
  97. #define COL_MAGENTA "{F300FF}"
  98. #define COL_VIOLET "{B700FF}"
  99. #define COL_PINK "{FF00EA}"
  100. #define COL_MARONE "{A90202}"
  101. #define COL_CMD "{B8FF02}"
  102. #define COL_PARAM "{3FCD02}"
  103. #define COL_SERVER "{AFE7FF}"
  104. #define COL_VALUE "{A3E4FF}"
  105. #define COL_RULE "{F9E8B7}"
  106. #define COL_RULE2 "{FBDF89}"
  107. #define COL_RWHITE "{FFFFFF}"
  108. #define COL_LGREEN "{C9FFAB}"
  109. #define COL_LRED "{FFA1A1}"
  110. #define COL_LRED2 "{C77D87}"
  111.  
  112. public OnFilterScriptInit()
  113. {
  114. print("\n--------------------------------------");
  115. print(" Jueixs bank system loaded");
  116. print("--------------------------------------\n");
  117. LoadATMs();
  118. LoadBanks();
  119. return 1;
  120. }
  121.  
  122. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  123. {
  124. new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ;
  125. GetObjectPos(objectid, oldX, oldY, oldZ);
  126. GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
  127. new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ,OVW,OINT;
  128. if(!playerobject) // If this is a global object, move it for other players
  129. {
  130. if(!IsValidObject(objectid)) return;
  131. MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
  132. }
  133. if(response == EDIT_RESPONSE_FINAL)
  134. {
  135. if(oModel[playerid] == 2942)
  136. {
  137. new ATMid = GetATMs();
  138. new ATM[256];
  139. format(ATM, sizeof(ATM), "ATMs/%i.ini",ATMid);
  140. OVW = GetPlayerVirtualWorld(playerid);
  141. OINT = GetPlayerInterior(playerid);
  142. GetObjectPos(objectid, OX, OY, OZ);
  143. GetObjectRot(objectid, ORX, ORY, ORZ);
  144. ATMInfo[ATMid][ATMMoney] = ATMm[playerid];
  145. dini_Create(ATM);
  146. dini_IntSet(ATM, "Money", ATMInfo[ATMid][ATMMoney]);
  147. dini_IntSet(ATM, "INT", OINT);
  148. dini_IntSet(ATM, "VW", OVW);
  149. dini_FloatSet(ATM, "ATMX", OX);
  150. dini_FloatSet(ATM, "ATMY", OY);
  151. dini_FloatSet(ATM, "ATMZ", OZ);
  152. dini_FloatSet(ATM, "ATMRX", ORX);
  153. dini_FloatSet(ATM, "ATMRY", ORY);
  154. dini_FloatSet(ATM, "ATMRZ", ORZ);
  155. DestroyObject(Object[playerid]);
  156. ATMObject[ATMid] = CreateObject(2942, OX, OY, OZ, ORX, ORY, ORZ);
  157. new string[256];
  158. format(string, sizeof(string), "ATM type /atmwithdraw and /atmbalance.\nMoney left $%d\nID[%d]",ATMInfo[ATMid][ATMMoney],ATMid);
  159. ATMLabel[ATMid] = Create3DTextLabel(string, 0x008080FF, OX, OY, OZ, 10.0, 0, 1);
  160. }
  161. }
  162. if(response == EDIT_RESPONSE_CANCEL)
  163. {
  164. //The player cancelled, so put the object back to it's old position
  165. if(!playerobject) //Object is not a playerobject
  166. {
  167. SetObjectPos(objectid, oldX, oldY, oldZ);
  168. SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
  169. DestroyObject(Object[playerid]);
  170. }
  171. else
  172. {
  173. SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
  174. SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
  175. DestroyObject(Object[playerid]);
  176. }
  177. }
  178. }
  179.  
  180. public OnPlayerConnect(playerid)
  181. {
  182. new name[MAX_PLAYER_NAME], userfile[256];
  183. GetPlayerName(playerid, name, sizeof(name));
  184. format(userfile, sizeof(userfile), ATM_USER_FILE, name);
  185. if (!dini_Exists(userfile)) {
  186. dini_Create(userfile);
  187. PlayerInfo[playerid][pBank] = 5000;
  188. SaveStats(playerid);
  189. }
  190. if(fexist(userfile)) {
  191. LoadStats(playerid);
  192. }
  193. return 1;
  194. }
  195.  
  196. public OnFilterScriptExit()
  197. {
  198. return 1;
  199. }
  200.  
  201. //ATM Loading
  202. stock LoadATMs()
  203. {
  204. new file[60];
  205. for(new i = 0; i < MAX_ATM;i++)
  206. {
  207. format(file,sizeof(file),"ATMs/%i.ini",i);
  208. if(!dini_Exists(file)) continue;
  209. ATMInfo[i][ATMx] = dini_Float(file, "ATMX");
  210. ATMInfo[i][ATMy] = dini_Float(file, "ATMY");
  211. ATMInfo[i][ATMz] = dini_Float(file, "ATMZ");
  212. ATMInfo[i][ATMrx] = dini_Float(file, "ATMRX");
  213. ATMInfo[i][ATMry] = dini_Float(file, "ATMRY");
  214. ATMInfo[i][ATMrz] = dini_Float(file, "ATMRZ");
  215. ATMInfo[i][ATMvw] = dini_Int(file, "VW");
  216. ATMInfo[i][ATMint] = dini_Int(file, "INT");
  217. ATMInfo[i][ATMMoney] = dini_Int(file, "Money");
  218. ATMObject[i] = CreateObject(2942, ATMInfo[i][ATMx], ATMInfo[i][ATMy], ATMInfo[i][ATMz], ATMInfo[i][ATMrx], ATMInfo[i][ATMry], ATMInfo[i][ATMrz]);
  219. new string[256];
  220. format(string, sizeof(string), "ATM type /atmwithdraw and /atmbalance.\nMoney left $%d",ATMInfo[i][ATMMoney]);
  221. ATMLabel[i] = Create3DTextLabel(string, 0x008080FF, ATMInfo[i][ATMx], ATMInfo[i][ATMy], ATMInfo[i][ATMz], 10.0, 0, 1);
  222. atms++;
  223. }
  224.  
  225. printf("ATMs Created!");
  226. return 1;
  227. }
  228.  
  229. stock LoadBanks()
  230. {
  231. new file[60];
  232. for(new i = 0; i < MAX_BANK;i++)
  233. {
  234. format(file,sizeof(file),"Banks/%i.ini",i);
  235. if(!dini_Exists(file)) continue;
  236. BankInfo[i][Bankx] = dini_Float(file, "BankX");
  237. BankInfo[i][Banky] = dini_Float(file, "BankY");
  238. BankInfo[i][Bankz] = dini_Float(file, "BankZ");
  239. BankInfo[i][Bankrx] = dini_Float(file, "BankRX");
  240. BankInfo[i][Bankry] = dini_Float(file, "BankRY");
  241. BankInfo[i][Bankrz] = dini_Float(file, "BankRZ");
  242. BankInfo[i][Bankvw] = dini_Int(file, "VW");
  243. BankInfo[i][Bankint] = dini_Int(file, "INT");
  244. BankInfo[i][BankMoney] = dini_Int(file, "Money");
  245. BankObject[i] = CreatePickup(1318, 1, BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz], -1);
  246. new string[256];
  247. format(string, sizeof(string), "/enter to enter the bank.\nMoney left in this banks vault $%d.",BankInfo[i][BankMoney]);
  248. BankLabel[i] = Create3DTextLabel(string, 0x008080FF, BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz], 10.0, 0, 1);
  249. Banks++;
  250. }
  251.  
  252. printf("Banks Created!");
  253. return 1;
  254. }
  255.  
  256. stock GetATMs()
  257. {
  258. new file[60];
  259. for(new i = 0; i < MAX_ATM;i++)
  260. {
  261. format(file,sizeof(file),"ATMs/%i.ini",i);
  262. if(!dini_Exists(file)) return i;
  263. }
  264. return -1;
  265. }
  266.  
  267. stock GetBanks()
  268. {
  269. new file[60];
  270. for(new i = 0; i < MAX_BANK;i++)
  271. {
  272. format(file,sizeof(file),"Banks/%i.ini",i);
  273. if(!dini_Exists(file)) return i;
  274. }
  275. return -1;
  276. }
  277.  
  278. stock GetATMID(playerid)
  279. {
  280. for(new i=0; i<MAX_ATM; i++)
  281. {
  282. if(PlayerToPoint(MAX_DISTANCE_TO_PROP, playerid, ATMInfo[i][ATMx],ATMInfo[i][ATMy],ATMInfo[i][ATMz]))
  283. {
  284. return i;
  285. }
  286. }
  287. return 1;
  288. }
  289.  
  290. stock GetBankID(playerid)
  291. {
  292. for(new i=0; i<MAX_BANK; i++)
  293. {
  294. if(PlayerToPoint(MAX_DISTANCE_TO_PROP, playerid, BankInfo[i][Bankx],BankInfo[i][Banky],BankInfo[i][Bankz]))
  295. {
  296. return i;
  297. }
  298. }
  299. return 1;
  300. }
  301.  
  302. stock RandomEx(min, max) //Y_Less
  303. {
  304. return random(max - min) + min;
  305. }
  306.  
  307. stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  308. {
  309. if(IsPlayerConnected(playerid))
  310. {
  311. new Float:oldposx, Float:oldposy, Float:oldposz;
  312. new Float:tempposx, Float:tempposy, Float:tempposz;
  313. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  314. tempposx = (oldposx -x);
  315. tempposy = (oldposy -y);
  316. tempposz = (oldposz -z);
  317. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  318. {
  319. return 1;
  320. }
  321. }
  322. return 0;
  323. }
  324.  
  325. COMMAND:addatm(playerid, params[])
  326. {
  327. new hCost;
  328. if(IsPlayerAdmin(playerid))
  329. {
  330. if(!sscanf(params, "i", hCost))
  331. {
  332. new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ;
  333. GetPlayerPos(playerid, OX, OY, OZ);
  334. oModel[playerid] = 2942;
  335. ATMm[playerid] = hCost;
  336. ORX = 0.0;
  337. ORY = 0.0;
  338. ORZ = 0.0;
  339. Object[playerid] = CreateObject(2942, OX+2, OY, OZ, ORX, ORY, ORZ); //Object will render at its default distance.
  340. SendClientMessage(playerid, 0xD8D8D8FF, "Object spawned now move it");
  341. EditObject(playerid, Object[playerid]);
  342. return 1;
  343. }
  344. else return SendClientMessage(playerid, COLOR_RED, "USAGE: /addatm [amount of money]");
  345. }
  346. else return SendClientMessage(playerid, COLOR_RED, "You do not have the rights to use this command.");
  347. }
  348.  
  349. COMMAND:addbank(playerid, params[])
  350. {
  351. new hCost;
  352. if(IsPlayerAdmin(playerid))
  353. {
  354. if(!sscanf(params, "i", hCost))
  355. {
  356. new i = GetBanks();
  357. GetPlayerPos(playerid, BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz]);
  358. BankInfo[i][Bankrx] = 2305.8408;
  359. BankInfo[i][Bankry] = -16.4474;
  360. BankInfo[i][Bankrz] = 26.7496;
  361. BankInfo[i][Bankint] = 0;
  362. BankInfo[i][Bankvw] = i;
  363. BankInfo[i][BankMoney] = hCost;
  364. new Bank[256];
  365. format(Bank, sizeof(Bank), "Banks/%i.ini",i);
  366. dini_Create(Bank);
  367. dini_IntSet(Bank, "Money", BankInfo[i][BankMoney]);
  368. dini_IntSet(Bank, "INT", BankInfo[i][Bankint]);
  369. dini_IntSet(Bank, "VW", BankInfo[i][Bankvw]);
  370. dini_FloatSet(Bank, "BankX", BankInfo[i][Bankx]);
  371. dini_FloatSet(Bank, "BankY", BankInfo[i][Banky]);
  372. dini_FloatSet(Bank, "BankZ", BankInfo[i][Bankz]);
  373. dini_FloatSet(Bank, "BankRX", BankInfo[i][Bankrx]);
  374. dini_FloatSet(Bank, "BankRY", BankInfo[i][Bankry]);
  375. dini_FloatSet(Bank, "BankRZ", BankInfo[i][Bankrz]);
  376. BankObject[i] = CreatePickup(1318, 1, BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz], -1);
  377. new string[256];
  378. format(string, sizeof(string), "/enter to enter the bank.\nMoney left in this banks vault $%d.",BankInfo[i][BankMoney]);
  379. BankLabel[i] = Create3DTextLabel(string, 0x008080FF, BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz], 10.0, 0, 1);
  380. SendClientMessage(playerid, 0xD8D8D8FF, "Bank created");
  381. return 1;
  382. }
  383. else return SendClientMessage(playerid, COLOR_RED, "USAGE: /addbank [amount of money]");
  384. }
  385. else return SendClientMessage(playerid, COLOR_RED, "You do not have the rights to use this command.");
  386. }
  387.  
  388. COMMAND:enter(playerid, params[])
  389. {
  390. new i = GetBankID(playerid);
  391. if(IsPlayerInRangeOfPoint(playerid, 3,BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz]))
  392. {
  393. SetPlayerPos(playerid,BankInfo[i][Bankrx], BankInfo[i][Bankry], BankInfo[i][Bankrz]);
  394. SetPlayerVirtualWorld(playerid,BankInfo[i][Bankvw]);
  395. SetPlayerInterior(playerid,BankInfo[i][Bankint]);
  396. PlayerInfo[playerid][playerenterbankid] = i;
  397. return 1;
  398. }
  399. else return SendClientMessage(playerid, COLOR_RED, "You are not near anywhere you can enter.");
  400. }
  401.  
  402. COMMAND:exit(playerid, params[])
  403. {
  404. new i = PlayerInfo[playerid][playerenterbankid];
  405. if(IsPlayerInRangeOfPoint(playerid, 3,2305.8408,-16.4474,26.7496))
  406. {
  407. SetPlayerPos(playerid,BankInfo[i][Bankx], BankInfo[i][Banky], BankInfo[i][Bankz]);
  408. SetPlayerVirtualWorld(playerid,0);
  409. SetPlayerInterior(playerid,0);
  410. return 1;
  411. }
  412. else return SendClientMessage(playerid, COLOR_RED, "You are not near anywhere you can enter.");
  413. }
  414.  
  415. COMMAND:removeatm(playerid, params[])
  416. {
  417. if(IsPlayerAdmin(playerid))
  418. {
  419. new i;
  420. if(!sscanf(params, "i", i))
  421. {
  422. new file[256];
  423. format(file,sizeof(file),"ATMs/%i.ini",i);
  424. dini_Remove(file);
  425. DestroyObject(ATMObject[i]);
  426. Delete3DTextLabel(ATMLabel[i]);
  427. SendClientMessage(playerid, COLOR_ORANGE, "ATM removed.");
  428. return 1;
  429. }
  430. else return SendClientMessage(playerid, COLOR_RED, "You do not have the rights to use this command.");
  431. }
  432. else return SendClientMessage(playerid, COLOR_RED, "Usage: /removeatm [atmid].");
  433. }
  434.  
  435. COMMAND:removebank(playerid, params[])
  436. {
  437. if(IsPlayerAdmin(playerid))
  438. {
  439. new i;
  440. if(!sscanf(params, "i", i))
  441. {
  442. new file[256];
  443. format(file,sizeof(file),"Banks/%i.ini",i);
  444. dini_Remove(file);
  445. DestroyObject(BankObject[i]);
  446. Delete3DTextLabel(BankLabel[i]);
  447. SendClientMessage(playerid, COLOR_ORANGE, "Bank removed.");
  448. return 1;
  449. }
  450. else return SendClientMessage(playerid, COLOR_RED, "You do not have the rights to use this command.");
  451. }
  452. else return SendClientMessage(playerid, COLOR_RED, "Usage: /removeBank [Bankid].");
  453. }
  454.  
  455. COMMAND:setatmcash(playerid, params[])
  456. {
  457. new amount;
  458. new atid;
  459. new Biz[128];
  460. new string[256];
  461. if(IsPlayerAdmin(playerid))
  462. {
  463. if(!sscanf(params, "ii", atid, amount))
  464. {
  465. format(Biz, sizeof(Biz), "ATMs/%i.ini",atid);
  466. ATMInfo[atid][ATMMoney] = amount;
  467. dini_IntSet(Biz, "Money", ATMInfo[atid][ATMMoney]);
  468. Delete3DTextLabel(ATMLabel[atid]);
  469. format(string, sizeof(string), "ATM type /atmwithdraw and /atmbalance.\nMoney left $%d",ATMInfo[atid][ATMMoney]);
  470. ATMLabel[atid] = Create3DTextLabel(string, 0x008080FF, ATMInfo[atid][ATMx],ATMInfo[atid][ATMy],ATMInfo[atid][ATMz], 10.0, 0, 1);
  471. return 1;
  472. }
  473. else return SendClientMessage(playerid,COLOR_RED,"USAGE: /setatmcash [atmid] [amount]");
  474. }
  475. else return SendClientMessage(playerid,COLOR_RED,"You can not use this command!");
  476. }
  477.  
  478. COMMAND:setbankcash(playerid, params[])
  479. {
  480. new amount;
  481. new atid;
  482. new Biz[128];
  483. new string[256];
  484. if(IsPlayerAdmin(playerid))
  485. {
  486. if(!sscanf(params, "ii", atid, amount))
  487. {
  488. format(Biz, sizeof(Biz), "Banks/%i.ini",atid);
  489. BankInfo[atid][BankMoney] = amount;
  490. dini_IntSet(Biz, "Money", BankInfo[atid][BankMoney]);
  491. Delete3DTextLabel(BankLabel[atid]);
  492. format(string, sizeof(string), "Bank type /Bankwithdraw and /Bankbalance.\nMoney left $%d",BankInfo[atid][BankMoney]);
  493. BankLabel[atid] = Create3DTextLabel(string, 0x008080FF, BankInfo[atid][Bankx],BankInfo[atid][Banky],BankInfo[atid][Bankz], 10.0, 0, 1);
  494. return 1;
  495. }
  496. else return SendClientMessage(playerid,COLOR_RED,"USAGE: /setBankcash [Bankid] [amount]");
  497. }
  498. else return SendClientMessage(playerid,COLOR_RED,"You can not use this command!");
  499. }
  500.  
  501. COMMAND:juesbank(playerid, params[])
  502. {
  503. if(IsPlayerAdmin(playerid))
  504. {
  505. SendClientMessage(playerid,COLOR_ORANGE,"/addatm /addbank /getatmid /getbankid /setatmcash /setbankcash /withdraw!");
  506. SendClientMessage(playerid,COLOR_ORANGE,"/removeatm /removebank /deposit /atmwithdraw!");
  507. return 1;
  508. }
  509. else return SendClientMessage(playerid,COLOR_RED,"You can not use this command!");
  510. }
  511.  
  512. COMMAND:atmwithdraw(playerid, params[])
  513. {
  514. new amount;
  515. new Biz[128];
  516. new string[256];
  517. new i;
  518. i = GetATMID(playerid);
  519. if(!sscanf(params, "i", amount))
  520. {
  521. if(IsPlayerInRangeOfPoint(playerid, 3.0,ATMInfo[i][ATMx],ATMInfo[i][ATMy],ATMInfo[i][ATMz]))
  522. {
  523. if(amount <= ATMInfo[i][ATMMoney] && amount > 0)
  524. {
  525. if(amount <= PlayerInfo[playerid][pBank] && amount > 0)
  526. {
  527. format(Biz, sizeof(Biz), "ATMs/ATMid%d",i);
  528. PlayerInfo[playerid][pBank] = PlayerInfo[playerid][pBank]-amount;
  529. GivePlayerMoney(playerid,amount);
  530. ATMInfo[i][ATMMoney] = ATMInfo[i][ATMMoney]-amount;
  531. dini_IntSet(Biz, "Money", ATMInfo[i][ATMMoney]);
  532. Delete3DTextLabel(ATMLabel[i]);
  533. format(string, sizeof(string), "ATM type /atmwithdraw and /balance.\nMoney left $%d",ATMInfo[i][ATMMoney]);
  534. ATMLabel[i] = Create3DTextLabel(string, 0x008080FF, ATMInfo[i][ATMx],ATMInfo[i][ATMy],ATMInfo[i][ATMz], 10.0, 0, 1);
  535. return 1;
  536. }
  537. else return SendClientMessage(playerid,COLOR_RED,"You don't have that much money in your bank account.");
  538. }
  539. else return SendClientMessage(playerid,COLOR_RED,"This cash machine doesn't have that much cash in.");
  540. }
  541. else return SendClientMessage(playerid,COLOR_RED,"You are not around any cash machines.");
  542. }
  543. else return SendClientMessage(playerid,COLOR_RED,"USAGE: /atmwithdraw [amount]");
  544. }
  545.  
  546. COMMAND:getatmid(playerid, params[])
  547. {
  548. new string[256];
  549. new i;
  550. i = GetATMID(playerid);
  551. if(IsPlayerAdmin(playerid))
  552. {
  553. if(IsPlayerInRangeOfPoint(playerid, 3.0,ATMInfo[i][ATMx],ATMInfo[i][ATMy],ATMInfo[i][ATMz]))
  554. {
  555. format(string, sizeof(string), "ATM ID %d",i);
  556. SendClientMessage(playerid,COLOR_ORANGE,string);
  557. return 1;
  558. }
  559. else return SendClientMessage(playerid,COLOR_RED,"You are not around any cash machines.");
  560. }
  561. else return SendClientMessage(playerid,COLOR_RED,"You can not use this command!");
  562. }
  563.  
  564. COMMAND:getbankid(playerid, params[])
  565. {
  566. new string[256];
  567. new i;
  568. i = GetBankID(playerid);
  569. if(IsPlayerAdmin(playerid))
  570. {
  571. if(IsPlayerInRangeOfPoint(playerid, 3.0,BankInfo[i][Bankx],BankInfo[i][Banky],BankInfo[i][Bankz]))
  572. {
  573. format(string, sizeof(string), "Bank ID %d",i);
  574. SendClientMessage(playerid,COLOR_ORANGE,string);
  575. return 1;
  576. }
  577. else return SendClientMessage(playerid,COLOR_RED,"You are not around any cash machines.");
  578. }
  579. else return SendClientMessage(playerid,COLOR_RED,"You can not use this command!");
  580. }
  581.  
  582. COMMAND:withdraw(playerid, params[])
  583. {
  584. new amount;
  585. if(IsPlayerInRangeOfPoint(playerid, 3.0,2316.5034,-10.0475,26.7422))
  586. {
  587. if(!sscanf(params, "i", amount))
  588. {
  589. if(amount > 0 && amount < 100000000)
  590. {
  591. if(PlayerInfo[playerid][pBank] >= amount)
  592. {
  593. PlayerInfo[playerid][pBank] = PlayerInfo[playerid][pBank]-amount;
  594. GivePlayerMoney(playerid,amount);
  595. SaveStats(playerid);
  596. return 1;
  597. }
  598. else return SendClientMessage(playerid,COLOR_RED,"You don't have this much in your account.");
  599. }
  600. else return SendClientMessage(playerid,COLOR_RED,"Invalid amount.");
  601. }
  602. else return SendClientMessage(playerid,COLOR_RED,"USAGE: /withdraw [amount]");
  603. }
  604. else return SendClientMessage(playerid,COLOR_RED,"Not around the bank.");
  605. }
  606.  
  607. COMMAND:deposit(playerid, params[])
  608. {
  609. new amount;
  610. if(IsPlayerInRangeOfPoint(playerid, 3.0,2316.5034,-10.0475,26.7422))
  611. {
  612. if(!sscanf(params, "i", amount))
  613. {
  614. if(amount > 0 && amount < 100000000)
  615. {
  616. if(PlayerInfo[playerid][pBank] >= amount)
  617. {
  618. PlayerInfo[playerid][pBank] = PlayerInfo[playerid][pBank]+amount;
  619. GivePlayerMoney(playerid,-amount);
  620. SaveStats(playerid);
  621. return 1;
  622. }
  623. else return SendClientMessage(playerid,COLOR_RED,"You don't have this much in your wallet.");
  624. }
  625. else return SendClientMessage(playerid,COLOR_RED,"Invalid amount.");
  626. }
  627. else return SendClientMessage(playerid,COLOR_RED,"USAGE: /deposit [amount]");
  628. }
  629. else return SendClientMessage(playerid,COLOR_RED,"Not around the bank.");
  630. }
  631.  
  632. SaveStats(playerid)
  633. {
  634. new name[MAX_PLAYER_NAME], file[256];
  635. GetPlayerName(playerid, name, sizeof(name));
  636. format(file, sizeof(file), ATM_USER_FILE, name);
  637. dini_IntSet(file, "Bank", PlayerInfo[playerid][pBank]);
  638. }
  639.  
  640. LoadStats(playerid)
  641. {
  642. new name[MAX_PLAYER_NAME], userfile[256];
  643. GetPlayerName(playerid, name, sizeof(name));
  644. format(userfile, sizeof(userfile), ATM_USER_FILE, name);
  645. PlayerInfo[playerid][pBank] = dini_Int(userfile, "Bank");
  646. }
Add Comment
Please, Sign In to add comment