Участник
Пользователь
- Сообщения
- 449
- Реакции
- 17
- Помог
- 1 раз(а)
Код:
#include <amxmodx>
#include <fakemeta>
#include <fun>
new g_isBlocked = 0 // Global variable to block bomb planting
public plugin_init() {
register_plugin("Block Bomb Plant on /frag", "1.0", "test");
register_clcmd("/frag", "cmd_frag") // When admin types /frag
register_clcmd("/fragoff", "cmd_fragoff") // When admin types /fragoff
register_event("CurWeapon", "on_weapon_change", "a", "1=1") // Check if user is bomb carrier
}
public cmd_frag(id) {
if (is_user_admin(id)) { // If the user is an admin
g_isBlocked = 1; // Block bomb planting
client_print(id, print_chat, "Bomb planting is now blocked!")
}
}
public cmd_fragoff(id) {
if (is_user_admin(id)) { // If the user is an admin
g_isBlocked = 0; // Allow bomb planting
client_print(id, print_chat, "Bomb planting is now allowed!")
}
}
public on_weapon_change(id) {
if (g_isBlocked && get_user_weapon(id) == CSW_C4) { // If user is bomb carrier and planting is blocked
remove_item(id, CSW_C4); // Correct function to remove bomb (C4)
client_print(id, print_chat, "Bomb planting is blocked by admin!");
}
}
public plugin_end() {
g_isBlocked = 0; // Reset the block when plugin ends
}
// Check if the user is an admin
public is_user_admin(id) {
new flags = get_user_flags(id); // Get the user's flags
return (flags & ADMIN_KICK) != 0; // Check if the user has admin rights (KICK permission or higher)
}
C++