Advertisement
Guest User

Untitled

a guest
Nov 14th, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.79 KB | None | 0 0
  1. /***********************
  2. **
  3. **       m_Bank
  4. **        v1.0
  5. **
  6. ***********************/
  7.  
  8. #include <a_samp>
  9. #include <YSI\y_commands>
  10. #include <YSI\y_ini>
  11.  
  12. /* ostalo */
  13. #define FILTERSCRIPT
  14. #define SCM(%0,%1,%2) SendClientMessage(%0,%1,%2)
  15.  
  16. /* dialozi */
  17. #define KREIRAJ 3500
  18. #define ON_KREIRAO 3514
  19. #define BANKHELP 3501
  20. #define BANKDEPOSIT 3502
  21. #define BANKDEPOSIT2 3503
  22. #define ON_DEPOSIT 3504
  23. #define BANKWITHDRAW 3505
  24. #define BANKWITHDRAW2 3506
  25. #define ON_WITHDRAW 3507
  26. #define BANKBALANCE 3508
  27. #define BANKPIN 3509
  28. #define BANKPIN2 3510
  29. #define ON_PIN 3511
  30. #define BANKBRISI 3512
  31. #define BANKBRISI2 3513
  32.  
  33. enum info
  34. {
  35.     PinKod,
  36.     Novac,
  37.     Banka,
  38.     Racun
  39. }
  40. new Podatci[MAX_PLAYERS][info];
  41.  
  42. public OnPlayerConnect(playerid)
  43. {
  44.     new
  45.           stra[256];
  46.     format(stra,sizeof(stra),"/mBank/%s.ini",GetName(playerid));
  47.     if(!fexist(stra)) {
  48.     SCM(playerid,-1,"Možete otvoriti bankovni račun pomoću {FF0000}/bank komande!");
  49.     new
  50.             INI:dat = INI_Open(stra);
  51.     INI_SetTag(dat,"data");
  52.     INI_WriteInt(dat,"Novac",0);
  53.     INI_Close(dat);
  54.     }
  55.     else {
  56.     if(fexist(stra)) {
  57.     INI_ParseFile(stra, "Load_%s", .bExtra = true, .extra = playerid);
  58.     GivePlayerMoney(playerid,Podatci[playerid][Novac]); }
  59.     }
  60.     return true;
  61. }
  62.  
  63. public OnPlayerDisconnect(playerid, reason)
  64. {
  65.         new
  66.              stra[256];
  67.         format(stra,sizeof stra,"/mBank/%s.ini",GetName(playerid));
  68.         new
  69.             INI:dat = INI_Open(stra);
  70.         INI_SetTag(dat,"data");
  71.         INI_WriteInt(dat,"Novac",GetPlayerMoney(playerid));
  72.         INI_WriteInt(dat,"Banka",Podatci[playerid][Banka]);
  73.         INI_WriteInt(dat,"PinKod",Podatci[playerid][PinKod]);
  74.         INI_WriteInt(dat,"Racun",Podatci[playerid][Racun]);
  75.         INI_Close(dat);
  76.         return true;
  77. }
  78.  
  79. YCMD:bankkreiraj(playerid,params[],help) {
  80.         #pragma unused help
  81.         #pragma unused params
  82.         if(Podatci[playerid][Racun] == 1) return SCM(playerid,-1,"{FF0000}Već imate račun!");
  83.         else
  84.         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");
  85.         return true; }
  86.        
  87. YCMD:bankdeposit(playerid,params[],help) {
  88.         #pragma unused help
  89.         #pragma unused params
  90.         if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
  91.         ShowPlayerDialog(playerid,BANKDEPOSIT,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
  92.  
  93. YCMD:bankwithdraw(playerid,params[],help) {
  94.         #pragma unused help
  95.         #pragma unused params
  96.         if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
  97.         ShowPlayerDialog(playerid,BANKWITHDRAW,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
  98.        
  99. YCMD:bankbalance(playerid,params[],help) {
  100.         #pragma unused help
  101.         #pragma unused params
  102.         new
  103.               str[128];
  104.         if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
  105.         format(str,sizeof str,"Vaše trenutno stanje na bankovnom računu : $%d !",Podatci[playerid][Banka]);
  106.         ShowPlayerDialog(playerid,BANKBALANCE,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori",""); return true; }
  107.        
  108. YCMD:bankpin(playerid,params[],help) {
  109.         #pragma unused help
  110.         #pragma unused params
  111.         if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
  112.         ShowPlayerDialog(playerid,BANKPIN,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
  113.        
  114. YCMD:bankhelp(playerid,params[],help) {
  115.         #pragma unused help
  116.         #pragma unused params
  117.         new
  118.              strc[470];
  119.         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!");
  120.         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!");
  121.         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!");
  122.         ShowPlayerDialog(playerid,BANKHELP,DIALOG_STYLE_MSGBOX,"{00FF00}Banka Pomoć",strc,"Hvala","");
  123.         return true; }
  124.        
  125. YCMD:bankobrisi(playerid,params[],help) {
  126.         #pragma unused help
  127.         #pragma unused params
  128.         if(Podatci[playerid][Racun] == 0) return SCM(playerid,-1,"{FF0000}Nemate bankovni račun!");
  129.         ShowPlayerDialog(playerid,BANKBRISI,DIALOG_STYLE_INPUT,"{00FF00}Banka","Molimo vas unesite pin kod bankovnog računa!","Unesite","Odustani"); return true; }
  130.        
  131.        
  132. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  133. {
  134.     if(dialogid == KREIRAJ) {
  135.     if(!response) return false;
  136.     new pin = strval(inputtext),
  137.         str[356];
  138.     Podatci[playerid][Racun] = 1;
  139.     Podatci[playerid][PinKod] = pin;
  140.     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);
  141.     ShowPlayerDialog(playerid,ON_KREIRAO,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
  142.     SCM(playerid,-1,"{00FF00}Uspješno ste napravili bankovni račun!");
  143.     SCM(playerid,-1,"{00FFFF}Koristite {00FF00}/bankhelp {00FFFF}da bi ste vidjeli komande za kontroliranje računom!");
  144.     }
  145.     if(dialogid == BANKDEPOSIT) {
  146.     new
  147.           pin = strval(inputtext);
  148.     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");
  149.     else
  150.     ShowPlayerDialog(playerid,BANKDEPOSIT,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani");
  151.     }
  152.     if(dialogid == BANKDEPOSIT2) {
  153.     if(!response) return false;
  154.     new val = strval(inputtext),
  155.          str[256];
  156.     if(val > GetPlayerMoney(playerid)) return SCM(playerid,-1,"{FF0000}Nemate toliko novca u džepu!");
  157.     if(val < 0 || val > 99999999) return SCM(playerid,-1,"{FF0000}Možete depositati novca od $0 do $99999999 !");
  158.     Podatci[playerid][Banka] = Podatci[playerid][Banka] + val;
  159.     GivePlayerMoney(playerid, - val);
  160.     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]);
  161.     ShowPlayerDialog(playerid,ON_DEPOSIT,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
  162.     }
  163.     if(dialogid == BANKWITHDRAW) {
  164.     if(!response) return false;
  165.     new
  166.           pin = strval(inputtext);
  167.     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");
  168.     else
  169.     ShowPlayerDialog(playerid,BANKWITHDRAW,DIALOG_STYLE_INPUT,"{00FF00}Banka","Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani");
  170.     }
  171.     if(dialogid == BANKWITHDRAW2) {
  172.     if(!response) return false;
  173.     new val = strval(inputtext),
  174.         str[256];
  175.     if(val > Podatci[playerid][Banka]) return SCM(playerid,-1,"Nemate toliko novaca u banci!");
  176.     Podatci[playerid][Banka] = Podatci[playerid][Banka] - val;
  177.     GivePlayerMoney(playerid,val);
  178.     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]);
  179.     ShowPlayerDialog(playerid,ON_WITHDRAW,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
  180.     }
  181.     if(dialogid == BANKPIN) {
  182.     if(!response) return false;
  183.     new
  184.           pin = strval(inputtext);
  185.     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");
  186.     else
  187.     ShowPlayerDialog(playerid,BANKPIN,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani");
  188.     }
  189.     if(dialogid == BANKPIN2) {
  190.     if(!response) return false;
  191.     new
  192.          novipin = strval(inputtext),
  193.          str[128];
  194.     Podatci[playerid][PinKod] = novipin;
  195.     format(str,sizeof str,"{FFFFFF}Uspješno ste promjenili pin kod!\n{FFFFFF}Vaš novi pin kod je : {00FF00}%d {FFFFFF}!",novipin);
  196.     ShowPlayerDialog(playerid,ON_PIN,DIALOG_STYLE_MSGBOX,"{00FF00}Banka",str,"Zatvori","");
  197.     }
  198.     if(dialogid == BANKBRISI) {
  199.     if(!response) return false;
  200.     new
  201.           pin = strval(inputtext);
  202.     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");
  203.     else
  204.     ShowPlayerDialog(playerid,BANKWITHDRAW,DIALOG_STYLE_INPUT,"{00FF00}Banka","{FFFFFF}Unijeli ste krivi pin kod! Molimo vas probajte ponovo!","Unesi","Odustani"); }
  205.     if(dialogid == BANKBRISI2) {
  206.     if(response) {
  207.     SCM(playerid,-1,"{00FF00}Obrisali ste bankovni račun!");
  208.     Podatci[playerid][Banka] = 0;
  209.     Podatci[playerid][Racun] = 0;
  210.     Podatci[playerid][PinKod] = 0;
  211.     } else {
  212.     SCM(playerid,-1,"{FFFF00}Odustali ste od brisanja bankovnog računa!"); } }
  213.     return true; }
  214.    
  215.  
  216.    
  217. forward Load_data(playerid,name[],value[]);
  218. public Load_data(playerid,name[],value[]) /* Y_Less */
  219. {
  220.         INI_Int("Novac",Podatci[playerid][Novac]);
  221.         INI_Int("Banka",Podatci[playerid][Banka]);
  222.         INI_Int("PinKod",Podatci[playerid][PinKod]);
  223.         INI_Int("Racun",Podatci[playerid][Racun]);
  224.         return true;
  225. }
  226.  
  227. stock GetName(playerid)
  228. {
  229.    new
  230.         ime[MAX_PLAYER_NAME];
  231.    GetPlayerName(playerid,ime,sizeof ime);
  232.    return ime;
  233. }
  234.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement