Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*VISITE NOSSO SITE: http://www.sampknd.com/
- SAMP KND MELHOR BLOG DE SAMP DO BRASIL
- */
- #include <a_samp>
- #include <file>
- #define dorado 0xFFD700
- #define plateado 0xC0C0C0
- #define C_Banco_Dialogid 666
- #define CAJA_FUERTE "/Afiliados/%s.ini"
- forward split(const strsrc[], strdest[][], delimiter);
- forward ini_GetKey( line[] );
- forward ini_GetValue( line[] );
- forward Afiliado_Bancario(playerid);
- forward No_Afiliado_Bancario(playerid);
- enum C_Info
- {
- C_Banco
- }
- new PlayerInfo[MAX_PLAYERS][C_Info];
- new Pickupid_C_banco_Entrada;
- new Pickupid_C_banco_Salida;
- new Pickup_C_Banco,Pickup_C_Banco_A,Pickup_C_Banco_B;
- new Verificacion[MAX_PLAYERS]; //RegistrationStep
- new Afiliacion[MAX_PLAYERS]; //gPlayerLogged
- ///--------------------------------------------------------------------------///
- ///--------------------- [ OnFilterScriptInit ] -----------------------------///
- ///--------------------------------------------------------------------------///
- public OnFilterScriptInit()
- {
- print("\n------------------------------------------------");
- print("|| Sistema de Banco By: Cesar_Google Cargado ||");
- print("------------------------------------------------\n");
- Pickupid_C_banco_Entrada = CreatePickup(1239,1,1420.2372,-1623.8413,13.5469,0);
- Pickupid_C_banco_Salida = CreatePickup(1239,1,2305.6890,-16.0881,26.7496,0);
- Pickup_C_Banco = CreatePickup(1829,2,2310.3286,-8.5272,26.7422,0);
- Pickup_C_Banco_A = CreatePickup(1829,2,2309.9382,-2.1212,26.7422,0);
- Pickup_C_Banco_B = CreatePickup(1829,2,2316.2710,-4.5288,26.7422,0);
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///---------------------- [ OnPlayerConnect ] -------------------------------///
- ///--------------------------------------------------------------------------///
- public OnPlayerConnect(playerid)
- {
- new Nombre[MAX_PLAYER_NAME], string[256];
- Verificacion[playerid] = 0;
- Afiliacion[playerid] = 0;
- GetPlayerName(playerid, Nombre , sizeof( Nombre ));
- format(string, sizeof(string), CAJA_FUERTE , Nombre);
- if (Verificacion[playerid] == 0 && Afiliacion[playerid] != 1)
- {
- new sendername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, sendername, sizeof(sendername));
- format(string, sizeof(string), CAJA_FUERTE , sendername);
- new File: hFile = fopen(string, io_read);
- if (hFile)
- {
- Afiliado_Bancario(playerid);
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new idx,cmd[256];
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/mmm", true) == 0)
- {
- SetPlayerPos(playerid,1423.2372,-1625.8413,13.5469);
- return 1;
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///------------------------ [ OnPlayerUpdate ] ------------------------------///
- ///--------------------------------------------------------------------------///
- public OnPlayerUpdate(playerid)
- {
- new string[64];
- new Nombre[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nombre, sizeof( Nombre ) );
- format(string , sizeof( string ),CAJA_FUERTE ,Nombre );
- new File: Datos = fopen(string ,io_write );
- if ( Datos )
- {
- new var[32];
- format(var, 32,"Banco=%d\n", PlayerInfo[playerid][C_Banco]);fwrite(Datos ,var );
- fclose( Datos );
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///---------------------- [ OnPlayerDisconnect ] ----------------------------///
- ///--------------------------------------------------------------------------///
- public OnPlayerDisconnect(playerid, reason)
- {
- new string[64];
- new Nombre[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nombre, sizeof( Nombre ) );
- format(string , sizeof( string ),CAJA_FUERTE ,Nombre );
- new File: Datos = fopen(string ,io_write );
- if ( Datos )
- {
- new var[32];
- format(var, 32,"Banco=%d\n", PlayerInfo[playerid][C_Banco]);fwrite(Datos ,var );
- fclose( Datos );
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///-------------------- [ OnPlayerPickUpPickup ] ----------------------------///
- ///--------------------------------------------------------------------------///
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(Pickup_C_Banco == pickupid){ShowPlayerDialog(playerid,C_Banco_Dialogid,DIALOG_STYLE_LIST,"Banco Central","depósito\r\nRemover\r\nBalance","aceitar","Cancelar");}
- if(Pickup_C_Banco_A == pickupid){ShowPlayerDialog(playerid,C_Banco_Dialogid,DIALOG_STYLE_LIST,"Banco Central","depósito\r\nRemover\r\nBalance","aceitar","Cancelar");}
- if(Pickup_C_Banco_B == pickupid){ShowPlayerDialog(playerid,C_Banco_Dialogid,DIALOG_STYLE_LIST,"Banco Central","depósito\r\nRemover\r\nBalance","aceitar","Cancelar");}
- /******************************************************************************/
- if(Pickupid_C_banco_Entrada == pickupid)
- {
- SetPlayerInterior(playerid,0);
- SetPlayerPos(playerid,2308.3015,-15.6663,26.7496);
- return 1;
- }
- if(Pickupid_C_banco_Salida == pickupid)
- {
- SetPlayerInterior(playerid,0);
- SetPlayerPos(playerid,1421.9677,-1623.8685,13.5469);
- return 1;
- }
- /******************************************************************************/
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///--------------------- [ OnDialogResponse ] -------------------------------///
- ///--------------------------------------------------------------------------///
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[256];
- switch(dialogid == C_Banco_Dialogid)
- {
- case 1:
- {
- if(!response)
- {
- SendClientMessage(playerid, dorado, "transação cancelada.");
- return 1;
- }
- switch(listitem)
- {
- case 0:
- {
- ShowPlayerDialog(playerid,C_Banco_Dialogid+1,DIALOG_STYLE_INPUT,"Depositar","Introduza o montante a depositar","Depositar","Cancelar");
- }
- case 1:
- {
- ShowPlayerDialog(playerid,C_Banco_Dialogid+2,DIALOG_STYLE_INPUT,"Retirar","Introduza o montante a Retirar","Retirar","Cancelar");
- }
- case 2:
- {
- new Balance_Total[128];
- format(Balance_Total,128,"O seu saldo é de $%d",PlayerInfo[playerid][C_Banco]);
- ShowPlayerDialog(playerid,C_Banco_Dialogid+3,DIALOG_STYLE_MSGBOX,"Balance",Balance_Total,"aceitar","aceitar");
- }
- }
- }
- }
- if(dialogid == C_Banco_Dialogid+1)
- {
- if(response)
- {
- if(!strlen(inputtext))
- {
- format(string, sizeof(string), "Servidor: você tem $%d na sua conta.", PlayerInfo[playerid][C_Banco]);
- SendClientMessage(playerid, plateado, string);
- return 1;
- }
- new Depositar_Dinero = strval(inputtext);
- if(!strlen(inputtext))
- {
- format(string, sizeof(string), "Servidor: você tem $%d na sua conta.", PlayerInfo[playerid][C_Banco]);
- SendClientMessage(playerid, plateado, string);
- return 1;
- }
- if (Depositar_Dinero > GetPlayerMoney(playerid) || Depositar_Dinero < 1)
- {
- SendClientMessage(playerid, plateado, "Servidor: Você não tem esse montante");
- return 1;
- }
- GivePlayerMoney(playerid,-Depositar_Dinero);
- new C_Banco_Val = PlayerInfo[playerid][C_Banco];
- PlayerInfo[playerid][C_Banco]=Depositar_Dinero+PlayerInfo[playerid][C_Banco];
- SendClientMessage(playerid, plateado, "|___Estado Bancario___|");
- format(string, sizeof(string), "Balance Anterior: $%d", C_Banco_Val);
- SendClientMessage(playerid, plateado, string);
- format(string, sizeof(string), "Deposito: $%d",Depositar_Dinero);
- SendClientMessage(playerid, plateado, string);
- SendClientMessage(playerid, plateado, "|_____________________|");
- format(string, sizeof(string), "novo Balance: $%d", PlayerInfo[playerid][C_Banco]);
- SendClientMessage(playerid, plateado, string);
- }
- }
- if(dialogid == C_Banco_Dialogid+2)
- {
- new Retirar_Dinero = strval(inputtext);
- if (Retirar_Dinero > PlayerInfo[playerid][C_Banco] || Retirar_Dinero < 1)
- {
- SendClientMessage(playerid, dorado, "Servidor: Você não tem esse montante!");
- return 1;
- }
- GivePlayerMoney(playerid,Retirar_Dinero);
- PlayerInfo[playerid][C_Banco]=PlayerInfo[playerid][C_Banco]-Retirar_Dinero;
- format(string, sizeof(string), " você tem $%d na sua conta: $%d ", Retirar_Dinero,PlayerInfo[playerid][C_Banco]);
- SendClientMessage(playerid, dorado, string);
- return 1;
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///---------------------- [ Afiliado_Bancario ] -----------------------------///
- ///--------------------------------------------------------------------------///
- public Afiliado_Bancario(playerid)
- {
- new string[64];
- new Nombre[MAX_PLAYER_NAME];
- new NombreSplit[3][MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nombre, sizeof( Nombre ));
- split(Nombre, NombreSplit, '_');
- format(string, sizeof( string ) ,CAJA_FUERTE , Nombre );
- new File: DatosUsuario = fopen(string ,io_read );
- if ( DatosUsuario )
- {
- new key[ 256 ] , val[ 256 ];
- new Data[ 256 ];
- while ( fread( DatosUsuario , Data , sizeof( Data ) ) )
- {
- key = ini_GetKey( Data );
- if( strcmp( key , "Banco" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][C_Banco] = strval( val ); }
- }
- fclose( DatosUsuario );
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///--------------------- [ No_Afiliado_Bancario ] ---------------------------///
- ///--------------------------------------------------------------------------///
- public No_Afiliado_Bancario(playerid)
- {
- new string[64];
- new Nombre[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nombre, sizeof( Nombre ) );
- format(string , sizeof( string ),CAJA_FUERTE ,Nombre );
- new File: Datos = fopen(string ,io_write );
- if ( Datos )
- {
- new var[32];
- format(var, 32,"Banco=%d\n", PlayerInfo[playerid][C_Banco]);fwrite(Datos ,var );
- fclose( Datos );
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///---------------------------- [ split ] -----------------------------------///
- ///--------------------------------------------------------------------------///
- public split(const strsrc[], strdest[][], delimiter)
- {
- new i, li;
- new aNum;
- new len;
- while(i <= strlen(strsrc)){
- if(strsrc[i]==delimiter || i==strlen(strsrc)){
- len = strmid(strdest[aNum], strsrc, li, i, 128);
- strdest[aNum][len] = 0;
- li = i+1;
- aNum++;
- }
- i++;
- }
- return 1;
- }
- ///--------------------------------------------------------------------------///
- ///---------------------------- [ stock ] -----------------------------------///
- ///--------------------------------------------------------------------------///
- stock ini_GetValue( line[] )
- {
- new valRes[256];
- valRes[0]=0;
- if ( strfind( line , "=" , true ) == -1 ) return valRes;
- strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
- return valRes;
- }
- //------------------------------------------------------------------------------
- stock ini_GetKey( line[] )
- {
- new keyRes[256];
- keyRes[0] = 0;
- if ( strfind( line , "=" , true ) == -1 ) return keyRes;
- strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
- return keyRes;
- }
- ///--------------------------------------------------------------------------///
- ///---------------------------- [ strtok ] ----------------------------------///
- ///--------------------------------------------------------------------------///
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement