SAMP Gitlab CI Test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.9 KiB

  1. //
  2. // Base FS
  3. // Contains /pm /kick /ban commands.
  4. //
  5. #include <a_samp>
  6. #include "../include/gl_common.inc"
  7. #define ADMINFS_MESSAGE_COLOR 0xFF444499
  8. #define PM_INCOMING_COLOR 0xFFFF22AA
  9. #define PM_OUTGOING_COLOR 0xFFCC2299
  10. //------------------------------------------------
  11. public OnFilterScriptInit()
  12. {
  13. print("\n--Base FS loaded.\n");
  14. return 1;
  15. }
  16. //------------------------------------------------
  17. public OnPlayerCommandText(playerid, cmdtext[])
  18. {
  19. new cmd[256];
  20. new tmp[256];
  21. new Message[256];
  22. new gMessage[256];
  23. new pName[MAX_PLAYER_NAME+1];
  24. new iName[MAX_PLAYER_NAME+1];
  25. new idx;
  26. cmd = strtok(cmdtext, idx);
  27. // PM Command
  28. if(strcmp("/pm", cmd, true) == 0)
  29. {
  30. tmp = strtok(cmdtext,idx);
  31. if(!strlen(tmp) || strlen(tmp) > 5) {
  32. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
  33. return 1;
  34. }
  35. new id = strval(tmp);
  36. gMessage = strrest(cmdtext,idx);
  37. if(!strlen(gMessage)) {
  38. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
  39. return 1;
  40. }
  41. if(!IsPlayerConnected(id)) {
  42. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
  43. return 1;
  44. }
  45. if(playerid != id) {
  46. GetPlayerName(id,iName,sizeof(iName));
  47. GetPlayerName(playerid,pName,sizeof(pName));
  48. format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
  49. SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
  50. format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage);
  51. SendClientMessage(id,PM_INCOMING_COLOR,Message);
  52. PlayerPlaySound(id,1085,0.0,0.0,0.0);
  53. printf("PM: %s",Message);
  54. }
  55. else {
  56. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
  57. }
  58. return 1;
  59. }
  60. //Kick Command
  61. if(strcmp("/kick", cmd, true) == 0)
  62. {
  63. if(IsPlayerAdmin(playerid)) {
  64. tmp = strtok(cmdtext,idx);
  65. if(!strlen(tmp) || strlen(tmp) > 5) {
  66. return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /kick (id) [reason]");
  67. }
  68. new id = strval(tmp);
  69. if(!IsPlayerConnected(id)) {
  70. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/kick : Bad player ID");
  71. return 1;
  72. }
  73. gMessage = strrest(cmdtext,idx);
  74. GetPlayerName(id,iName,sizeof(iName));
  75. SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been kicked from the server.");
  76. if(strlen(gMessage) > 0) {
  77. format(Message,sizeof(Message),"Reason: %s",gMessage);
  78. SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
  79. }
  80. format(Message,sizeof(Message),">> %s(%d) has been kicked.",iName,id);
  81. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);
  82. Kick(id);
  83. return 1;
  84. } else {
  85. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/kick : You are not an admin");
  86. return 1;
  87. }
  88. }
  89. //Ban Command
  90. if(strcmp("/ban", cmd, true) == 0)
  91. {
  92. if(IsPlayerAdmin(playerid)) {
  93. tmp = strtok(cmdtext,idx);
  94. if(!strlen(tmp) || strlen(tmp) > 5) {
  95. return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /ban (id) [reason]");
  96. }
  97. new id = strval(tmp);
  98. if(!IsPlayerConnected(id)) {
  99. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : Bad player ID");
  100. return 1;
  101. }
  102. gMessage = strrest(cmdtext,idx);
  103. GetPlayerName(id,iName,sizeof(iName));
  104. SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been banned from the server.");
  105. if(strlen(gMessage) > 0) {
  106. format(Message,sizeof(Message),"Reason: %s",gMessage);
  107. SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
  108. }
  109. format(Message,sizeof(Message),">> %s(%d) has been banned.",iName,id);
  110. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);
  111. Ban(id);
  112. return 1;
  113. } else {
  114. SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : You are not an admin");
  115. return 1;
  116. }
  117. }
  118. return 0;
  119. }