Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************
- **
- ** m_Bank
- ** v1.0
- **
- ***********************/
- #include <a_samp>
- #include <YSI\y_commands>
- #include <YSI\y_ini>
- /* ostalo */
- #define FILTERSCRIPT
- #define SCM(%0,%1,%2) SendClientMessage(%0,%1,%2)
- /* dialozi */
- #define KREIRAJ 3500
- #define ON_KREIRAO 3514
- #define BANKHELP 3501
- #define BANKDEPOSIT 3502
- #define BANKDEPOSIT2 3503
- #define ON_DEPOSIT 3504
- #define BANKWITHDRAW 3505
- #define BANKWITHDRAW2 3506
- #define ON_WITHDRAW 3507
- #define BANKBALANCE 3508
- #define BANKPIN 3509
- #define BANKPIN2 3510
- #define ON_PIN 3511
- #define BANKBRISI 3512
- #define BANKBRISI2 3513
- enum info
- {
- PinKod,
- Novac,
- Banka,
- Racun
- }
- new Podatci[MAX_PLAYERS][info];
- public OnPlayerConnect(playerid)
- {
- new
- stra[256];
- format(stra,sizeof(stra),"/mBank/%s.ini",GetName(playerid));
- if(!fexist(stra)) {
- SCM(playerid,-1,"Možete otvoriti bankovni račun pomoću {FF0000}/bank komande!");
- new
- INI:dat = INI_Open(stra);
- INI_SetTag(dat,"data");
- INI_WriteInt(dat,"Novac",0);
- INI_Close(dat);
- }
- else {
- if(fexist(stra)) {
- INI_ParseFile(stra, "Load_%s", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid,Podatci[playerid][Novac]); }
- }
- return true;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new
- stra[256];
- format(stra,sizeof stra,"/mBank/%s.ini",GetName(playerid));
- new
- INI:dat = INI_Open(stra);
- INI_SetTag(dat,"data");
- INI_WriteInt(dat,"Novac",GetPlayerMoney(playerid));
- INI_WriteInt(dat,"Banka",Podatci[playerid][Banka]);
- INI_WriteInt(dat,"PinKod",Podatci[playerid][PinKod]);
- INI_WriteInt(dat,"Racun",Podatci[playerid][Racun]);
- INI_Close(dat);
- return true;
- }
- YCMD:bankkreiraj(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- if(Podatci[playerid][Racun] == 1) return SCM(playerid,-1,"{FF0000}Već imate račun!");
- else
- ShowPlayerDialog(playerid,KREIRAJ,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Upišite željeni pin kod da bi ste napravili bankovni račun!\n{FF0000}(Pin kod mora biti u brojevima!)","Unesi","Odustani");
- return true; }
- YCMD:bankdeposit(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
- ShowPlayerDialog(playerid,BANKDEPOSIT,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
- YCMD:bankwithdraw(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
- ShowPlayerDialog(playerid,BANKWITHDRAW,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
- YCMD:bankbalance(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- new
- str[128];
- if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
- format(str,sizeof str,"Vaše trenutno stanje na bankovnom računu : $%d !",Podatci[playerid][Banka]);
- ShowPlayerDialog(playerid,BANKBALANCE,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori",""); return true; }
- YCMD:bankpin(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
- ShowPlayerDialog(playerid,BANKPIN,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
- YCMD:bankhelp(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- new
- strc[470];
- strcat(strc,"{FFFF00}BANKA KOMANDE : \n\n{FFFF00}/bankkreiraj {FFFFFF}- Služi za kreiranje bankovnog računa!\n{FFFF00}/bankdeposit {FFFFFF}- Služi za stavljanje novaca na bankovni račun!");
- strcat(strc,"\n{FFFF00}/bankwithdraw {FFFFFF}- Služi za vađenje novca iz bankovnog računa!\n{FFFF00}/bankbalance {FFFFFF}- Služi za provjeru trenutnog stanja na bankovnom računu!");
- strcat(strc,"\n{FFFF00}/bankpin {FFFFFF}- Služi za promjenu pin koda računa!\n{FFFF00}/bankobrisi {FFFFFF}- Služi za brisanje bankovnog računa!");
- ShowPlayerDialog(playerid,BANKHELP,DIALOG_STYLE_MSGBOX,"{00FF00}Banka Pomoć",strc,"Hvala","");
- return true; }
- YCMD:bankobrisi(playerid,params[],help) {
- #pragma unused help
- #pragma unused params
- if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
- ShowPlayerDialog(playerid,BANKBRISI,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == KREIRAJ) {
- if(!response) return false;
- new pin = strval(inputtext),
- str[356];
- Podatci[playerid][Racun] = 1;
- Podatci[playerid][PinKod] = pin;
- format(str,sizeof str,"{FFFFFF}Uspješno ste napravili bankovni račun!\n{FFFFFF}Ispod pišu vaše informacije o bankovnom računu:\n\n{FFFF00}Ime bankovnog računa : {FFFFFF}%s\n{FFFF00}Vaš pin kod : {FFFFFF}%d",GetName(playerid),pin);
- ShowPlayerDialog(playerid,ON_KREIRAO,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
- SCM(playerid,-1,"{00FF00}Uspješno ste napravili bankovni račun!");
- SCM(playerid,-1,"{00FFFF}Koristite {00FF00}/bankhelp {00FFFF}da bi ste vidjeli komande za kontroliranje računom!");
- }
- if(dialogid == BANKDEPOSIT) {
- new
- pin = strval(inputtext);
- if(pin == Podatci[playerid][PinKod]) return ShowPlayerDialog(playerid,BANKDEPOSIT2,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unesite iznos koji želite staviti na svoj bankovni račun!","Unesi","Odustani");
- else
- ShowPlayerDialog(playerid,BANKDEPOSIT,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani");
- }
- if(dialogid == BANKDEPOSIT2) {
- if(!response) return false;
- new val = strval(inputtext),
- str[256];
- if(val > GetPlayerMoney(playerid)) return SCM(playerid,-1,"{FF0000}Nemate toliko novca u džepu!");
- if(val < 0 || val > 99999999) return SCM(playerid,-1,"{FF0000}Možete depositati novca od $0 do $99999999 !");
- Podatci[playerid][Banka] = Podatci[playerid][Banka] + val;
- GivePlayerMoney(playerid, - val);
- format(str,sizeof str,"{FFFFFF}Uspješno ste depositali novce na račun!\n{FFFFFF}Depositali ste : {00FF00}$%d\n{FFFFFF}Trenutno stanje : {00FF00}$%d",val,Podatci[playerid][Banka]);
- ShowPlayerDialog(playerid,ON_DEPOSIT,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
- }
- if(dialogid == BANKWITHDRAW) {
- if(!response) return false;
- new
- pin = strval(inputtext);
- if(pin == Podatci[playerid][PinKod]) return ShowPlayerDialog(playerid,BANKWITHDRAW2,DIALOG_STYLE_INPUT,"{00FF00}Banka","Unesite iznos koji želite izvaditi sa svojeg bankovnog računa!","Unesi","Odustani");
- else
- ShowPlayerDialog(playerid,BANKWITHDRAW,DIALOG_STYLE_INPUT,"{00FF00}Banka","Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani");
- }
- if(dialogid == BANKWITHDRAW2) {
- if(!response) return false;
- new val = strval(inputtext),
- str[256];
- if(val > Podatci[playerid][Banka]) return SCM(playerid,-1,"Nemate toliko novaca u banci!");
- Podatci[playerid][Banka] = Podatci[playerid][Banka] - val;
- GivePlayerMoney(playerid,val);
- format(str,sizeof str,"{FFFFFF}Uspješno ste izvadili novce sa računa!\nIzvadili ste : {00FF00}$%d\n{FFFFFF}Trenutno stanje računa : {00FF00}$%d",val,Podatci[playerid][Banka]);
- ShowPlayerDialog(playerid,ON_WITHDRAW,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
- }
- if(dialogid == BANKPIN) {
- if(!response) return false;
- new
- pin = strval(inputtext);
- if(pin == Podatci[playerid][PinKod]) return ShowPlayerDialog(playerid,BANKPIN2,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Molimo vas unesite novi pin kod! {FF0000}(Mora biti u brojevima!)","Unesi","Odustani");
- else
- ShowPlayerDialog(playerid,BANKPIN,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani");
- }
- if(dialogid == BANKPIN2) {
- if(!response) return false;
- new
- novipin = strval(inputtext),
- str[128];
- Podatci[playerid][PinKod] = novipin;
- format(str,sizeof str,"{FFFFFF}Uspješno ste promjenili pin kod!\n{FFFFFF}Vaš novi pin kod je : {00FF00}%d {FFFFFF}!",novipin);
- ShowPlayerDialog(playerid,ON_PIN,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
- }
- if(dialogid == BANKBRISI) {
- if(!response) return false;
- new
- pin = strval(inputtext);
- if(pin == Podatci[playerid][PinKod]) return ShowPlayerDialog(playerid,BANKBRISI2,DIALOG_STYLE_MSGBOX,"{00FF00}Banka Brisanje Računa","{FFFFFF}Ovime brišete svoj bankovni račun! Dali ste sigurni da želite ovo! Bankovni račun je nemoguće vratiti !","Da","NE");
- else
- ShowPlayerDialog(playerid,BANKWITHDRAW,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani"); }
- if(dialogid == BANKBRISI2) {
- if(response) {
- SCM(playerid,-1,"{00FF00}Obrisali ste bankovni račun!");
- Podatci[playerid][Banka] = 0;
- Podatci[playerid][Racun] = 0;
- Podatci[playerid][PinKod] = 0;
- } else {
- SCM(playerid,-1,"{FFFF00}Odustali ste od brisanja bankovnog računa!"); } }
- return true; }
- forward Load_data(playerid,name[],value[]);
- public Load_data(playerid,name[],value[]) /* Y_Less */
- {
- INI_Int("Novac",Podatci[playerid][Novac]);
- INI_Int("Banka",Podatci[playerid][Banka]);
- INI_Int("PinKod",Podatci[playerid][PinKod]);
- INI_Int("Racun",Podatci[playerid][Racun]);
- return true;
- }
- stock GetName(playerid)
- {
- new
- ime[MAX_PLAYER_NAME];
- GetPlayerName(playerid,ime,sizeof ime);
- return ime;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement