Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Phantom Shot Detection for Sapp
- -- By: Skylace
- -- Message the server will send when a player has phantomed .
- player_phantomed_msg_enabled = true -- Should the message be enabled
- player_phantomed = " has phantom shot!"
- -- Message sent if a killer kills a victim with a phantom shot.
- phantom_kill_msg = "%s killed %s with a phantom shot!"
- -- Times a player phantoms to get a warn message
- max_phantoms = 2
- -- Times a player needs to get kills with phantoms to have an action taken.
- max_phantom_kills = 2
- -- Action taken if max_phantoms is reached. Valid options = kick, ban, ipban, warn, and none.
- phantom_action = "warn" -- Only if they are phantom shooting.
- phantom_kill_action = "kick" -- If they get kills with phantom shooting.
- -- Message if phantom_action is "warn"
- warn_msg = "Please stop phantom shooting!"
- -- Do not touch anything below this unless you know what your doing
- api_version = "1.4.0.0"
- phantom = {}
- phantomcount = {}
- isphantomshooting = {}
- phantomkills = {}
- function OnScriptLoad()
- for i = 0,15 do
- phantom[i] = 0
- end
- register_callback(cb["EVENT_TICK"], "OnServerTick")
- register_callback(cb['EVENT_DIE'], "OnPlayerDeath")
- end
- function OnScriptUnload()
- end
- function OnPlayerDeath(PlayerIndex, KillerIndex)
- if KillerIndex ~= "-1" then
- local name = get_var(PlayerIndex, "$name")
- local kname = get_var(KillerIndex, "$name")
- if isphantomshooting[kname] then
- local msg = string.format(phantom_kill_msg, kname, name)
- say_all(msg)
- if phantomkills[kname] then
- phantomkills[kname] = tonumber(phantomkills[kname]) + 1
- if phantomkills[kname] >= max_phantom_kills then
- takeaction(KillerIndex, phantom_kill_action, 1)
- end
- else
- phantomkills[kname] = 0
- end
- end
- end
- end
- function OnServerTick()
- for i = 0,15 do
- local PlayerIndex = to_player_index(i)
- if player_alive(PlayerIndex) then
- local m_object = get_dynamic_player(PlayerIndex)
- if phantom[i] == 0 then
- local melee_key = read_byte(m_object + 0x208)
- if melee_key >= 0x80 then
- local scoped = read_byte(m_object + 0x320)
- if scoped ~= 255 then
- phantom[i] = 1
- local name = get_var(PlayerIndex, "$name")
- if not isphantomshooting[name] then
- isphantomshooting[name] = true
- timer(1500, "removeactivephantom", name) -- Time it takes for melee animation to end and time players have to phantom shoot.
- end
- end
- end
- elseif phantom[i] < 60 then
- phantom[i] = phantom[i] + 1
- local is_shooting = bit.band(read_byte(m_object + 0x209), 0x08)
- if is_shooting ~= 0 then
- local name = get_var(PlayerIndex, "$name")
- if player_phantomed_msg_enabled then
- say_all_exempt(PlayerIndex, name .. player_phantomed)
- end
- if phantomcount[name] then
- phantomcount[name] = phantomcount[name] + 1
- if phantomcount[name] >= max_phantoms then
- takeaction(PlayerIndex, phantom_action, 0)
- end
- else
- phantomcount[name] = 1
- end
- phantom[i] = 0
- end
- else
- phantom[i] = 0
- end
- end
- end
- end
- function say_all_exempt(ExemptPlayer, Message) -- Dont send this message to the ExemptPlayer
- for i = 0,15 do
- local PlayerIndex = to_player_index(i)
- if player_present(PlayerIndex) then
- if PlayerIndex ~= ExemptPlayer then
- say(PlayerIndex, Message)
- end
- end
- end
- end
- function takeaction(PlayerIndex, Action, Mode)
- local name = get_var(PlayerIndex, "$name")
- if Action == "kick" then
- execute_command("k " .. PlayerIndex .. " 'Phantom Shooting'")
- elseif Action == "ban" then
- execute_command("b " .. PlayerIndex .. " 'Phantom Shooting'")
- elseif Action == "ipban" then
- execute_command("ipban " .. PlayerIndex .. " 'Phantom Shooting'")
- elseif Action == "warn" then
- say(PlayerIndex, warn_msg)
- end
- phantomcount[name] = 0
- if Mode == 1 then
- phantom[to_real_index(PlayerIndex)] = 0
- phantomkills[name] = 0
- end
- end
- function removeactivephantom(name)
- if isphantomshooting[name] then
- isphantomshooting[name] = false
- else
- isphantomshooting[name] = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement