MrMegaTx

[FS]Banco

Nov 20th, 2011
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.76 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <dini>
  6.  
  7. #define COLOR_WHITE 0xffffffff
  8. #define COLOR_LIGHTGREEN 0x00ff00ff
  9.  
  10. //Colores Pawno Generados por PawnoGen v0.2 by Shoock
  11.  
  12. #pragma tabsize 0
  13.  
  14. new archivo[256];
  15.  
  16. public OnFilterScriptInit()
  17. {
  18. print("-----------------------------------------");
  19. print("----------Bank System by rooT.----------");
  20. print("-----------------------------------------");
  21. return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26. return 1;
  27. }
  28.  
  29. CMD:depositar(playerid, params[])
  30. {
  31. new dinero, string[128];
  32. if(sscanf(params, "d", dinero)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /depositar <cantidad>");
  33. if(!sscanf(params, "d", dinero))
  34. {
  35. if(GetPlayerMoney(playerid) < dinero) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "No tienes ese dinero!");
  36. if(GetPlayerMoney(playerid) >= dinero)
  37. {
  38. new pname[MAX_PLAYER_NAME];
  39. GetPlayerName(playerid, pname, sizeof(pname));
  40. format(archivo, sizeof(archivo), "Banco/%s.txt", pname);
  41.  
  42. if(dini_Exists(archivo))
  43. {
  44. dini_IntSet(archivo, "Saldo", dini_Int(archivo, "Saldo") +dinero);
  45. }
  46. else if(!dini_Exists(archivo))
  47. {
  48. dini_Create(archivo);
  49. dini_IntSet(archivo, "Saldo", dinero);
  50. }
  51. format(string, sizeof(string), "|- Banco -| Depositaste %d, tu saldo actual es %d", dinero, dini_Int(archivo, "Saldo"));
  52. SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
  53. GivePlayerMoney(playerid, -dinero);
  54. }
  55. }
  56. return 1;
  57. }
  58.  
  59. CMD:retirar(playerid, params[])
  60. {
  61. new dinero, string[128];
  62. if(sscanf(params, "d", dinero)) return SendClientMessage(playerid, COLOR_WHITE, "USO: /retirar <cantidad>");
  63. if(!sscanf(params, "d", dinero))
  64. {
  65. new pname[MAX_PLAYER_NAME];
  66. GetPlayerName(playerid, pname, sizeof(pname));
  67. format(archivo, sizeof(archivo), "Banco/%s.txt", pname);
  68. if(dini_Exists(archivo))
  69. {
  70. if(dini_Int(archivo, "Saldo") < dinero) return SendClientMessage(playerid, COLOR_LIGHTGREEN, "No tienes esa cantidad de dinero en el banco!");
  71. else if(dini_Int(archivo, "Saldo") >= dinero)
  72. {
  73. GivePlayerMoney(playerid, dinero);
  74. dini_IntSet(archivo, "Saldo", dini_Int(archivo, "Saldo") -dinero);
  75. format(string, sizeof(string), "|- Banco -| Retiraste %d, tu saldo actual es %d", dinero, dini_Int(archivo, "Saldo"));
  76. SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
  77. }
  78. }
  79. else if(!dini_Exists(archivo))
  80. {
  81. SendClientMessage(playerid, COLOR_LIGHTGREEN, "|- Banco -| No tienes cuenta en el banco!");
  82. }
  83. }
  84. return 1;
  85. }
  86.  
  87. CMD:saldo(playerid, params[])
  88. {
  89.  
  90. new pname[MAX_PLAYER_NAME];
  91. GetPlayerName(playerid, pname, sizeof(pname));
  92. format(archivo, sizeof(archivo), "Banco/%s.txt", pname);
  93. if(dini_Exists(archivo))
  94. {
  95. new string[128];
  96. format(string, sizeof(string), "|- Banco -| Tu saldo actual es %d", dini_Int(archivo, "Saldo"));
  97. SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
  98. }
  99. else if(!dini_Exists(archivo))
  100. {
  101. SendClientMessage(playerid, COLOR_LIGHTGREEN, "|- Banco -| No tienes cuenta en el banco!");
  102. }
  103. return 1;
  104. }
  105.  
  106. CMD:banco(playerid, params[])
  107. {
  108. SendClientMessage(playerid, COLOR_LIGHTGREEN, "Comandos del banco:");
  109. SendClientMessage(playerid, COLOR_LIGHTGREEN, "/depositar <cantidad>: Deposita X cantidad de dinero.");
  110. SendClientMessage(playerid, COLOR_LIGHTGREEN, "/retirar <cantidad>: Retira X cantidad de dinero.");
  111. SendClientMessage(playerid, COLOR_LIGHTGREEN, "/saldo: Para ver tu saldo en el banco");
  112. return 1;
  113. }
  114.  
  115. //------------------------------Sscanf-----------------------------------------
  116. stock sscanf(string[], format[], {Float,_}:...)
  117. {
  118. new
  119. formatPos = 0,
  120. stringPos = 0,
  121. paramPos = 2,
  122. paramCount = numargs();
  123. while (paramPos < paramCount && string[stringPos])
  124. {
  125. switch (format[formatPos++])
  126. {
  127. case '\0':
  128. {
  129. return 0;
  130. }
  131. case 'i', 'd':
  132. {
  133. new
  134. neg = 1,
  135. num = 0,
  136. ch = string[stringPos];
  137. if (ch == '-')
  138. {
  139. neg = -1;
  140. ch = string[++stringPos];
  141. }
  142. do
  143. {
  144. stringPos++;
  145. if (ch >= '0' && ch <= '9')
  146. {
  147. num = (num * 10) + (ch - '0');
  148. }
  149. else
  150. {
  151. return 1;
  152. }
  153. }
  154. while ((ch = string[stringPos]) && ch != ' ');
  155. setarg(paramPos, 0, num * neg);
  156. }
  157. case 'h', 'x':
  158. {
  159. new
  160. ch,
  161. num = 0;
  162. while ((ch = string[stringPos++]))
  163. {
  164. switch (ch)
  165. {
  166. case 'x', 'X':
  167. {
  168. num = 0;
  169. continue;
  170. }
  171. case '0' .. '9':
  172. {
  173. num = (num << 4) | (ch - '0');
  174. }
  175. case 'a' .. 'f':
  176. {
  177. num = (num << 4) | (ch - ('a' - 10));
  178. }
  179. case 'A' .. 'F':
  180. {
  181. num = (num << 4) | (ch - ('A' - 10));
  182. }
  183. case ' ':
  184. {
  185. break;
  186. }
  187. default:
  188. {
  189. return 1;
  190. }
  191. }
  192. }
  193. setarg(paramPos, 0, num);
  194. }
  195. case 'c':
  196. {
  197. setarg(paramPos, 0, string[stringPos++]);
  198. }
  199. case 'f':
  200. {
  201. new tmp[25];
  202. strmid(tmp, string, stringPos, stringPos+sizeof(tmp)-2);
  203. setarg(paramPos, 0, _:floatstr(tmp));
  204. }
  205. case 's', 'z':
  206. {
  207. new
  208. i = 0,
  209. ch;
  210. if (format[formatPos])
  211. {
  212. while ((ch = string[stringPos++]) && ch != ' ')
  213. {
  214. setarg(paramPos, i++, ch);
  215. }
  216. if (!i) return 1;
  217. }
  218. else
  219. {
  220. while ((ch = string[stringPos++]))
  221. {
  222. setarg(paramPos, i++, ch);
  223. }
  224. }
  225. stringPos--;
  226. setarg(paramPos, i, '\0');
  227. }
  228. default:
  229. {
  230. continue;
  231. }
  232. }
  233. while (string[stringPos] && string[stringPos] != ' ')
  234. {
  235. stringPos++;
  236. }
  237. while (string[stringPos] == ' ')
  238. {
  239. stringPos++;
  240. }
  241. paramPos++;
  242. }
  243. while (format[formatPos] == 'z') formatPos++;
  244. return format[formatPos];
  245. }
  246. //---------------------Fin Sscanff--------------------
  247.  
Advertisement
Add Comment
Please, Sign In to add comment