Guest User

FS Sistema VIP - Homehots

a guest
Sep 10th, 2014
724
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Include's */
  2. #include <a_samp>
  3. #include <zcmd>
  4. #include <sscanf>
  5. #include <DOF2>
  6.  
  7. /* New's */
  8. new PlayerVip[MAX_PLAYERS];
  9.  
  10. /* Public's */
  11. main(){}
  12. public OnFilterScriptInit() return 1;
  13. public OnFilterScriptExit() { DOF2_Exit(); return 1; }
  14.  
  15. public OnPlayerConnect(playerid)
  16. {
  17. new string[80];
  18. format(string, sizeof(string), "/vips/%s.ini", GetName(playerid));
  19. if(DOF2_FileExists(string))
  20. {
  21. PlayerVip[playerid] = DOF2_GetInt(string,"VipExpira");
  22. if(gettime() > PlayerVip[playerid])
  23. {
  24. DOF2_RemoveFile(string);
  25. PlayerVip[playerid] = 0;
  26. SendClientMessage(playerid, 0xF6FF00AA, "* Seu vip expirou!");
  27. }
  28. else
  29. {
  30. format(string, sizeof(string), "* Seu vip expira em %s.", convertNumber(PlayerVip[playerid]-gettime()));
  31. SendClientMessage(playerid, 0xF6FF00AA, string);
  32. }
  33. }
  34. return 1;
  35. }
  36.  
  37. public OnPlayerSpawn(playerid)
  38. {
  39. if(PlayerVip[playerid] > 0)
  40. {
  41. if(gettime() > PlayerVip[playerid])
  42. {
  43. new string[40];
  44. format(string, sizeof(string), "/vips/%s.ini", GetName(playerid));
  45. DOF2_RemoveFile(string);
  46. PlayerVip[playerid] = 0;
  47. SendClientMessage(playerid, 0xF6FF00AA, "* Seu vip expirou!");
  48. }
  49. else
  50. {
  51. SetPlayerArmour(playerid, 100);
  52. SetPlayerHealth(playerid, 100);
  53. }
  54. }
  55. return 1;
  56. }
  57.  
  58. /* Stock's */
  59. stock ConvertDays(dias)
  60. {
  61.  
  62. new
  63. valueday = 86400*dias,
  64. daysconvert,
  65. gtime = gettime()
  66. ;
  67.  
  68. #emit LOAD.S.PRI gtime
  69. #emit LOAD.S.ALT valueday
  70. #emit ADD
  71. #emit STOR.S.PRI daysconvert
  72.  
  73. return daysconvert;
  74. }
  75.  
  76. stock convertNumber(n)
  77. {
  78. new dia, hr, mn, seg, resto;
  79.  
  80. resto = n;
  81. seg = resto % 60;
  82. resto /= 60;
  83. mn = resto % 60;
  84. resto /= 60;
  85. hr = resto % 24;
  86. resto /= 24;
  87. dia = resto;
  88.  
  89. new str[50];
  90. format(str, sizeof(str), "%ddias, %02dh %02dm %02ds", dia, hr, mn, seg);
  91. return str;
  92. }
  93.  
  94. stock GetName(playerid)
  95. {
  96. new name[24];
  97. GetPlayerName(playerid, name, sizeof(name));
  98. return name;
  99. }
  100. /* Command's */
  101.  
  102. CMD:vips(playerid)
  103. {
  104. new string[85];
  105. new count;
  106. SendClientMessage(playerid, 0x33AAFFFF, "** Todos os jogadores VIP online:");
  107. for(new i = 0; i < MAX_PLAYERS; i++)
  108. {
  109. if(PlayerVip[i] > 0)
  110. {
  111. if(IsPlayerConnected(i))
  112. {
  113. format(string, sizeof(string), "Vip %s (%d) [%s]", GetName(i), i, convertNumber(PlayerVip[i]-gettime()));
  114. SendClientMessage(playerid, 0xE3E3E3FF, string);
  115. count++;
  116. }
  117. }
  118. }
  119. if(count == 0)
  120. return SendClientMessage(playerid, 0xD8D8D8FF, "Não tem nenhum jogador vip on-line!");
  121.  
  122. return true;
  123. }
  124.  
  125. CMD:setvip(playerid, params[])
  126. {
  127. new id, days, string[70];
  128.  
  129. if(!IsPlayerAdmin(playerid))
  130. return SendClientMessage(playerid, 0xFF0000AA, "ERRO: Você precisa estar logado na RCON para usar este comando!");
  131.  
  132. if(sscanf(params, "ud", id, days))
  133. return SendClientMessage(playerid, -1, "Modo de uso: /setvip [id] [dias]");
  134.  
  135. if(days < 0)
  136. {
  137. return SendClientMessage(playerid, 0xFF0000AA, "ERRO: Este jogador não está online!");
  138. }
  139. else
  140. {
  141. if(!IsPlayerConnected(id))
  142. return SendClientMessage(playerid, 0xFF0000AA, "ERRO: Este jogador não está online!");
  143. else
  144. {
  145. PlayerVip[id] = ConvertDays(days);
  146. format(string, sizeof(string), "** Você deu %d dias de VIP para %s.", days, GetName(id));
  147. SendClientMessage(playerid, 0x33AAFFFF, string);
  148. format(string, sizeof(string), "** Você recebeu %d dias de VIP.", days);
  149. SendClientMessage(playerid, 0x33AAFFFF, string);
  150.  
  151. format(string, sizeof(string), "/vips/%s.ini", GetName(id));
  152. DOF2_CreateFile(string);
  153. DOF2_SetInt(string,"VipExpira", PlayerVip[id]);
  154. DOF2_SaveFile();
  155. }
  156. }
  157. return true;
  158. }
RAW Paste Data