Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Ban Hammer
- Made by Jelly23
- */
- #define FILTERSCRIPT
- #define ADMINS_ONLY (true) //Change it to false if you want anyone to use it
- #define SAVE_LOGS (true) //Change it to false if you dont want to save logs
- /*Includes*/
- #include <a_samp>
- #include <izcmd>
- /*Variables*/
- #if SAVE_LOGS true //if SAVE_LOGS is true, the other variables used for the logs will be created aswell.
- static bool:HasHammer[MAX_PLAYERS], //If the player has a hammer or not
- PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME], //Player name array
- Year, //Year variable
- Month, //Month
- Day, //Day
- Hour, //Hour
- Minutes, //Minutes
- Seconds; //Seconds
- #else //if SAVE_LOGS is false, variables related to logs won't be created and PlayerName will be the last one.
- static bool:HasHammer[MAX_PLAYERS], //If the player has a hammer or not
- PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME]; //Player name array
- #endif
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Ban Hammer");
- print("--------------------------------------\n");
- return 1;
- }
- #endif
- /*Callbacks*/
- public OnPlayerConnect(playerid)
- {
- HasHammer[playerid] = false; //We reset it when you join, which means you got no hammer.
- GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME); //We get the player's name and store it in PlayerName array.
- return 1;
- }
- public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
- {
- 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.
- {
- new banmessage[50+MAX_PLAYER_NAME*2]; //Our string
- format(banmessage,sizeof(banmessage),"{FF0000}Ban: %s has banned %s",PlayerName[playerid],PlayerName[damagedid]); //We format it with the player and victim's name.
- SendClientMessageToAll(-1,banmessage); //We send the message to everyone.
- #if SAVE_LOGS true //If SAVE_LOGS is true, means it will save ban logs
- new File:Ban_File, Ban_Log[41+MAX_PLAYER_NAME*2]; //Ban_File is the file, Ban_Log the string.
- if(fexist("Ban_Hammer.txt")) Ban_File = fopen("Ban_Hammer.txt", io_append); //We check if it exists, if yes we open it.
- else Ban_File = fopen("Ban_Hammer.txt", io_write); //Otherwise we create it.
- getdate(Year, Month, Day); //We get the date.
- gettime(Hour, Minutes, Seconds); //We get the time.
- 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
- fwrite(Ban_File, Ban_Log); //We write it in the file
- fclose(Ban_File); //We close the file
- #endif
- BanEx(damagedid,"Ban Hammer"); //We ban the victim.
- }
- return 1;
- }
- /*Command*/
- CMD:hammer(playerid)
- {
- #if ADMINS_ONLY true //If ADMINS_ONLY is true, means only RCON admins will be able to use this command, otherwise anyone.
- 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.
- #endif
- new hammermessage[49+MAX_PLAYER_NAME];
- if(HasHammer[playerid] == false) //If HasHammer is false, which means the player has no hammer, what is below and under the brackets will happen.
- {
- HasHammer[playerid] = true; //We change it to true, letting it know the player has a hammer.
- 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.
- GivePlayerWeapon(playerid,5,1); //We give the player a baseball bat.
- format(hammermessage,sizeof(hammermessage),"{FF0000}Hammer: %s has given himself a ban hammer.",PlayerName[playerid]);
- SendClientMessageToAll(-1,hammermessage);
- }
- else //Otherwise, what is below and under the brackets will happen.
- {
- HasHammer[playerid] = false; //We change it to false, letting it know the hammer was removed.
- RemovePlayerAttachedObject(playerid, 1); //We remove the hammer attachment.
- format(hammermessage,sizeof(hammermessage),"{FF0000}Hammer: %s's ban hammer is gone/taken out.",PlayerName[playerid]);
- SendClientMessageToAll(-1,hammermessage);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement