Advertisement
Guest User

Ban Hammer - Jelly23

a guest
Feb 10th, 2017
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. /*
  2. Ban Hammer
  3. Made by Jelly23
  4. */
  5.  
  6. #define FILTERSCRIPT
  7.  
  8. #define ADMINS_ONLY (true) //Change it to false if you want anyone to use it
  9. #define SAVE_LOGS (true) //Change it to false if you dont want to save logs
  10.  
  11. /*Includes*/
  12. #include <a_samp>
  13. #include <izcmd>
  14.  
  15. /*Variables*/
  16. #if SAVE_LOGS true //if SAVE_LOGS is true, the other variables used for the logs will be created aswell.
  17. static bool:HasHammer[MAX_PLAYERS], //If the player has a hammer or not
  18. PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME], //Player name array
  19. Year, //Year variable
  20. Month, //Month
  21. Day, //Day
  22. Hour, //Hour
  23. Minutes, //Minutes
  24. Seconds; //Seconds
  25. #else //if SAVE_LOGS is false, variables related to logs won't be created and PlayerName will be the last one.
  26. static bool:HasHammer[MAX_PLAYERS], //If the player has a hammer or not
  27. PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME]; //Player name array
  28. #endif
  29.  
  30. #if defined FILTERSCRIPT
  31.  
  32. public OnFilterScriptInit()
  33. {
  34. print("\n--------------------------------------");
  35. print(" Ban Hammer");
  36. print("--------------------------------------\n");
  37. return 1;
  38. }
  39.  
  40. #endif
  41.  
  42. /*Callbacks*/
  43. public OnPlayerConnect(playerid)
  44. {
  45. HasHammer[playerid] = false; //We reset it when you join, which means you got no hammer.
  46. GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME); //We get the player's name and store it in PlayerName array.
  47. return 1;
  48. }
  49.  
  50. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
  51. {
  52. if(HasHammer[playerid] == true && weaponid == 5) //Here we check if the player has a hammer and if the weapon in hands is a baseball bat.
  53. {
  54. new banmessage[50+MAX_PLAYER_NAME*2]; //Our string
  55. format(banmessage,sizeof(banmessage),"{FF0000}Ban: %s has banned %s",PlayerName[playerid],PlayerName[damagedid]); //We format it with the player and victim's name.
  56. SendClientMessageToAll(-1,banmessage); //We send the message to everyone.
  57. #if SAVE_LOGS true //If SAVE_LOGS is true, means it will save ban logs
  58. new File:Ban_File, Ban_Log[41+MAX_PLAYER_NAME*2]; //Ban_File is the file, Ban_Log the string.
  59. if(fexist("Ban_Hammer.txt")) Ban_File = fopen("Ban_Hammer.txt", io_append); //We check if it exists, if yes we open it.
  60. else Ban_File = fopen("Ban_Hammer.txt", io_write); //Otherwise we create it.
  61. getdate(Year, Month, Day); //We get the date.
  62. gettime(Hour, Minutes, Seconds); //We get the time.
  63. format(Ban_Log, sizeof(Ban_Log), "[%04d/%02d/%02d - %02d:%02d:%02d] %s has banned %s\r\n", Year, Month, Day, Hour, Minutes, Seconds, PlayerName[playerid],PlayerName[damagedid]); //We format the string
  64. fwrite(Ban_File, Ban_Log); //We write it in the file
  65. fclose(Ban_File); //We close the file
  66. #endif
  67. BanEx(damagedid,"Ban Hammer"); //We ban the victim.
  68. }
  69. return 1;
  70. }
  71.  
  72. /*Command*/
  73. CMD:hammer(playerid)
  74. {
  75. #if ADMINS_ONLY true //If ADMINS_ONLY is true, means only RCON admins will be able to use this command, otherwise anyone.
  76. if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}Error: Only rcon admins can use this command."); //If the player isn't an admin, they won't be able to use it. - Exception if ADMINS_ONLY is false.
  77. #endif
  78. new hammermessage[49+MAX_PLAYER_NAME];
  79. if(HasHammer[playerid] == false) //If HasHammer is false, which means the player has no hammer, what is below and under the brackets will happen.
  80. {
  81. HasHammer[playerid] = true; //We change it to true, letting it know the player has a hammer.
  82. SetPlayerAttachedObject(playerid, 1, 18635, 6, -0.211000, -0.093999, 0.000000, 4.699998, 8.100019, -0.500001, 3.759002, 4.369003, 2.290000); //We attach the hammer object in the player's right hand.
  83. GivePlayerWeapon(playerid,5,1); //We give the player a baseball bat.
  84. format(hammermessage,sizeof(hammermessage),"{FF0000}Hammer: %s has given himself a ban hammer.",PlayerName[playerid]);
  85. SendClientMessageToAll(-1,hammermessage);
  86. }
  87. else //Otherwise, what is below and under the brackets will happen.
  88. {
  89. HasHammer[playerid] = false; //We change it to false, letting it know the hammer was removed.
  90. RemovePlayerAttachedObject(playerid, 1); //We remove the hammer attachment.
  91. format(hammermessage,sizeof(hammermessage),"{FF0000}Hammer: %s's ban hammer is gone/taken out.",PlayerName[playerid]);
  92. SendClientMessageToAll(-1,hammermessage);
  93. }
  94. return 1;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement