Advertisement
Guest User

[FS]Sistema de Pontos

a guest
Feb 13th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. /*******************************************************************************
  2. ********************************************************************************
  3. ************************** Feito por Josma_CMD ******************************
  4. ********************************************************************************
  5. ********************************************************************************
  6. */
  7. #include <a_samp>
  8. #include <SII>
  9.  
  10. const Branco = 0xFFFFFFFF;
  11.  
  12. enum PInfo { Matou, Morreu, Pontos, Text:TPontos, bool:Connectado, };
  13.  
  14. new ProgressaoInfo[MAX_PLAYERS][PInfo];
  15. new arquivo[50];
  16.  
  17. forward SalvarInformacoes(playerid);
  18. forward CarregarInformacoes(playerid);
  19.  
  20. public OnFilterScriptInit()
  21. {
  22. print("\n--------------------------------------");
  23. print(" Sistema de Pontos feito por Josma_CMD");
  24. print("--------------------------------------\n");
  25. return true;
  26. }
  27.  
  28. public OnFilterScriptExit()
  29. {
  30. for(new i = 0, PP = GetMaxPlayers(); i <= PP; i++)
  31. {
  32. if(!IsPlayerConnected(i)) continue;
  33. TextDrawDestroy(ProgressaoInfo[i][TPontos]);
  34. }
  35. return true;
  36. }
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40. CarregarInformacoes(playerid);
  41. //********************************* Pontos *********************************
  42. ProgressaoInfo[playerid][TPontos] = TextDrawCreate(496.000000, 105.000000, "~l~Pontos: ~b~953");
  43. TextDrawBackgroundColor(ProgressaoInfo[playerid][TPontos], 16777215);
  44. TextDrawFont(ProgressaoInfo[playerid][TPontos], 2);
  45. TextDrawLetterSize(ProgressaoInfo[playerid][TPontos], 0.420000, 1.400000);
  46. TextDrawColor(ProgressaoInfo[playerid][TPontos], -1);
  47. TextDrawSetOutline(ProgressaoInfo[playerid][TPontos], 1);
  48. TextDrawSetProportional(ProgressaoInfo[playerid][TPontos], 1);
  49. return true;
  50. }
  51.  
  52. public OnPlayerDisconnect(playerid, reason)
  53. {
  54. SalvarInformacoes(playerid);
  55. TextDrawDestroy(ProgressaoInfo[playerid][TPontos]);
  56. return true;
  57. }
  58.  
  59. public OnPlayerSpawn(playerid)
  60. {
  61. if(ProgressaoInfo[playerid][Connectado] == false)
  62. {
  63. new string[20];
  64. ProgressaoInfo[playerid][Pontos] = (ProgressaoInfo[playerid][Matou] - ProgressaoInfo[playerid][Morreu]);
  65. format(string, sizeof(string), "~l~Pontos: ~b~%d", ProgressaoInfo[playerid][Pontos]);
  66. TextDrawSetString(ProgressaoInfo[playerid][TPontos], string);
  67. TextDrawShowForPlayer(playerid, ProgressaoInfo[playerid][TPontos]);
  68. }
  69. return true;
  70. }
  71.  
  72. public OnPlayerDeath(playerid, killerid, reason)
  73. {
  74. new Texto[30], Texto1[30];
  75. ProgressaoInfo[killerid][Matou] ++;
  76. ProgressaoInfo[playerid][Morreu] ++;
  77. ProgressaoInfo[killerid][Pontos] = (ProgressaoInfo[killerid][Matou] - ProgressaoInfo[killerid][Morreu]);
  78. ProgressaoInfo[playerid][Pontos] = (ProgressaoInfo[playerid][Matou] - ProgressaoInfo[playerid][Morreu]);
  79. format(Texto, sizeof(Texto), "~l~Pontos: ~b~%d", ProgressaoInfo[killerid][Pontos]);
  80. TextDrawSetString(ProgressaoInfo[killerid][TPontos], Texto);
  81. TextDrawShowForPlayer(killerid, ProgressaoInfo[killerid][TPontos]);
  82. format(Texto1, sizeof(Texto1), "~l~Pontos: ~b~%d", ProgressaoInfo[playerid][Pontos]);
  83. TextDrawSetString(ProgressaoInfo[playerid][TPontos], Texto1);
  84. TextDrawShowForPlayer(playerid, ProgressaoInfo[playerid][TPontos]);
  85. SetPlayerScore(playerid, ProgressaoInfo[playerid][Pontos]);
  86. SetPlayerScore(killerid, ProgressaoInfo[killerid][Pontos]);
  87. return true;
  88. }
  89.  
  90. public SalvarInformacoes(playerid)
  91. {
  92. format(arquivo, sizeof(arquivo), "/PontosInfo/%s.ini",pNome(playerid));
  93. INI_Open(arquivo);
  94. INI_WriteInt("Matou", ProgressaoInfo[playerid][Matou]);
  95. INI_WriteInt("Morreu", ProgressaoInfo[playerid][Morreu]);
  96. INI_Save();
  97. INI_Close();
  98. return true;
  99. }
  100.  
  101. public CarregarInformacoes(playerid)
  102. {
  103. format(arquivo, sizeof(arquivo), "/PontosInfo/%s.ini",pNome(playerid));
  104. if(fexist(arquivo))
  105. {
  106. INI_Open(arquivo);
  107. ProgressaoInfo[playerid][Matou] = INI_ReadInt("Matou");
  108. ProgressaoInfo[playerid][Morreu] = INI_ReadInt("Morreu");
  109. INI_Close();
  110. }
  111. else SalvarInformacoes(playerid);
  112. return true;
  113. }
  114.  
  115. stock pNome(playerid)
  116. {
  117. new nome[MAX_PLAYER_NAME];
  118. GetPlayerName(playerid, nome, sizeof(nome));
  119. return nome;
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement