Advertisement
WeenSoares_

[FilterScript]Sistema de Private Message(PM) -STRCMP

Jan 4th, 2012
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. /*
  2.  
  3. FilterScript Sistema de Private Message(PM)
  4. Direito autoriais: WeenSoares
  5. Contato: weensoares@live.com
  6.  
  7. */
  8.  
  9. #include <a_samp>
  10. #include <dutils>
  11. new bool:LerPms[MAX_PLAYERS];
  12. new bool:PmBlock[MAX_PLAYERS];
  13. //==============================/*FILTERSCRIPTINIT*/==============================//
  14. public OnFilterScriptInit()
  15. {
  16.  
  17. print("•\n");
  18. print("******************************************************");
  19. print("* [FilterScript] Sistema de Private Message(PM) *\n");
  20. print("* Carregando... *\n\n");
  21. print("* Carregado 100%. *");
  22. print("******************************************************");
  23. print("•\n");
  24. return 1;
  25. }
  26. //==============================/*ONPLAYERCONNECT*/==============================//
  27. public OnPlayerConnect(playerid)
  28. {
  29. LerPms[playerid] = false;
  30. PmBlock[playerid] = false;
  31. return 1;
  32. }
  33. public OnPlayerCommandText(playerid, cmdtext[])
  34. {
  35. new cmd[256];
  36. new string[128];
  37. new tmp[256];
  38. new playername[MAX_PLAYER_NAME];
  39. new giveplayername[MAX_PLAYER_NAME];
  40. new giveplayerid;
  41. new idx;
  42. cmd = strtok(cmdtext, idx);
  43. //==============================/*INICIO DOS COMANDOS*/==============================//
  44. if(strcmp(cmd, "/pm", true) == 0)
  45. {
  46. GetPlayerName(playerid, playername, sizeof(playername));
  47. GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
  48. tmp = strtok(cmdtext, idx);
  49. if(!strlen(tmp))
  50. {
  51. SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /pm [id do player] [menssagem]");
  52. return 1;
  53. }
  54. giveplayerid = strval(tmp);
  55. if(!strlen(tmp))
  56. {
  57. SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /pm [id do player] [menssagem]");
  58. return 1;
  59. }
  60. new length = strlen(cmdtext);
  61. while ((idx < length) && (cmdtext[idx] <= ' '))
  62. {
  63. idx++;
  64. }
  65. new offset = idx;
  66. new menssagem[156];
  67. while ((idx < length) && ((idx - offset) < (sizeof(menssagem) - 1)))
  68. {
  69. menssagem[idx - offset] = cmdtext[idx];
  70. idx++;
  71. }
  72. menssagem[idx - offset] = EOS;
  73. if(IsPlayerConnected(playerid))
  74. {
  75. if(IsPlayerConnected(giveplayerid))
  76. {
  77. GetPlayerName(playerid, playername, sizeof(playername));
  78. GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
  79. if(PmBlock[playerid])
  80. {
  81. format(string,sizeof(string),"[Private Message]: Você não pode enviar uma menssagem pois a sua PM está bloqueada!");
  82. SendClientMessage(playerid, 0xFF80808B, string);
  83. return 1;
  84. }
  85. if(PmBlock[giveplayerid])
  86. {
  87. format(string,sizeof(string),"[Private Message]: Você não pode enviar uma menssagem para %s pois ele está com o PM Bloqueado!", giveplayername);
  88. SendClientMessage(playerid, 0xFF80808B, string);
  89. return 1;
  90. }
  91. if(!strlen(menssagem))
  92. {
  93. SendClientMessage(playerid, 0x33AA33AA, "Uso Correto: /pm [id do player] [menssagem]");
  94. return 1;
  95. }
  96. format(string,sizeof(string),">> Enviada para: %s (%d): %s", giveplayername, giveplayerid, menssagem);
  97. SendClientMessage(playerid,0xFFD500FF,string);
  98. format(string,sizeof(string),"** Recebida de: %s (%d): %s", playername, playerid, menssagem);
  99. GameTextForPlayer(giveplayerid, "~w~MENSAGEM ~r~RECEBIDA", 3000, 1);
  100. SendClientMessage(giveplayerid,0xFF80808B,string);
  101. PlayerPlaySound(giveplayerid, 1085, 0.0, 0.0, 0.0);
  102. printf("[Private Message]: %s envio para %s: %s", playername, giveplayername, menssagem);
  103. for(new i; i < MAX_PLAYERS; i++)
  104. {
  105. if(IsPlayerAdmin(playerid) && LerPms[i] == true)
  106. {
  107. format(string, sizeof(string), "** %s envio para %s: %s", playername, giveplayername, menssagem);
  108. SendClientMessage(i, 0xFF80808B, string);
  109. }
  110. }
  111. }
  112. else
  113. {
  114. format(string, sizeof(string), "* O ID %d não está online.", giveplayerid);
  115. SendClientMessage(playerid, 0x00FFFFAA, string);
  116. }
  117. }
  118. else
  119. {
  120. SendClientMessage(playerid, 0x00FFFFAA, "Você tem que está logado para usar este comando!");
  121. }
  122. return 1;
  123. }
  124. if(strcmp(cmd, "/bpm", true) == 0)
  125. {
  126. if(!PmBlock[playerid])
  127. {
  128. SendClientMessage(playerid, 0xFF80808B, "[Private Message]: Private Message bloqueada!");
  129. PmBlock[playerid] = true;
  130. }
  131. else
  132. {
  133. SendClientMessage(playerid, 0xFF80808B, "[Private Message]: Private Message já bloqueada!");
  134. return 1;
  135. }
  136. return 1;
  137. }
  138. if(strcmp(cmd, "/lpm", true) == 0)
  139. {
  140. if(IsPlayerConnected(playerid))
  141. {
  142. if(PmBlock[playerid])
  143. {
  144. SendClientMessage(playerid, 0xFF80808B, "[Private Message]: Private Message liberada!");
  145. PmBlock[playerid] = false;
  146. }
  147. else
  148. {
  149. SendClientMessage(playerid, 0xFF80808B,"[Private Message]: Private Message já liberada!");
  150. }
  151. }
  152. return 1;
  153. }
  154. if(strcmp(cmd, "/lerpms", true) == 0)
  155. {
  156. if(IsPlayerConnected(playerid))
  157. {
  158. if(IsPlayerAdmin(playerid))
  159. {
  160. if(!LerPms[playerid])
  161. {
  162. SendClientMessage(playerid, 0xFF80808B, "AdmCMD: Você está lendo as [Private Message].");
  163. LerPms[playerid] = true;
  164. }
  165. else
  166. {
  167. SendClientMessage(playerid, 0xFF80808B, "AdmCMD: Você parou de ler as [Private Message].");
  168. LerPms[playerid] = false;
  169. return 1;
  170. }
  171. }
  172. else
  173. {
  174. SendClientMessage(playerid, 0x00FFFFAA, "Você não tem permissão para usar este comando!");
  175. }
  176. }
  177. else
  178. {
  179. SendClientMessage(playerid, 0x00FFFFAA, "Você tem que está logado para usar este comando!");
  180. }
  181. return 1;
  182. }
  183. return false;
  184. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement