Guest User

Dynamic Banksys Sqlite by Music4You

a guest
Jul 24th, 2013
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.79 KB | None | 0 0
  1. /*
  2. Bankssystem by Items4Landwirt aka Music4You
  3.  
  4. - Es ist verboten meinen Namen aus dem Skript zu löschen!
  5. - Es ist verboten Dieses Skript nocheinmal zu veröffentlichen
  6. - Es ist verboten Dieses Skript als eigenes auszugeben.
  7.  
  8. Ich danke BlackAce für sein gutes Tutorial für SQLlite.
  9. http://forum.sa-mp.de/gta-multiplayer-mods/san-andreas-multiplayer/scripting-base/tutorials/121557-sqlite-die-alternative-zu-mysql/
  10.  
  11. Nun noch ein Paar YT Kanäle, von guten Freunden
  12. Music4You http://www.youtube.com/user/Music4You43
  13. Items4Sacred http://www.youtube.com/user/items4sacred
  14. Metalletsplay666 http://www.youtube.com/user/MetalLetsPlay666
  15.  
  16. */
  17. #define FILTERSCRIPT
  18.  
  19. ////=============== Includes ===============
  20. #include <a_samp>
  21. #include <ocmd>
  22. #include <streamer>
  23.  
  24. //=============== Defines ===============
  25. #define rot 0xFF0A00FF
  26. #define gruen 0x4BB400FF
  27.  
  28. #define SCM SendClientMessage
  29.  
  30. #define Bankmenu 1001
  31. #define Einzahlung 1002
  32. #define Kontostand 1003
  33. #define Auszahlung 1004
  34. #define Pinauswahl 1005
  35. #define Pinaueingabe 1006
  36. #define bankhelp 1007
  37. #define Ueberweisung 1008
  38. #define Summe 1009
  39. #define Fehler 1010
  40.  
  41. #define MAX_ATMS 20
  42.  
  43. ////=============== News ===============
  44. new DB:Database;
  45. new bankein;
  46. new bankaus;
  47.  
  48. new ueberweisman[MAX_PLAYERS];
  49.  
  50. enum bank
  51. {
  52. Guthaben,
  53. Konto
  54. }
  55. new BankInfo[MAX_PLAYERS][bank];
  56.  
  57. enum ATM
  58. {
  59. ID,
  60. Float:X,
  61. Float:Y,
  62. Float:Z,
  63. Float:Angle,
  64. atmobjekt,
  65. bool:erstellt
  66. }
  67. new ATMInfo[MAX_ATMS][ATM];
  68.  
  69. public OnFilterScriptInit()
  70. {
  71. print("\n=================================================");
  72. print(" SQLLite Banksystem by Music4You aka Items4Landwirt");
  73. print("===================================================\n");
  74.  
  75. Database = db_open("Bank.db");
  76. db_query(Database,"CREATE TABLE IF NOT EXISTS `bank`(`Name`,`Konto`,`Pin`,`Guthaben`)");
  77. db_query(Database,"CREATE TABLE IF NOT EXISTS `atm`(`ID`,`X`,`Y`,`Z`,`A`)");
  78.  
  79. new DBResult:Result, str[512], rows;
  80. for(new i=0;i<MAX_ATMS;i++)
  81. {
  82. format(str,sizeof(str),"SELECT * FROM `atm` WHERE `ID` = '%i'",i);
  83. Result = db_query(Database,str);
  84. rows = db_num_rows(Result);
  85. if(rows == 0)continue;
  86. db_get_field_assoc(Result,"X",str,sizeof(str));
  87. ATMInfo[i][X]=floatstr(str);
  88. db_get_field_assoc(Result,"Y",str,sizeof(str));
  89. ATMInfo[i][Y]=floatstr(str);
  90. db_get_field_assoc(Result,"Z",str,sizeof(str));
  91. ATMInfo[i][Z]=floatstr(str);
  92. db_get_field_assoc(Result,"A",str,sizeof(str));
  93. ATMInfo[i][Angle]=floatstr(str);
  94.  
  95. ATMInfo[i][erstellt] = true;
  96. ATMInfo[i][atmobjekt] = CreateDynamicObject(2942,ATMInfo[i][X],ATMInfo[i][Y],ATMInfo[i][Z]-0.5,0,0,ATMInfo[i][Angle]);
  97. db_free_result(Result);
  98. }
  99. //=============== bank interior ===============
  100. CreateObject(14789, 1424.690308, -1004.066162, 1643.018677, 0.0000, 0.0000, 90.0000);
  101. CreateObject(2774, 1433.026245, -1004.643921, 1635.819824, 0.0000, 0.0000, 0.0000);
  102. CreateObject(2774, 1429.296997, -1004.618652, 1641.281128, 0.0000, 0.0000, 0.0000);
  103. CreateObject(2774, 1440.957031, -979.682068, 1640.297729, 0.0000, 0.0000, 0.0000);
  104. CreateObject(2774, 1429.337158, -979.545288, 1639.723389, 0.0000, 0.0000, 0.0000);
  105. CreateObject(2774, 1449.314087, -984.505005, 1648.023193, 0.0000, 0.0000, 0.0000);
  106. CreateObject(2774, 1413.914063, -984.515381, 1643.073486, 0.0000, 0.0000, 0.0000);
  107. CreateObject(1886, 1448.510132, -1003.642944, 1647.093994, 19.7670, 0.0000, 223.3584);
  108. CreateObject(1886, 1414.706543, -980.604431, 1647.061646, 19.7670, 0.0000, 43.3584);
  109. CreateObject(2774, 1430.416870, -999.017273, 1638.722412, 0.0000, 269.7592, 0.0000);
  110. CreateObject(2774, 1408.149292, -998.996826, 1638.722412, 0.0000, 269.7592, 180.0000);
  111. CreateObject(2774, 1443.577271, -986.634644, 1638.723389, 0.0000, 269.7592, 270.0000);
  112. CreateObject(2774, 1443.604492, -998.998169, 1647.797485, 0.0000, 0.0000, 0.0000);
  113. CreateObject(11359, 1414.356201, -988.985352, 1639.795898, 0.0000, 0.0000, 90.0000);
  114. CreateObject(2774, 1413.927368, -986.011719, 1643.046997, 0.0000, 0.0000, 270.0000);
  115. CreateObject(2774, 1413.763672, -992.085388, 1643.673340, 0.0000, 0.0000, 0.0000);
  116. CreateObject(626, 1427.554565, -997.322998, 1640.766479, 0.0000, 0.0000, 135.0000);
  117. CreateObject(626, 1427.488281, -990.752502, 1640.841553, 0.0000, 0.0000, 135.0000);
  118. CreateObject(2773, 1427.756714, -995.781189, 1639.310181, 0.0000, 0.0000, 0.0000);
  119. CreateObject(2773, 1427.694946, -992.841431, 1639.310181, 0.0000, 0.0000, 0.0000);
  120. CreateObject(2773, 1427.596924, -989.128601, 1639.301514, 0.0000, 0.0000, 0.0000);
  121. CreateObject(2773, 1429.863159, -982.927368, 1639.310181, 0.0000, 0.0000, 90.0000);
  122. CreateObject(626, 1427.665283, -983.128601, 1640.841553, 0.0000, 0.0000, 236.2500);
  123. CreateObject(2773, 1432.755859, -982.990784, 1639.310181, 0.0000, 0.0000, 90.0000);
  124. CreateObject(626, 1434.648315, -983.188904, 1640.841553, 0.0000, 0.0000, 236.2500);
  125. CreateObject(2773, 1437.091431, -983.054993, 1639.310181, 0.0000, 0.0000, 90.0000);
  126. CreateObject(2773, 1440.040283, -983.012756, 1639.310181, 0.0000, 0.0000, 90.0000);
  127. CreateObject(3462, 1448.466919, -993.014465, 1640.297974, 0.0000, 0.0000, 0.0000);
  128. CreateObject(3462, 1448.512085, -982.992615, 1640.181519, 0.0000, 0.0000, 0.0000);
  129. CreateObject(626, 1441.636230, -997.047729, 1640.741455, 0.0000, 0.0000, 146.2500);
  130. CreateObject(14632, 1443.648682, -995.934631, 1638.667725, 0.0000, 0.0000, 90.0000);
  131. CreateObject(14632, 1432.156372, -1018.015259, 1639.988159, 0.0000, 0.0000, 270.0000);
  132. CreateObject(1514, 1432.294922, -998.852478, 1639.740112, 0.0000, 0.0000, 180.0000);
  133. CreateObject(1514, 1438.352539, -998.846741, 1639.815674, 0.0000, 0.0000, 180.0000);
  134. CreateObject(2773, 1435.183838, -996.759277, 1639.301514, 0.0000, 0.0000, 0.0000);
  135. CreateObject(2773, 1435.152466, -993.932556, 1639.301514, 0.0000, 0.0000, 0.0000);
  136. CreateObject(2773, 1439.338623, -996.658691, 1639.301514, 0.0000, 0.0000, 0.0000);
  137. CreateObject(2773, 1439.288940, -994.000671, 1639.301514, 0.0000, 0.0000, 0.0000);
  138. CreateObject(1723, 1426.280151, -994.863586, 1638.707275, 0.0000, 0.0000, 270.0000);
  139. CreateObject(1723, 1426.244629, -991.150452, 1638.732300, 0.0000, 0.0000, 270.0000);
  140. CreateObject(1723, 1422.277466, -996.935059, 1638.682251, 0.0000, 0.0000, 90.0000);
  141. CreateObject(1723, 1422.279297, -993.210022, 1638.657227, 0.0000, 0.0000, 90.0000);
  142. CreateObject(2637, 1424.232422, -992.173584, 1638.838745, 0.0000, 0.0000, 270.0000);
  143. CreateObject(2637, 1424.228516, -995.704163, 1638.838745, 0.0000, 0.0000, 270.0000);
  144. CreateObject(3657, 1432.633301, -987.739014, 1639.202393, 0.0000, 0.0000, 0.0000);
  145. CreateObject(3657, 1432.631104, -986.977234, 1639.202393, 0.0000, 0.0000, 180.0000);
  146. CreateObject(3657, 1438.111572, -986.977539, 1639.202393, 0.0000, 0.0000, 180.0000);
  147. CreateObject(3657, 1438.086304, -987.730713, 1639.227417, 0.0000, 0.0000, 0.0000);
  148. CreateObject(2961, 1439.028320, -999.826660, 1639.211304, 0.0000, 0.0000, 0.0000);
  149. CreateObject(2961, 1433.505615, -999.827637, 1639.301392, 0.0000, 0.0000, 0.0000);
  150. CreateObject(2946, 1414.355225, -990.513489, 1638.755615, 0.0000, 0.0000, 0.0000);
  151. CreateObject(2946, 1414.380249, -987.392517, 1638.755005, 0.0000, 0.0000, 180.0000);
  152. CreateObject(2963, 1424.165283, -1004.815674, 1640.781128, 0.0000, 0.0000, 270.0000);
  153. CreateObject(2963, 1426.806763, -1004.832520, 1640.826904, 0.0000, 0.0000, 90.0000);
  154. CreateObject(1886, 1414.730591, -993.523010, 1646.908569, 17.1887, 0.0000, 67.5000);
  155. CreateObject(2773, 1431.414551, -996.845825, 1639.301514, 0.0000, 0.0000, 0.0000);
  156. CreateObject(2773, 1431.473389, -994.017090, 1639.301514, 0.0000, 0.0000, 0.0000);
  157. CreateObject(632, 1434.735352, -987.757507, 1639.131226, 0.0000, 0.0000, 213.7500);
  158. CreateObject(2942, 1417.713623, -980.475159, 1639.363525, 0.0000, 0.0000, 0.0000);
  159. CreateObject(1216, 1443.281372, -989.311279, 1639.387817, 0.0000, 0.0000, 270.0000);
  160. CreateObject(2942, 1421.217163, -980.448914, 1639.385498, 0.0000, 0.0000, 0.0000);
  161. CreateObject(2942, 1424.630493, -980.526672, 1639.371460, 0.0000, 0.0000, 0.0000);
  162. CreateObject(1216, 1443.277832, -991.424866, 1639.424194, 0.0000, 0.0000, 270.0000);
  163. CreateObject(1216, 1443.251221, -987.278198, 1639.376221, 0.0000, 0.0000, 270.0000);
  164. CreateObject(1216, 1443.259766, -985.484985, 1639.376221, 0.0000, 0.0000, 270.0000);
  165. CreateObject(2773, 1441.228638, -993.042969, 1639.301514, 0.0000, 0.0000, 270.0000);
  166. CreateObject(2824, 1424.297241, -992.054932, 1639.247681, 0.0000, 0.0000, 78.7500);
  167.  
  168. bankein = CreatePickup(1318,1,1462.2754,-1011.1824,26.8438,-1);
  169. bankaus = CreatePickup(1318,1,1414.7997,-989.0223,1639.7843,-1);
  170. return 1;
  171. }
  172.  
  173. public OnFilterScriptExit()
  174. {
  175. for(new i = 0; i < MAX_PLAYERS; i++)
  176. {
  177. SaveBank(i);
  178. }
  179. return 1;
  180. }
  181.  
  182. public OnPlayerConnect(playerid)
  183. {
  184. new DBResult:Result, str[512];
  185. format(str, sizeof(str), "SELECT * FROM `bank` WHERE Name = '%s'",SpielerName(playerid));
  186. Result = db_query(Database,str);
  187.  
  188. db_get_field_assoc(Result,"Konto",str,sizeof(str));
  189. BankInfo[playerid][Konto]=strval(str);
  190. db_get_field_assoc(Result,"Guthaben",str,sizeof(str));
  191. BankInfo[playerid][Guthaben]=strval(str);
  192. db_free_result(Result);
  193. return 1;
  194. }
  195.  
  196. public OnPlayerDisconnect(playerid, reason)
  197. {
  198. SaveBank(playerid);
  199. return 1;
  200. }
  201.  
  202. ocmd:atm(playerid,params[])
  203. {
  204. if(BankInfo[playerid][Konto]!=1) return SCM(playerid,rot,"Du hast kein Bankkonto");
  205. if(IsATM(playerid) != -1)
  206. {
  207. ShowPlayerDialog(playerid,Pinaueingabe,DIALOG_STYLE_INPUT,"Pineingabe","Gebe nun deinen Bankpin ein, um auf dein Bankkonto zuzugreifen","Weiter","Abbrechen");
  208. }
  209. else
  210. {
  211. SCM(playerid,rot,"Du bist an keinem ATM");
  212. }
  213. return 1;
  214. }
  215. ocmd:bank(playerid,params[])
  216. {
  217. new query[128];
  218. if(!IsPlayerInRangeOfPoint(playerid,10,1417.7145,-981.6283,1639.7843)) return SCM(playerid,rot,"Du bist nicht in Der Bank");
  219. if(BankInfo[playerid][Konto]!=0) return SCM(playerid,rot,"Du hast bereits ein Bankkonto");
  220. ShowPlayerDialog(playerid,Pinauswahl,DIALOG_STYLE_INPUT,"Pineingabe","Um ein Bankkonto zu erstellen musst du vorher einen Sicheren Bankpin eingeben,\n diesen musst du dir merken!","Weiter","");
  221. format(query,sizeof(query),"INSERT INTO `bank` (`Name`) VALUES ('%s')",SpielerName(playerid));
  222. db_query(Database,query);
  223. return 1;
  224. }
  225. ocmd:bankhilfe(playerid,params[])
  226. {
  227. SCM(playerid,gruen,"/bank -> Bankkonto erstellen, nur in der Bank");
  228. SCM(playerid,gruen,"/atm -> Bankkonto aufrufen, nur in der Bank");
  229. return 1;
  230. }
  231. ocmd:catm(playerid,params[])
  232. {
  233. new Float:x,Float:y,Float:z,Float:a, query[256];
  234. if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
  235. GetPlayerPos(playerid, x, y, z);
  236. GetPlayerFacingAngle(playerid,a);
  237. for(new i = 0;i < MAX_ATMS; i++)
  238. {
  239. if(ATMInfo[i][erstellt] == true)continue;
  240. ATMInfo[i][erstellt] = true;
  241. ATMInfo[i][X] = x;
  242. ATMInfo[i][Y] = y;
  243. ATMInfo[i][Z] = z;
  244. ATMInfo[i][Angle] = a;
  245. ATMInfo[i][atmobjekt] = CreateDynamicObject(2942,x,y,z-0.5,0,0,a);
  246. format(query,sizeof(query),"INSERT INTO `atm` (`ID`, `X`,`Y`,`Z`,`A`) VALUES ('%i','%f','%f','%f','%f')",i,x,y,z,a);
  247. db_query(Database,query);
  248. SCM(playerid,gruen,"ATM erstellt");
  249. return 1;
  250. }
  251. return 1;
  252. }
  253. ocmd:delatm(playerid, params[])
  254. {
  255. if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
  256. new id = IsATM(playerid),query[256];
  257. if(id != -1)
  258. {
  259. ATMInfo[id][erstellt] = false;
  260. ATMInfo[id][X] = 0.0;
  261. ATMInfo[id][Y] = 0.0;
  262. ATMInfo[id][Z] = 0.0;
  263. ATMInfo[id][Angle] = 0;
  264. SCM(playerid,gruen,"Du hast den ATM gelöscht");
  265. DestroyDynamicObject(ATMInfo[id][atmobjekt]);
  266.  
  267. format(query,sizeof(query),"SELECT * FROM atm WHERE ID = '%d'",id);
  268. format(query,sizeof(query),"DELETE FROM atm WHERE ID = '%d'",id);
  269. db_query(Database,query);
  270. return 1;
  271. }
  272. else
  273. {
  274. SCM(playerid,rot,"Du bist an keinem ATM");
  275. }
  276. return 1;
  277. }
  278. ocmd:delallatm(playerid,params[])
  279. {
  280. if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
  281. for(new i=0,query[128];i<MAX_ATMS;i++)
  282. {
  283. ATMInfo[i][erstellt] = false;
  284. ATMInfo[i][X] = 0.0;
  285. ATMInfo[i][Y] = 0.0;
  286. ATMInfo[i][Z] = 0.0;
  287. ATMInfo[i][Angle] = 0;
  288. DestroyDynamicObject(ATMInfo[i][atmobjekt]);
  289.  
  290. format(query,sizeof(query),"SELECT * FROM atm WHERE ID = '%d'",i);
  291. format(query,sizeof(query),"DELETE FROM atm WHERE ID = '%d'",i);
  292. db_query(Database,query);
  293. }
  294. SCM(playerid,gruen,"Du hast alle ATMs gelöscht");
  295. return 1;
  296. }
  297.  
  298. public OnPlayerPickUpPickup(playerid, pickupid)
  299. {
  300. if(pickupid == bankein)
  301. {
  302. SetPlayerPos(playerid,1417.2261,-989.1280,1639.7843);
  303. SetPlayerInterior(playerid,0);
  304. }
  305. if(pickupid == bankaus)
  306. {
  307. SetPlayerPos(playerid,1471.2754,-1011.1824,26.8438);
  308. SetPlayerInterior(playerid,0);
  309. }
  310. return 1;
  311. }
  312.  
  313.  
  314. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  315. {
  316. switch(dialogid)
  317. {
  318. case Pinauswahl:
  319. {
  320. if(response)
  321. {
  322. if(!strlen(inputtext))
  323. {
  324. ShowPlayerDialog(playerid,Pinauswahl,DIALOG_STYLE_INPUT,"Pineingabe","Um ein Bankkonto zu erstellen musst du vorher einen Sicheren Bankpin eingeben,\n diesen musst du dir merken!","Weiter","");
  325. return 1;
  326. }
  327. new query[128];
  328. format(query,128,"UPDATE `bank` SET `Pin` = '%s' WHERE `Name` = '%s'",inputtext,SpielerName(playerid));
  329. db_query(Database,query);
  330. BankInfo[playerid][Konto]=1;
  331. BankInfo[playerid][Guthaben]+=300;
  332. SCM(playerid,gruen,"konto erstellt");
  333. }
  334. }
  335. case Pinaueingabe:
  336. {
  337. if(response)
  338. {
  339. new str[128],DBResult:Result;
  340. format(str, sizeof(str), "SELECT * FROM `bank` WHERE Name = '%s' AND Pin = '%s'",SpielerName(playerid),inputtext);
  341. Result = db_query(Database,str);
  342. if(db_num_rows(Result) > 0)
  343. {
  344. ShowPlayerDialog(playerid,Bankmenu,DIALOG_STYLE_LIST,"Transaktionen","Einzahlung\nAuszahlung\nKontostand\nÜberweisen","Wählen","Beenden");
  345. }
  346. else
  347. {
  348. ShowPlayerDialog(playerid,Pinaueingabe,DIALOG_STYLE_INPUT,"Pineingabe","Gebe nun deinen Bankpin ein, um auf dein Bankkonto zuzugreifen","Weiter","Abbrechen");
  349. }
  350. db_free_result(Result);
  351. }
  352. }
  353. case Bankmenu:
  354. {
  355. if(response)
  356. {
  357. if(listitem == 0)
  358. {
  359. ShowPlayerDialog(playerid,Einzahlung,DIALOG_STYLE_INPUT,"Einzahlung","Summe eingeben:","Einzahlen","Verlassen");
  360. }
  361. if(listitem == 1)
  362. {
  363. ShowPlayerDialog(playerid,Auszahlung,DIALOG_STYLE_INPUT,"Auszahlung","Summe eingeben:","Auszahlen","Verlassen");
  364. }
  365. if(listitem == 2)
  366. {
  367. new str[128];
  368. format(str,sizeof(str),"Kontostand: %d$",BankInfo[playerid][Guthaben]);
  369. ShowPlayerDialog(playerid,Kontostand,DIALOG_STYLE_MSGBOX,"Kontostand",str,"Schließen","");
  370. }
  371. if(listitem == 3)
  372. {
  373.  
  374. }
  375. }
  376. }
  377. case Einzahlung:
  378. {
  379. new str[128];
  380. if(!response)return ShowPlayerDialog(playerid,Bankmenu,DIALOG_STYLE_LIST,"Transaktionen","Einzahlung\nAuszahlung\nKontostand\nÜberweisen","Wählen","Beenden");
  381. if(GetPlayerMoney(playerid) < strval(inputtext))return SendClientMessage(playerid,rot,"Du hast nicht genug Geld dabei!");
  382. GivePlayerMoney(playerid, - strval(inputtext));
  383. BankInfo[playerid][Guthaben] += strval(inputtext);
  384. format(str,sizeof(str),"Sie haben %d$ auf ihr Konto eingezahlt",strval(inputtext));
  385. SCM(playerid,gruen,str);
  386. }
  387. case Auszahlung:
  388. {
  389. new str[128];
  390. if(!response)return ShowPlayerDialog(playerid,Bankmenu,DIALOG_STYLE_LIST,"Transaktionen","Einzahlung\nAuszahlung\nKontostand\nÜberweisen","Wählen","Beenden");
  391. if(BankInfo[playerid][Guthaben] < strval(inputtext))return SendClientMessage(playerid,rot,"Du hast nicht genug auf dem Konto!");
  392. GivePlayerMoney(playerid,strval(inputtext));
  393. BankInfo[playerid][Guthaben] -= strval(inputtext);
  394. format(str,sizeof(str),"Sie haben %d$ von ihrem Konto abgehoben",strval(inputtext));
  395. SCM(playerid,gruen,str);
  396. }
  397. case Ueberweisung:
  398. {
  399. new pID;
  400. if(!response)return ShowPlayerDialog(playerid,Bankmenu,DIALOG_STYLE_LIST,"Transaktionen","Einzahlung\nAuszahlung\nKontostand\nÜberweisung","Wählen","Beenden");
  401. if(sscanf(inputtext,"u",pID))return ShowPlayerDialog(playerid,Fehler,DIALOG_STYLE_MSGBOX,"Transaktion","Ungültige Angabe!","Schließen","") ;
  402. if(!IsPlayerConnected(pID))return ShowPlayerDialog(playerid,Fehler,DIALOG_STYLE_MSGBOX,"Transaktion","Ungültiger Empfänger!","Schließen","") ;
  403. if (pID == playerid)return ShowPlayerDialog(playerid,Fehler,DIALOG_STYLE_MSGBOX,"Transaktion","Ungültiger Empfänger!","Schließen","") ;
  404. ShowPlayerDialog(playerid,Summe,DIALOG_STYLE_INPUT,"Überweisung","Summe eingeben:","Überweisen","Verlassen");
  405. ueberweisman[playerid] = pID;
  406. ueberweisman[pID] = playerid;
  407. }
  408. case Summe:
  409. {
  410. new pID = ueberweisman[playerid];
  411. new str[128],str2[128];
  412. if(!response)return ShowPlayerDialog(playerid,Bankmenu,DIALOG_STYLE_LIST,"Transaktionen","Einzahlung\nAuszahlung\nKontostand\nÜberweisung","Wählen","Beenden");
  413. if(GetPlayerMoney(playerid)< strval(inputtext))return SendClientMessage(playerid,rot,"Du hast nicht genug Geld auf dem Konto!");
  414. BankInfo[playerid][Guthaben] -= strval(inputtext);
  415. BankInfo[pID][Guthaben] += strval(inputtext);
  416. format(str,sizeof(str),"Sie haben %d$ auf das Konto von %s überwiesen",strval(inputtext),SpielerName(pID));
  417. SCM(playerid,gruen,str);
  418. format(str2,sizeof(str2),"%s hat ihnen %d$ auf ihr Konto überwiesen",SpielerName(playerid),strval(inputtext));
  419. SendClientMessage(pID,gruen,str2);
  420. }
  421. }
  422. return 0;
  423. }
  424.  
  425. stock SpielerName(playerid)
  426. {
  427. new name[MAX_PLAYER_NAME];
  428. GetPlayerName(playerid,name,sizeof(name));
  429. return name;
  430. }
  431. stock SaveBank(playerid)
  432. {
  433. new query[128];
  434. format(query,128,"UPDATE `bank` SET `Konto` = '%i', `Guthaben` = '%i' WHERE `Name` = '%s'",BankInfo[playerid][Konto],BankInfo[playerid][Guthaben],SpielerName(playerid));
  435. db_query(Database,query);
  436. return 1;
  437. }
  438. stock IsATM(playerid)
  439. {
  440. new i=0;
  441. while(i != MAX_ATMS)
  442. {
  443. if(IsPlayerInRangeOfPoint(playerid, 3.0, ATMInfo[i][X], ATMInfo[i][Y], ATMInfo[i][Z]) || IsPlayerInRangeOfPoint(playerid,10,1417.7145,-981.6283,1639.7843))
  444. {
  445. return i;
  446. }
  447. i++;
  448. }
  449. return -1;
  450. }
  451.  
  452. stock sscanf(string[], format[], {Float,_}:...)
  453. {
  454. #if defined isnull
  455. if (isnull(string))
  456. #else
  457. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  458. #endif
  459. {
  460. return format[0];
  461. }
  462. #pragma tabsize 4
  463. new
  464. formatPos = 0,
  465. stringPos = 0,
  466. paramPos = 2,
  467. paramCount = numargs(),
  468. delim = ' ';
  469. while (string[stringPos] && string[stringPos] <= ' ')
  470. {
  471. stringPos++;
  472. }
  473. while (paramPos < paramCount && string[stringPos])
  474. {
  475. switch (format[formatPos++])
  476. {
  477. case '\0':
  478. {
  479. return 0;
  480. }
  481. case 'i', 'd':
  482. {
  483. new
  484. neg = 1,
  485. num = 0,
  486. ch = string[stringPos];
  487. if (ch == '-')
  488. {
  489. neg = -1;
  490. ch = string[++stringPos];
  491. }
  492. do
  493. {
  494. stringPos++;
  495. if ('0' <= ch <= '9')
  496. {
  497. num = (num * 10) + (ch - '0');
  498. }
  499. else
  500. {
  501. return -1;
  502. }
  503. }
  504. while ((ch = string[stringPos]) > ' ' && ch != delim);
  505. setarg(paramPos, 0, num * neg);
  506. }
  507. case 'h', 'x':
  508. {
  509. new
  510. num = 0,
  511. ch = string[stringPos];
  512. do
  513. {
  514. stringPos++;
  515. switch (ch)
  516. {
  517. case 'x', 'X':
  518. {
  519. num = 0;
  520. continue;
  521. }
  522. case '0' .. '9':
  523. {
  524. num = (num << 4) | (ch - '0');
  525. }
  526. case 'a' .. 'f':
  527. {
  528. num = (num << 4) | (ch - ('a' - 10));
  529. }
  530. case 'A' .. 'F':
  531. {
  532. num = (num << 4) | (ch - ('A' - 10));
  533. }
  534. default:
  535. {
  536. return -1;
  537. }
  538. }
  539. }
  540. while ((ch = string[stringPos]) > ' ' && ch != delim);
  541. setarg(paramPos, 0, num);
  542. }
  543. case 'c':
  544. {
  545. setarg(paramPos, 0, string[stringPos++]);
  546. }
  547. case 'f':
  548. {
  549.  
  550. new changestr[16], changepos = 0, strpos = stringPos;
  551. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  552. {
  553. changestr[changepos++] = string[strpos++];
  554. }
  555. changestr[changepos] = '\0';
  556. setarg(paramPos,0,_:floatstr(changestr));
  557. }
  558. case 'p':
  559. {
  560. delim = format[formatPos++];
  561. continue;
  562. }
  563. case '\'':
  564. {
  565. new
  566. end = formatPos - 1,
  567. ch;
  568. while ((ch = format[++end]) && ch != '\'') {}
  569. if (!ch)
  570. {
  571. return -1;
  572. }
  573. format[end] = '\0';
  574. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  575. {
  576. if (format[end + 1])
  577. {
  578. return -1;
  579. }
  580. return 0;
  581. }
  582. format[end] = '\'';
  583. stringPos = ch + (end - formatPos);
  584. formatPos = end + 1;
  585. }
  586. case 'u':
  587. {
  588. new
  589. end = stringPos - 1,
  590. id = 0,
  591. bool:num = true,
  592. ch;
  593. while ((ch = string[++end]) && ch != delim)
  594. {
  595. if (num)
  596. {
  597. if ('0' <= ch <= '9')
  598. {
  599. id = (id * 10) + (ch - '0');
  600. }
  601. else
  602. {
  603. num = false;
  604. }
  605. }
  606. }
  607. if (num && IsPlayerConnected(id))
  608. {
  609. setarg(paramPos, 0, id);
  610. }
  611. else
  612. {
  613. #if !defined foreach
  614. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  615. #define __SSCANF_FOREACH__
  616. #endif
  617. string[end] = '\0';
  618. num = false;
  619. new
  620. name[MAX_PLAYER_NAME];
  621. id = end - stringPos;
  622. foreach (Player, playerid)
  623. {
  624. GetPlayerName(playerid, name, sizeof (name));
  625. if (!strcmp(name, string[stringPos], true, id))
  626. {
  627. setarg(paramPos, 0, playerid);
  628. num = true;
  629. break;
  630. }
  631. }
  632. if (!num)
  633. {
  634. setarg(paramPos, 0, INVALID_PLAYER_ID);
  635. }
  636. string[end] = ch;
  637. #if defined __SSCANF_FOREACH__
  638. #undef foreach
  639. #undef __SSCANF_FOREACH__
  640. #endif
  641. }
  642. stringPos = end;
  643. }
  644. case 's', 'z':
  645. {
  646. new
  647. i = 0,
  648. ch;
  649. if (format[formatPos])
  650. {
  651. while ((ch = string[stringPos++]) && ch != delim)
  652. {
  653. setarg(paramPos, i++, ch);
  654. }
  655. if (!i)
  656. {
  657. return -1;
  658. }
  659. }
  660. else
  661. {
  662. while ((ch = string[stringPos++]))
  663. {
  664. setarg(paramPos, i++, ch);
  665. }
  666. }
  667. stringPos--;
  668. setarg(paramPos, i, '\0');
  669. }
  670. default:
  671. {
  672. continue;
  673. }
  674. }
  675. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  676. {
  677. stringPos++;
  678. }
  679. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  680. {
  681. stringPos++;
  682. }
  683. paramPos++;
  684. }
  685. do
  686. {
  687. if ((delim = format[formatPos++]) > ' ')
  688. {
  689. if (delim == '\'')
  690. {
  691. while ((delim = format[formatPos++]) && delim != '\'') {}
  692. }
  693. else if (delim != 'z')
  694. {
  695. return delim;
  696. }
  697. }
  698. }
  699. while (delim > ' ');
  700. return 0;
  701. }
Add Comment
Please, Sign In to add comment