SHARE
TWEET

Hitscan

it300 Oct 23rd, 2016 (edited) 237 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Hit-Scan (Projectile Velocity Modification)
  2. -- SAPP Compatability: 9.8+
  3. -- Script by: Skylace aka Devieth
  4. -- Discord: https://discord.gg/Mxmuxgm
  5.  
  6. api_version = "1.10.0.0"
  7.  
  8. function OnScriptLoad()
  9.     safe_read(true) safe_write(true)
  10.     register_callback(cb['EVENT_GAME_START'], "OnMapLoad")
  11. end
  12.  
  13. function OnMapLoad()
  14.     first = true
  15.     EnableHitscan()
  16. end
  17.  
  18. function OnScriptUnload() end
  19.  
  20. function EnableHitscan()
  21.     local tag_address = read_dword(0x40440000)
  22.     local tag_count = read_dword(0x4044000C)
  23.     timer(180, "print_wait", "\n\n --[[ Hitscan Edits Started. ]]--")
  24.     for i=0,tag_count-1 do
  25.         local tag = tag_address + 0x20 * i
  26.         local tag_name = read_string(read_dword(tag + 0x10))
  27.         local tag_class = string.reverse(string.sub(read_string(tag),1,4))
  28.         if tag_class == "proj" then
  29.             local tag_data = read_dword(tag + 0x14)
  30.             local t = tokenizestring(read_float(tag_data + 0x1e8), ".")
  31.             if string.sub(tag_name,1,4) == "weap" then
  32.                 if t[1] == "3" or t[1] == "10" then -- Intiger values of bullet speed.
  33.                     write_float(tag_data + 0x1e8, 40)
  34.                     timer(200, "print_wait", "Edited Slow_proj: '" .. tag_name) -- ARs, shotguns, and pistols.
  35.                 elseif t[1] == "33" then
  36.                     write_float(tag_data + 0x1e8, 1000)
  37.                     timer(225, "print_wait", "Edited Fast_proj: '" .. tag_name) -- Snipers (hopefully works with beam rifles on custom maps.)
  38.                 else
  39.                     if t[1] == "40" or t[1] == "1000" then
  40.                         timer(250, "print_wait", "Already edited: ".. tag_name) -- If the projectile speed has already been modified.
  41.                     else
  42.                         timer(300, "print_wait", "Cannot be edited: " .. tag_name) -- If the projectile cannot be edited (non-bullet weapons.)
  43.                     end
  44.                 end
  45.             elseif string.sub(tag_name,1,4) == "vehi" then
  46.                 if t[1] == "10" then -- Tank bullet.
  47.                     write_float(tag_data + 0x1e8, 40)
  48.                     timer(200, "print_wait", "Edited '" .. tag_name .. "' as a low speed projectile.")
  49.                 else
  50.                     if t[1] == "40" then
  51.                         timer(275, "print_wait", "Already edited: ".. tag_name)
  52.                     else
  53.                         timer(325, "print_wait", "Cannot be edited: " .. tag_name)
  54.                     end
  55.                 end
  56.             end
  57.         end
  58.     end
  59.     timer(350, "print_wait", "--[[ Hitscan Edits Finished. ]]--\n")
  60. end
  61.  
  62. function print_wait(msg) -- Used to slow down the printing otherwize the script loads so fast when starting a server it gets scrambled.
  63.     print(msg)
  64. end
  65.  
  66. function tokenizestring(inputstr, sep)
  67.     if sep == nil then
  68.         sep = "%s"
  69.     end
  70.     local t={} ; i=1
  71.     for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  72.         t[i] = str
  73.         i = i + 1
  74.     end
  75.     return t
  76. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top