Advertisement
cesar_google

C_Banco

May 22nd, 2012
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.68 KB | None | 0 0
  1. /*
  2.     ---== [ concluído Por Cesar_Google ] ==---
  3.       --= [ Sistema de Banco Por Dialogo ] =--
  4.             - [ 1 Tempo de Trabalho ] -
  5.         *** Número de linhas usadas 336 ***
  6.                   versão : 1.0
  7. - Sistema de diálogo Muito útil para Banco a Role Play
  8. - Os agradecimentos são Não Roubar créditos que não lhe Você gostaria que alguém fez o manto
  9.  
  10. Em breve :  Os caixas Automatico
  11. */
  12. #include <a_samp>
  13. #include <file>
  14. #define dorado 0xFFD700
  15. #define plateado 0xC0C0C0
  16. #define C_Banco_Dialogid 666
  17. #define CAJA_FUERTE "/Afiliados/%s.ini"
  18. forward split(const strsrc[], strdest[][], delimiter);
  19. forward ini_GetKey( line[] );
  20. forward ini_GetValue( line[] );
  21. forward Afiliado_Bancario(playerid);
  22. forward No_Afiliado_Bancario(playerid);
  23.  
  24. enum C_Info
  25. {
  26. C_Banco
  27. }
  28. new PlayerInfo[MAX_PLAYERS][C_Info];
  29. new Pickupid_C_banco_Entrada;
  30. new Pickupid_C_banco_Salida;
  31. new Pickup_C_Banco,Pickup_C_Banco_A,Pickup_C_Banco_B;
  32.  
  33. new Verificacion[MAX_PLAYERS]; //RegistrationStep
  34. new Afiliacion[MAX_PLAYERS];   //gPlayerLogged
  35. ///--------------------------------------------------------------------------///
  36. ///--------------------- [ OnFilterScriptInit ] -----------------------------///
  37. ///--------------------------------------------------------------------------///
  38. public OnFilterScriptInit()
  39. {
  40. print("\n------------------------------------------------");
  41. print("|| Sistema de Banco By: Cesar_Google Cargado ||");
  42. print("------------------------------------------------\n");
  43. Pickupid_C_banco_Entrada  = CreatePickup(1239,1,1420.2372,-1623.8413,13.5469,0);
  44. Pickupid_C_banco_Salida   = CreatePickup(1239,1,2305.6890,-16.0881,26.7496,0);
  45. Pickup_C_Banco            = CreatePickup(1829,2,2310.3286,-8.5272,26.7422,0);
  46. Pickup_C_Banco_A          = CreatePickup(1829,2,2309.9382,-2.1212,26.7422,0);
  47. Pickup_C_Banco_B          = CreatePickup(1829,2,2316.2710,-4.5288,26.7422,0);
  48. return 1;
  49. }
  50. ///--------------------------------------------------------------------------///
  51. ///---------------------- [ OnPlayerConnect ] -------------------------------///
  52. ///--------------------------------------------------------------------------///
  53. public OnPlayerConnect(playerid)
  54. {
  55. new Nombre[MAX_PLAYER_NAME], string[256];
  56. Verificacion[playerid] = 0;
  57. Afiliacion[playerid] = 0;
  58.  
  59. GetPlayerName(playerid, Nombre , sizeof( Nombre ));
  60. format(string, sizeof(string), CAJA_FUERTE , Nombre);
  61.  
  62. if (Verificacion[playerid] == 0 && Afiliacion[playerid] != 1)
  63. {
  64. new sendername[MAX_PLAYER_NAME];
  65. GetPlayerName(playerid, sendername, sizeof(sendername));
  66. format(string, sizeof(string), CAJA_FUERTE , sendername);
  67. new File: hFile = fopen(string, io_read);
  68. if (hFile)
  69. {
  70. Afiliado_Bancario(playerid);
  71. }
  72. }
  73. return 1;
  74. }
  75.  
  76. public OnPlayerCommandText(playerid, cmdtext[])
  77. {
  78. new idx,cmd[256];
  79. cmd = strtok(cmdtext, idx);
  80.  
  81. if(strcmp(cmd, "/mmm", true) == 0)
  82. {
  83. SetPlayerPos(playerid,1423.2372,-1625.8413,13.5469);
  84. return 1;
  85. }
  86. return 1;
  87. }
  88. ///--------------------------------------------------------------------------///
  89. ///------------------------ [ OnPlayerUpdate ] ------------------------------///
  90. ///--------------------------------------------------------------------------///
  91. public OnPlayerUpdate(playerid)
  92. {
  93. new string[64];
  94. new Nombre[MAX_PLAYER_NAME];
  95. GetPlayerName(playerid, Nombre, sizeof( Nombre ) );
  96. format(string , sizeof( string ),CAJA_FUERTE ,Nombre );
  97. new File: Datos = fopen(string ,io_write );
  98. if ( Datos )
  99. {
  100. new var[32];
  101. format(var, 32,"Banco=%d\n", PlayerInfo[playerid][C_Banco]);fwrite(Datos ,var );
  102. fclose( Datos );
  103. }
  104. return 1;
  105. }
  106. ///--------------------------------------------------------------------------///
  107. ///---------------------- [ OnPlayerDisconnect ] ----------------------------///
  108. ///--------------------------------------------------------------------------///
  109. public OnPlayerDisconnect(playerid, reason)
  110. {
  111. new string[64];
  112. new Nombre[MAX_PLAYER_NAME];
  113. GetPlayerName(playerid, Nombre, sizeof( Nombre ) );
  114. format(string , sizeof( string ),CAJA_FUERTE ,Nombre );
  115. new File: Datos = fopen(string ,io_write );
  116. if ( Datos )
  117. {
  118. new var[32];
  119. format(var, 32,"Banco=%d\n", PlayerInfo[playerid][C_Banco]);fwrite(Datos ,var );
  120. fclose( Datos );
  121. }
  122. return 1;
  123. }
  124. ///--------------------------------------------------------------------------///
  125. ///-------------------- [ OnPlayerPickUpPickup ] ----------------------------///
  126. ///--------------------------------------------------------------------------///
  127. public OnPlayerPickUpPickup(playerid, pickupid)
  128. {
  129. if(Pickup_C_Banco == pickupid){ShowPlayerDialog(playerid,C_Banco_Dialogid,DIALOG_STYLE_LIST,"Banco Central","depósito\r\nRemover\r\nBalance","aceitar","Cancelar");}
  130. if(Pickup_C_Banco_A == pickupid){ShowPlayerDialog(playerid,C_Banco_Dialogid,DIALOG_STYLE_LIST,"Banco Central","depósito\r\nRemover\r\nBalance","aceitar","Cancelar");}
  131. if(Pickup_C_Banco_B == pickupid){ShowPlayerDialog(playerid,C_Banco_Dialogid,DIALOG_STYLE_LIST,"Banco Central","depósito\r\nRemover\r\nBalance","aceitar","Cancelar");}
  132. /******************************************************************************/
  133. if(Pickupid_C_banco_Entrada == pickupid)
  134. {
  135. SetPlayerInterior(playerid,0);
  136. SetPlayerPos(playerid,2308.3015,-15.6663,26.7496);
  137. return 1;
  138. }
  139. if(Pickupid_C_banco_Salida == pickupid)
  140. {
  141. SetPlayerInterior(playerid,0);
  142. SetPlayerPos(playerid,1421.9677,-1623.8685,13.5469);
  143. return 1;
  144. }
  145. /******************************************************************************/
  146. return 1;
  147. }
  148. ///--------------------------------------------------------------------------///
  149. ///--------------------- [ OnDialogResponse ] -------------------------------///
  150. ///--------------------------------------------------------------------------///
  151. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  152. {
  153. new string[256];
  154. switch(dialogid == C_Banco_Dialogid)
  155. {
  156. case 1:
  157. {
  158. if(!response)
  159. {
  160. SendClientMessage(playerid, dorado, "transação cancelada.");
  161. return 1;
  162. }
  163. switch(listitem)
  164. {
  165. case 0:
  166. {
  167. ShowPlayerDialog(playerid,C_Banco_Dialogid+1,DIALOG_STYLE_INPUT,"Depositar","Introduza o montante a depositar","Depositar","Cancelar");
  168. }
  169. case 1:
  170. {
  171. ShowPlayerDialog(playerid,C_Banco_Dialogid+2,DIALOG_STYLE_INPUT,"Retirar","Introduza o montante a Retirar","Retirar","Cancelar");
  172. }
  173. case 2:
  174. {
  175. new Balance_Total[128];
  176. format(Balance_Total,128,"O seu saldo é de $%d",PlayerInfo[playerid][C_Banco]);
  177. ShowPlayerDialog(playerid,C_Banco_Dialogid+3,DIALOG_STYLE_MSGBOX,"Balance",Balance_Total,"aceitar","aceitar");
  178. }
  179.   }
  180.  }
  181. }
  182.  
  183. if(dialogid == C_Banco_Dialogid+1)
  184. {
  185. if(response)
  186. {
  187. if(!strlen(inputtext))
  188. {
  189. format(string, sizeof(string), "Servidor: você tem $%d na sua conta.", PlayerInfo[playerid][C_Banco]);
  190. SendClientMessage(playerid, plateado, string);
  191. return 1;
  192. }
  193. new Depositar_Dinero = strval(inputtext);
  194. if(!strlen(inputtext))
  195. {
  196. format(string, sizeof(string), "Servidor: você tem $%d na sua conta.", PlayerInfo[playerid][C_Banco]);
  197. SendClientMessage(playerid, plateado, string);
  198. return 1;
  199. }
  200. if (Depositar_Dinero > GetPlayerMoney(playerid) || Depositar_Dinero < 1)
  201. {
  202. SendClientMessage(playerid, plateado, "Servidor: Você não tem esse montante");
  203. return 1;
  204. }
  205. GivePlayerMoney(playerid,-Depositar_Dinero);
  206. new C_Banco_Val = PlayerInfo[playerid][C_Banco];
  207. PlayerInfo[playerid][C_Banco]=Depositar_Dinero+PlayerInfo[playerid][C_Banco];
  208. SendClientMessage(playerid, plateado, "|___Estado Bancario___|");
  209. format(string, sizeof(string), "Balance Anterior: $%d", C_Banco_Val);
  210. SendClientMessage(playerid, plateado, string);
  211. format(string, sizeof(string), "Deposito: $%d",Depositar_Dinero);
  212. SendClientMessage(playerid, plateado, string);
  213. SendClientMessage(playerid, plateado, "|_____________________|");
  214. format(string, sizeof(string), "novo Balance: $%d", PlayerInfo[playerid][C_Banco]);
  215. SendClientMessage(playerid, plateado, string);
  216. }
  217. }
  218.  
  219. if(dialogid == C_Banco_Dialogid+2)
  220. {
  221. new Retirar_Dinero = strval(inputtext);
  222. if (Retirar_Dinero > PlayerInfo[playerid][C_Banco] || Retirar_Dinero < 1)
  223. {
  224. SendClientMessage(playerid, dorado, "Servidor: Você não tem esse montante!");
  225. return 1;
  226. }
  227. GivePlayerMoney(playerid,Retirar_Dinero);
  228. PlayerInfo[playerid][C_Banco]=PlayerInfo[playerid][C_Banco]-Retirar_Dinero;
  229. format(string, sizeof(string), "  você tem $%d na sua conta: $%d ", Retirar_Dinero,PlayerInfo[playerid][C_Banco]);
  230. SendClientMessage(playerid, dorado, string);
  231. return 1;
  232. }
  233.  
  234. return 1;
  235. }
  236. ///--------------------------------------------------------------------------///
  237. ///---------------------- [ Afiliado_Bancario ] -----------------------------///
  238. ///--------------------------------------------------------------------------///
  239. public Afiliado_Bancario(playerid)
  240. {
  241. new string[64];
  242. new Nombre[MAX_PLAYER_NAME];
  243. new NombreSplit[3][MAX_PLAYER_NAME];
  244. GetPlayerName(playerid, Nombre, sizeof( Nombre ));
  245. split(Nombre, NombreSplit, '_');
  246. format(string, sizeof( string ) ,CAJA_FUERTE , Nombre );
  247. new File: DatosUsuario = fopen(string ,io_read );
  248. if ( DatosUsuario )
  249. {
  250. new key[ 256 ] , val[ 256 ];
  251. new Data[ 256 ];
  252. while ( fread( DatosUsuario , Data , sizeof( Data ) ) )
  253. {
  254. key = ini_GetKey( Data );
  255. if( strcmp( key , "Banco" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][C_Banco] = strval( val ); }
  256. }
  257. fclose( DatosUsuario );
  258. }
  259. return 1;
  260. }
  261. ///--------------------------------------------------------------------------///
  262. ///--------------------- [ No_Afiliado_Bancario ] ---------------------------///
  263. ///--------------------------------------------------------------------------///
  264. public No_Afiliado_Bancario(playerid)
  265. {
  266. new string[64];
  267. new Nombre[MAX_PLAYER_NAME];
  268. GetPlayerName(playerid, Nombre, sizeof( Nombre ) );
  269. format(string , sizeof( string ),CAJA_FUERTE ,Nombre );
  270. new File: Datos = fopen(string ,io_write );
  271. if ( Datos )
  272. {
  273. new var[32];
  274. format(var, 32,"Banco=%d\n", PlayerInfo[playerid][C_Banco]);fwrite(Datos ,var );
  275. fclose( Datos );
  276. }
  277. return 1;
  278. }
  279. ///--------------------------------------------------------------------------///
  280. ///---------------------------- [ split ] -----------------------------------///
  281. ///--------------------------------------------------------------------------///
  282. public split(const strsrc[], strdest[][], delimiter)
  283. {
  284. new i, li;
  285. new aNum;
  286. new len;
  287. while(i <= strlen(strsrc)){
  288. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  289. len = strmid(strdest[aNum], strsrc, li, i, 128);
  290. strdest[aNum][len] = 0;
  291. li = i+1;
  292. aNum++;
  293. }
  294. i++;
  295. }
  296. return 1;
  297. }
  298. ///--------------------------------------------------------------------------///
  299. ///---------------------------- [ stock ] -----------------------------------///
  300. ///--------------------------------------------------------------------------///
  301. stock ini_GetValue( line[] )
  302. {
  303. new valRes[256];
  304. valRes[0]=0;
  305. if ( strfind( line , "=" , true ) == -1 ) return valRes;
  306. strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  307. return valRes;
  308. }
  309. //------------------------------------------------------------------------------
  310. stock ini_GetKey( line[] )
  311. {
  312. new keyRes[256];
  313. keyRes[0] = 0;
  314. if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  315. strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  316. return keyRes;
  317. }
  318. ///--------------------------------------------------------------------------///
  319. ///---------------------------- [ strtok ] ----------------------------------///
  320. ///--------------------------------------------------------------------------///
  321. strtok(const string[], &index)
  322. {
  323. new length = strlen(string);
  324. while ((index < length) && (string[index] <= ' '))
  325. {
  326. index++;
  327. }
  328. new offset = index;
  329. new result[20];
  330. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  331. {
  332. result[index - offset] = string[index];
  333. index++;
  334. }
  335. result[index - offset] = EOS;
  336. return result;
  337. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement