20.12.2013, 17:00
Код:
E:\Servert\18WoS\filterscripts\bank.pwn(436) : warning 203: symbol is never used: "ybank_SetMoney" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Warning.
Код:
/* * YLLERON'S BANK SYSTEM * 2011 © * You can't present this script as your, or * make version and public it without my perm. * * Version: 1.7a * Cheers Y */ #include <a_samp> #tryinclude <dini> // Defines --------------------------------------------------------------------- //------------------------------------------------------------------------------ #define MAX_BANK 50 //-----------------------------| #define YBANK_FILE_PATH "/ybank/users/%s.ini" #define c_YBANK:: c_YBANK_ #define YBANK:: YBANK_ #define PDATA:: PDATA_ //-----------------------------| #define YDIALOG ShowPlayerDialog //-----------------------------| #define INPUT DIALOG_STYLE_INPUT #define LIST DIALOG_STYLE_LIST #define BOX DIALOG_STYLE_MSGBOX //-----------------------------| #define SCRIPT:%0(%1) \ forward %0(%1); \ public %0(%1) #define PRIVATE:%0(%1) \ stock %0(%1) //-----------------------------| #define YD_DEPOSITACCOUNT 100 #define YD_ACCOUNTSTATUS 101 #define YD_TRANSACTAMOUT 102 #define YD_DRAWACCOUNT 103 #define YD_TRANSACTID 104 #define YD_CHANGEPASS 105 #define YD_GETPASS 106 #define YD_REGIST 107 #define YD_DELACC 108 #define YD_BASIC 109 #define YD_LOGIN 110 //-----------------------------| #define C_RED 0xFF0000AA //-----------------------------| enum e_ybank { Float:Float_X, Float:Float_Y, Float:Float_Z, NameBank[50], IdDialog, IdPickup, Cash } enum e_ypData { TransactName[32], TransactID, bool:Log } new YBANK::[MAX_BANK][e_ybank]; new YBANK::MAX_COUNT = 0; static PDATA::[MAX_PLAYERS][e_ypData]; SCRIPT: yOnDialogResponse ( playerid, dialogid, response, listitem, inputtext[] ) { for ( new i=0;i<YBANK::MAX_COUNT;i++ ) { if ( dialogid == YBANK::[i][IdDialog] ) { new nb[ 50 ]; format ( nb,50,"Bank %s", YBANK::[i][NameBank] ); switch ( listitem ) { case 0: { new _Str1 [ 80 ]; format (_Str1, sizeof (_Str1), "YBANK: On your account is $%i", ybank_Money(playerid) ); YDIALOG ( playerid, YBANK::[i][IdDialog], LIST, nb, "Account status\nDraw from account\nDeposit to account\nTransact cash\nDelete Account\nChange pass", "OK", ""); } case 1: { YDIALOG ( playerid, YD_DRAWACCOUNT, INPUT, nb, "YBANK: Please type amout to draw", "OK", "" ); } case 2: { YDIALOG ( playerid, YD_DEPOSITACCOUNT, INPUT, nb, "YBANK: Please type amout to deposit", "OK", "" ); } case 3: { YDIALOG ( playerid, YD_TRANSACTID, INPUT, nb, "YBANK: Please type id of given player", "OK", "" ); } case 4: { YDIALOG ( playerid, YD_DELACC, BOX, nb, "YBANK: Are you sure?", "Yes", "No" ); } case 5: { YDIALOG ( playerid, YD_CHANGEPASS, INPUT, nb, "YBANK: Please type your new password", "OK", "Cancel" ); } case 6: { return true; } } } break; } if ( dialogid == YD_BASIC ) { if ( response ) { return 1; } } if ( dialogid == YD_REGIST ) { if ( response ) { YDIALOG ( playerid, YD_GETPASS, INPUT, "Please fill following textfield", "Type your password to you account", "Submit", "" ); } } if ( dialogid == YD_LOGIN ) { if ( response ) { if (!strlen(inputtext)) return YDIALOG ( playerid, YD_LOGIN, INPUT, "Error", "Welcome!\nPlease fill following field with your account password", "Login", "Cancel" ); else { new pass[20], fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); strcat( pass, dini_Get(fp, "BankPass"), 20 ); if (phash(inputtext) == strval(pass)) { PDATA::[playerid][Log] = true; SendClientMessage ( playerid, C_RED, "YBANK: You've been successfully logged in your account" ); } } } } if ( dialogid == YD_GETPASS ) { if ( response ) { if (!strlen(inputtext) || strlen(inputtext) > 12) return SendClientMessage ( playerid, C_RED, "YBANK: Password lenght must be in 4-12 range" ); else { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); dini_Create(fp); // Password dini_IntSet(fp, "BankPass", phash(inputtext)); // Bank cash dini_IntSet(fp, "BankCash", 0); SendClientMessage ( playerid, C_RED, "YBANK: You've been successfully registered in bank" ); } } } if ( dialogid == YD_DRAWACCOUNT ) { if ( response ) { if ( !strlen ( inputtext ) ) return YDIALOG ( playerid, YD_DRAWACCOUNT, INPUT, "Bank" , "YBANK: Please type amout to draw", "OK", "" ); if ( ybank_Money( playerid ) < strval(inputtext) ) return SendClientMessage ( playerid, C_RED, "YBANK: You don't have so much money on your account!" ); else { new pDraw = strval(inputtext); GivePlayerMoney( playerid, pDraw ); ybank_Delete ( playerid, pDraw ); new _Str [ 90 ]; format ( _Str, sizeof (_Str), "Cash in bank: $%i\nYou draw: $%i", ybank_Money ( playerid ), pDraw ); YDIALOG ( playerid, YD_BASIC, BOX, "Information", _Str, "OK", "" ); } } } if ( dialogid == YD_DEPOSITACCOUNT ) { if ( response ) { if ( !strlen ( inputtext ) ) return YDIALOG ( playerid, YD_DEPOSITACCOUNT, INPUT, "Error", "YBANK: Please type amout to deposit", "OK", "" ); if ( GetPlayerMoney ( playerid ) < strval( inputtext ) ) return SendClientMessage ( playerid, C_RED, "YBANK: You don't have amout, you typed" ); else { new pDeposit = strval( inputtext ); GivePlayerMoney ( playerid, -pDeposit); ybank_Add ( playerid, pDeposit ); new _Str [ 90 ]; format ( _Str, sizeof (_Str), "Cash in bank: $%i\nYou deposit: $%i", ybank_Money ( playerid ), pDeposit ); YDIALOG ( playerid, YD_BASIC, BOX, "Information", _Str, "OK", "" ); } } } if ( dialogid == YD_TRANSACTID ) { if ( response ) { if ( !strlen ( inputtext ) ) return YDIALOG ( playerid, YD_TRANSACTID, INPUT, "Error", "YBANK: Please type id/name of given player", "OK", "Cancel" ); if (IsNumeric(inputtext)) { new targetid = strval(inputtext); if ( IsPlayerConnected(targetid) ) { PDATA::[playerid][TransactID] = targetid; } } else { strcat( PDATA::[playerid][TransactName], inputtext, 32 ); YDIALOG ( playerid, YD_TRANSACTAMOUT, BOX, "Bank", "YBANK: Type amout cash to transact", "OK", "Cancel" ); } } } if ( dialogid == YD_TRANSACTAMOUT ) { if ( response ) { new amout = strval(inputtext); if ( !strlen ( inputtext ) ) return YDIALOG ( playerid, YD_TRANSACTAMOUT, BOX, "Error", "YBANK: Type amout cash to transact", "OK", "Cancel" ); if ( !IsNumeric ( inputtext ) ) return YDIALOG ( playerid, YD_TRANSACTAMOUT, BOX, "Error", "YBANK: Type amout cash to transact", "OK", "Cancel" ); else { new targetid = PDATA::[playerid][TransactID]; if ( IsPlayerConnected (targetid) ) { ybank_Add ( targetid, amout ); ybank_Delete ( playerid, amout ); } else { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(getId(inputtext))); if ( dini_Exists(fp) ) { ybank_Add ( getId(inputtext), amout ); ybank_Delete ( playerid, amout ); } } new _Str [ 90 ]; format ( _Str, sizeof (_Str), "Cash in bank: $%i\nYou transact: $%i (ID: %i)", ybank_Money ( playerid ), amout, targetid ); YDIALOG ( playerid, YD_BASIC, BOX, "Information", _Str, "OK", "" ); } } } if ( dialogid == YD_DELACC ) { if ( response ) { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); fremove(fp); SendClientMessage(playerid, C_RED, "YBANK: Your account has been deleted!"); } } if ( dialogid == YD_CHANGEPASS ) { if ( response ) { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); if ( dini_Exists (fp) ) { dini_IntSet(fp, "BankPass", phash(inputtext)); } } } return true; } SCRIPT: yOnPlayerPickUpPickup ( playerid, pickupid ) { for ( new i=0;i<YBANK::MAX_COUNT;i++ ) { if ( pickupid == YBANK::[i][IdPickup] ) { YBANK::[i][IdDialog] = i; //---------------------------------------- new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); //----------------------------------------- if (!dini_Exists(fp)) { new str[ 100 ]; format( str, sizeof(str), "Welcome %s", getName(playerid)); YDIALOG ( playerid, YD_REGIST, BOX, str, "Do you want create account in our bank?", "Yes", "No, thanks" ); } else { if ( !PDATA::[playerid][Log] ) { YDIALOG ( playerid, YD_LOGIN, INPUT, "Login", "Welcome!\nPlease fill following field with your account password", "Login", "Cancel" ); } else { new nb[ 50 ]; format(nb,50,"Bank %s", YBANK::[i][NameBank]); YDIALOG ( playerid, YBANK::[i][IdDialog], LIST, nb, "Account status\nDraw from account\nDeposit to account\nTransact cash\nDelete Account\nChange pass", "OK", ""); } } } } return true; } SCRIPT: CreateYBank( Float:X, Float:Y, Float:Z, bankname[] ) { if ( YBANK::MAX_COUNT <= MAX_BANK ) { YBANK::MAX_COUNT++; new bankid = YBANK::MAX_COUNT; YBANK::[bankid][Float_X] = X; YBANK::[bankid][Float_Y] = Y; YBANK::[bankid][Float_Z] = Z; strmid( YBANK::[bankid][NameBank], bankname, 0, strlen( bankname ), 50 ); CreateYBankPickup( bankid, X, Y, Z); printf ( "YBANK - Banks created %i", YBANK::MAX_COUNT ); } else { printf ( "YBANK says: BANK limit exceed! Banks created %i", YBANK::MAX_COUNT ); return false; } return true; } SCRIPT: CreateYBankPickup( bankid, Float:X, Float:Y, Float:Z) { YBANK::[bankid][IdPickup] = CreatePickup( 1318, 1, X, Y, Z, 0 ); return true; } ybank_SetMoney( playerid, cash ) { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid))); if ( dini_Exists(fp) ) return dini_IntSet( fp, "BankCash", cash ); return 1; } ybank_Delete( playerid, cash ) { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); if ( dini_Exists(fp ) ) return dini_IntSet( fp, "BankCash", dini_Int( fp, "BankCash")-cash ); return 1; } ybank_Money( playerid ) { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); if ( dini_Exists(fp ) ) return dini_Int( fp, "BankCash"); return 1; } ybank_Add( playerid, cash ) { new fp[70]; format(fp, sizeof(fp), YBANK_FILE_PATH, getName(playerid)); if ( dini_Exists(fp ) ) return dini_IntSet( fp, "BankCash", dini_Int(fp, "BankCash" )+cash ); return 1; } getId(pname[]) { for ( new i=0;i<MAX_PLAYERS;i++ ) { if ( !strcmp(pname, getName(i), true) ) { return i; } } return -1; } getName(playerid) { new n[25]; GetPlayerName(playerid, n, sizeof(n)); return n; } stock phash(buf[]) { new length=strlen(buf); new s1 = 1; new s2 = 0; new n; for (n=0; n<length; n++) { s1 = (s1 + buf[n]) % 65521; s2 = (s2 + s1) % 65521; } return (s2 << 16) + s1; } stock IsNumeric(string[]) { for (new i = 0, j = strlen(string); i < j; i++) { if (string[i] > '9' || string[i] < '0') { return 0; } } return 1; }