Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <zcmd>
  4.  
  5. #define MSGFAIL_COLOR 0xFF3233FF //RED
  6. #define MSGCMDS_COLOR 0xFFFFFFFF
  7. #define MSGSUCC_COLOR 0x00FF00FF//GREEN
  8. #define MSGINFO_COLOR 0x3C93FFFF//TYRKYS
  9.  
  10. #define DIALOG_MINCA 1
  11. #define DIALOG_KOCKATOP 2
  12.  
  13. new betminca;
  14.  
  15. CMD:kocka(playerid, params[]){ //FUNGUJE
  16. new string[128];
  17. new bet;
  18. new number;//0-5,Musím nejako pridať +1
  19. if (sscanf(params, "ii",number,bet)){
  20. SendClientMessage(playerid,MSGCMDS_COLOR, "Použitie: \"/kocka <tvoje číslo> <suma stávky>\"");
  21. }else{
  22. if(number > 6 || number < 1){
  23. SendClientMessage(playerid,MSGFAIL_COLOR, "Neplatné číslo!(1-6).");
  24. }else if (bet<1){
  25. SendClientMessage(playerid,MSGFAIL_COLOR, "Nezadal si čiastku.");
  26. }else if (bet>1000000){
  27. SendClientMessage(playerid,MSGFAIL_COLOR, "Nemôžeš staviť viac ako 1 000 000 bez VIP!");
  28. }else{
  29. if (Money(playerid)<bet){
  30. format(string,sizeof(string),"Nemáš peniaze!.Stav: $%i",Money(playerid));
  31. SendClientMessage(playerid,MSGFAIL_COLOR,string);
  32. }else{
  33. new randomnumber = random(6)+1;
  34. if (randomnumber==number){
  35. string[0] = EOS;
  36. format(string,sizeof(string),"Vylosované číslo je %d",randomnumber);
  37. SendClientMessage(playerid,MSGSUCC_COLOR,string);
  38. format(string,sizeof(string),"Vyhral si $%d!",bet*6);
  39. SendClientMessage(playerid,MSGSUCC_COLOR,string);
  40. GivePlayerMoneyEx(playerid,bet*6);
  41. }else{
  42. string[0] = EOS;
  43. format(string,sizeof(string),"Vylosované číslo je %d",randomnumber);
  44. SendClientMessage(playerid,MSGFAIL_COLOR,string);
  45. format(string,sizeof(string),"Prehral si %d...",bet);
  46. SendClientMessage(playerid,MSGFAIL_COLOR,string);
  47. GivePlayerMoneyEx(playerid,-bet);
  48. }
  49. }
  50. }
  51. }
  52. if (bet >10000){
  53. new stringkockatop[MAX_PLAYER_NAME + 7];
  54. format(stringkockatop,sizeof(stringkockatop),"%s\r\n",Name(playerid));
  55. new File:kockatop = fopen("kockatop.txt", io_append);
  56. if (kockatop){
  57. fwrite(kockatop, stringkockatop);
  58. fclose(kockatop);
  59. }
  60. }
  61. return 1;
  62. }
  63. CMD:minca(playerid, params[]){
  64. if (sscanf(params, "i",betminca)){
  65. SendClientMessage(playerid,MSGCMDS_COLOR, "Použitie: \"/minca <suma stávky>\"");
  66. }else{
  67. ShowPlayerDialog(playerid,DIALOG_MINCA,DIALOG_STYLE_MSGBOX,"Minca", "Orol alebo Panna?","Orol","Panna");
  68. }
  69. return 1;
  70. }
  71. CMD:kockatop(playerid,params[]){
  72. if(fexist("kockatop.txt")){
  73. new File:kockatop = fopen("kockatop.txt", io_read);
  74. new str[256], str2[3000];
  75. while(fread(kockatop, str, sizeof(str))){
  76. strcat(str2, str);
  77. }
  78. ShowPlayerDialog(playerid,DIALOG_KOCKATOP,DIALOG_STYLE_MSGBOX,"Hráči ktorí vložili nad 10000",str2,"Zrušiť","");
  79. fclose(kockatop);
  80. }
  81. return 1;
  82. }
  83. public OnPlayerConnect(playerid){
  84. GivePlayerMoney(playerid, 50000);
  85. }
  86. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  87. new string[18];
  88. new randomnumber = random(2)+1;
  89. switch(dialogid){
  90. case DIALOG_MINCA:{
  91. switch(response){
  92. case 0:{ //panna dialog click
  93. if (randomnumber==1){
  94. SendClientMessage(playerid,MSGSUCC_COLOR,"Padla panna!");
  95. //SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")+bet*2);
  96. GivePlayerMoney(playerid,betminca*2);
  97. string[0] = EOS;
  98. format(string,sizeof(string),"Vyhral si %d...",betminca*2);
  99. SendClientMessage(playerid,MSGSUCC_COLOR,string);
  100. }else{
  101. SendClientMessage(playerid,MSGFAIL_COLOR,"Padol orol!");
  102. //SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")-bet);
  103. GivePlayerMoney(playerid,-betminca);
  104. string[0] = EOS;
  105. format(string,sizeof(string),"Prehral si %d...",betminca);
  106. SendClientMessage(playerid,MSGFAIL_COLOR,string);
  107. }
  108. }case 1:{// Orol dialog click
  109. if (randomnumber==2){
  110. SendClientMessage(playerid,MSGSUCC_COLOR,"Padol orol!");
  111. //SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")+bet*2);
  112. GivePlayerMoney(playerid,betminca*2);
  113. string[0] = EOS;
  114. format(string,sizeof(string),"Vyhral si %d...",betminca*2);
  115. SendClientMessage(playerid,MSGSUCC_COLOR,string);
  116. }else{
  117. SendClientMessage(playerid,MSGFAIL_COLOR,"Padla panna!");
  118. //SetPVarInt(playerid,"Money",GetPVarInt(playerid,"Money")-bet);
  119. GivePlayerMoney(playerid,-betminca);
  120. string[0] = EOS;
  121. format(string,sizeof(string),"Prehral si %d...",betminca);
  122. SendClientMessage(playerid,MSGFAIL_COLOR,string);
  123. }//ELSE
  124. }//CASE 1
  125. }//switch response
  126. }//dialog minca
  127. case DIALOG_KOCKATOP:{
  128. }
  129. }//SWITCH UKONčENý
  130. return 1;
  131. }
  132. stock Name(playerid){
  133. new nname[MAX_PLAYER_NAME];
  134. GetPlayerName(playerid, nname, sizeof(nname));
  135. return nname;
  136. }
  137. stock Money(playerid){//moc mi to prácu neulahčilo? lepšie #define
  138. return GetPlayerMoney(playerid);
  139. }
  140. stock GivePlayerMoneyEx(playerid, money){
  141. new pMoney = GetPVarInt(playerid, "Money"); // Zistenie, koľko má hráč uložené v PVare
  142. SetPVarInt(playerid, "Money", pMoney + money); // Nové uloženie do PVaru -> hodnota v starom PVare navýšená o peniaze, ktoré si hráčovi dal (parameter money)
  143. GivePlayerMoney(playerid, money); // Dáš hráčovi peniaze
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement