Advertisement
Guest User

Sistema de Gold [STRCMP]

a guest
Aug 19th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Dini>
  3.  
  4. //NEWS
  5. new Text:Textdraw1[MAX_PLAYERS];
  6. new Text:Textdraw0[MAX_PLAYERS];
  7. new Gold[MAX_PLAYERS];
  8. new tGold[MAX_PLAYERS];
  9. //DEFINES
  10. #define Cor 0xFF00EBFF
  11.  
  12. public OnPlayerSpawn(playerid)
  13. {
  14. SetTimerEx("Timer",60000,true,"i",playerid); //TROQUE O '10000' PELO TEMPO QUE ELE GANHA [0/3], NO CASO AQUI É 1 MINUTO, NA TEXTDRAWN TEM 0/3, E QUANDO CHEGAR A 3 MINUTOS GANHA 1 GOLD
  15. SetTimer("ActualizarTextDraws",true,60000);
  16. ///////////////////////// Gold ////////////////////////////////////////////////
  17. Textdraw0[playerid] = TextDrawCreate(551.000000, 291.000000, "Gold: 0");
  18. TextDrawBackgroundColor(Textdraw0[playerid], 255);
  19. TextDrawFont(Textdraw0[playerid], 3);
  20. TextDrawLetterSize(Textdraw0[playerid], 0.500000, 1.000000);
  21. TextDrawColor(Textdraw0[playerid], 65535);
  22. TextDrawSetOutline(Textdraw0[playerid], 0);
  23. TextDrawSetProportional(Textdraw0[playerid], 1);
  24. TextDrawSetShadow(Textdraw0[playerid], 1);
  25. //////////////////////////tGold//////////////////////////////////////////////
  26. Textdraw1[playerid] = TextDrawCreate(551.000000, 268.000000, "0/3");
  27. TextDrawBackgroundColor(Textdraw1[playerid], 255);
  28. TextDrawFont(Textdraw1[playerid], 1);
  29. TextDrawLetterSize(Textdraw1[playerid], 0.280000, 2.100000);
  30. TextDrawColor(Textdraw1[playerid], -16776961);
  31. TextDrawSetOutline(Textdraw1[playerid], 0);
  32. TextDrawSetProportional(Textdraw1[playerid], 1);
  33. TextDrawSetShadow(Textdraw1[playerid], 1);
  34. return 1;
  35. }
  36. forward ActualizarTextDraws();
  37. public ActualizarTextDraws()
  38. {
  39. new String[100];
  40.  
  41. for(new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
  42. {
  43. if(IsPlayerConnected(playerid))
  44. {
  45. format(String, sizeof(String), "Gold: %d", Gold[playerid]);
  46. TextDrawSetString(Textdraw0[playerid], String);
  47. TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
  48. format(String, sizeof(String), " %d / 3", tGold[playerid]);
  49. TextDrawSetString(Textdraw1[playerid], String);
  50. TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
  51. }
  52. }
  53. }
  54. forward Timer(playerid);
  55. public Timer(playerid)
  56. {
  57. tGold[playerid]++;
  58. if(tGold[playerid] == 3)
  59. {
  60. Gold[playerid]++;
  61. SendClientMessage(playerid,Cor,"{FF3D3D}[INFO]{FFFFFF} Parabéns, você ganhou 1 Gold!");
  62. tGold[playerid] = 0;
  63. }
  64. return 1;
  65. }
  66. public OnPlayerConnect(playerid)
  67. {
  68. if(dini_Isset("Golds.dkn",PlayerName(playerid))) Gold[playerid] = (playerid,dini_Int("Golds.dkn",PlayerName(playerid)));
  69. return 1;
  70. }
  71. public OnPlayerDisconnect(playerid, reason)
  72. {
  73. dini_IntSet("Golds.dkn",PlayerName(playerid),Gold[playerid]);
  74. return 1;
  75. }
  76. public OnGameModeInit()
  77. {
  78. if(!fexist("Golds.dkn")) dini_Create("Golds.dkn");
  79. return 1;
  80. }
  81. stock PlayerName(playerid)
  82. {
  83. new PlayerNameGold[MAX_PLAYERS];
  84. GetPlayerName(playerid, PlayerNameGold, MAX_PLAYERS);
  85. return PlayerNameGold;
  86. }
  87.  
  88. public OnPlayerCommandText(playerid, cmdtext[])
  89. {
  90.  
  91. if (strcmp("/premio", cmdtext, true) == 0) //DIALOG PREMIOS
  92. {
  93. ShowPlayerDialog(playerid, 2014, DIALOG_STYLE_LIST, "GOLD - Premio", "{7CFC00}R${F8F8FF}1.000.000,00{FFFF00} [1000 Gold's]", "Selecionar", "Fechar");
  94. return 1;
  95. }
  96.  
  97. return 1;
  98. }
  99.  
  100. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  101. {
  102.  
  103. if(dialogid == 2014)
  104. {
  105. if(response)
  106. {
  107. if(listitem == 0)
  108. {
  109. if(Gold[playerid] > 1000)
  110. {
  111. //COLOQUE AQUI OQUE ELE VAI GANHAR SE SELECINAR O ITEM, EXEMPLO:
  112. GivePlayerMoney(playerid, 1000000);
  113. Gold[playerid] = 0; //VAI ZERAR O GOLD
  114. }
  115. else
  116. {
  117. SendClientMessage(playerid, Cor, "{FF3D3D}[ERRO]{FFFFFF} Você não tem 1000 de Gold."); //MENSAGEM SE O PLAYER NÃO TIVER 1000 DE GOLD
  118. }
  119. }
  120. }
  121. return 1;
  122. }
  123.  
  124. return 1;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement