-- https://fatality.win/threads/lua-chat-spam.2701/
local config = fatality.config;
local menu = fatality.menu;
local callbacks = fatality.callbacks;
local chat_spam_checkbox_item = config:add_item('misc_chat_spam', 0.0);
local chat_spam_checkbox = menu:add_checkbox('Chat Spam', 'Visuals', 'Misc', 'Various', chat_spam_checkbox_item);
local engine_client = csgo.interface_handler:get_engine_client();
local entity_list = csgo.interface_handler:get_entity_list();
local events = csgo.interface_handler:get_events();
events:add_event('player_death');
events:add_event('player_changename');
events:add_event('bomb_beginplant');
events:add_event('bomb_abortplant');
events:add_event('bomb_planted');
events:add_event('bomb_defused');
events:add_event('bomb_exploded');
events:add_event('bomb_dropped');
events:add_event('bomb_pickup');
events:add_event('bomb_begindefuse');
events:add_event('bomb_abortdefuse');
events:add_event('round_mvp');
local function on_events(event)
if not chat_spam_checkbox_item:get_bool() then
return;
end
if not engine_client:is_connected() and not engine_client:is_in_game() then
return;
end
local local_player = entity_list:get_localplayer();
if local_player == nil then
return;
end
if event:get_name() == 'player_death' then
local event_user_id = event:get_int('userid');
local event_attacker = event:get_int('attacker');
local event_weapon = event:get_string('weapon');
local event_headshot = event:get_bool('headshot');
if event_user_id == nil or event_attacker == nil or event_weapon == nil or event_headshot == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
local attacker = entity_list:get_player_from_id(event_attacker);
if user_id == nil or attacker == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
if not attacker:get_index() == attacker:get_index() then
return;
end
if attacker:get_index() == local_player:get_index() then
if event_headshot then
chat_message = name .. ' has just died to a headshot by my ' .. event_weapon;
else
chat_message = name .. ' has just died to my ' .. event_weapon;
end
if chat_message == nil then
return;
end
engine_client:client_cmd('say ' .. chat_message);
end
end
if event:get_name() == 'player_changename' then
local event_old_name = event:get_string('oldname');
local event_new_name = event:get_string('newname');
if event_old_name == nil or event_new_name == nil then
return;
end
if string.len(event_old_name) > 32 then
event_old_name = string.sub(event_old_name, 0, 32);
end
if string.len(event_new_name) > 32 then
event_new_name = string.sub(event_new_name, 0, 32);
end
engine_client:client_cmd('say ' .. event_old_name .. ' has changed their name to ' .. event_new_name);
end
if event:get_name() == 'bomb_beginplant' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has just begun to plant the bomb');
end
if event:get_name() == 'bomb_abortplant' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has aborted planting the bomb');
end
if event:get_name() == 'bomb_planted' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has planted the bomb');
end
if event:get_name() == 'bomb_defused' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has defused the bomb');
end
if event:get_name() == 'bomb_exploded' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say The bomb planted by ' .. name .. ' has exploded');
end
if event:get_name() == 'bomb_dropped' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has dropped the bomb');
end
if event:get_name() == 'bomb_pickup' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has picked up the bomb');
end
if event:get_name() == 'bomb_begindefuse' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has begun to defuse the bomb');
end
if event:get_name() == 'bomb_abortdefuse' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' has aborted defusing the bomb');
end
if event:get_name() == 'round_mvp' then
local event_user_id = event:get_int('userid');
if event_user_id == nil then
return;
end
local user_id = entity_list:get_player_from_id(event_user_id);
if user_id == nil then
return;
end
local name = user_id:get_name();
if name == nil then
return;
end
if string.len(name) > 32 then
name = string.sub(name, 0, 32);
end
engine_client:client_cmd('say ' .. name .. ' was the round mvp');
end
end
callbacks:add('events', on_events);