WeenSoares_

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

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