Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MultiWeapon
- weapons = {}
- switch = {}
- multiweap = {}
- onweaponpickup = {}
- max_weapons = 6
- for i = 0,15 do
- weapons[i] = {}
- multiweap[i] = {}
- switch[i] = 0
- onweaponpickup[i] = true
- end
- function GetRequiredVersion()
- return 10058
- end
- function OnScriptLoad(process)
- end
- function OnScriptUnload()
- end
- function OnNewGame(map)
- end
- function OnGameEnd(mode)
- end
- function OnServerChat(player, chattype, message)
- return 1
- end
- function OnServerCommand(player, command)
- return 1
- end
- function OnTeamDecision(team)
- return team
- end
- function OnPlayerJoin(player, team)
- end
- function OnPlayerLeave(player, team)
- end
- function OnPlayerKill(killer, victim, mode)
- end
- function OnKillMultiplier(player, multiplier)
- end
- function OnPlayerSpawn(player, m_objId)
- end
- function OnPlayerSpawnEnd(player, m_objId)
- end
- function OnTeamChange(relevant, player, cur_team, dest_team)
- return 1
- end
- function OnObjectCreation(m_objId, player, tagName)
- end
- function OnObjectInteraction(player, m_objId, tagType, tagName)
- return 1
- end
- function OnWeaponAssignment(player, m_objId, slot, tagName)
- return 0
- end
- function OnWeaponReload(player, m_weapId)
- return 1
- end
- function OnDamageLookup(receiver, causer, tagData, tagName)
- end
- function OnVehicleEntry(relevant, player, m_vehicleId, tagName, seat)
- return 1
- end
- function OnVehicleEject(player, forced)
- return 1
- end
- function OnWeaponPickup(player, m_objId, tagName, m_weapId, slot)
- if #weapons[player] <= max_weapons then
- table.insert(weapons[player], tagName)
- end
- end
- function OnWeaponSwitch(player, m_objId, cur_tagName, next_tagName, cur_weapId, next_weapId, cur_slot, next_slot)
- local slot = table.find(weapons[player], cur_tagName)
- if weapons[slot + 1] then
- destroyobject(next_weapId)
- assignweapon(player, weapons[slot + 1])
- else
- destroyobject(next_weapId)
- assignweapon(player, weapons[1])
- end
- end
- function OnClientUpdate(player, m_objId)
- end
- registertimer(10, "WeaponTimer")
- function WeaponTimer(id, count)
- for i = 0,15 do
- if gethash(i) then
- local m_player = getplayer(i)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- local primary_weapId = readdword(m_object, 0x2F8)
- local secondary_weapId = readdword(m_object, 0x2FC)
- local tertiary_weapId = readdword(m_object, 0x300)
- local quartenary_weapId = readdword(m_object, 0x304)
- local new_weaps = {primary_weapId, secondary_weapId, tertiary_weapId, quartenary_weapId}
- for k,v in opairs(new_weaps) do
- local tagType, tagName = getobjecttag(v)
- if weapons[i][k] ~= tagName then
- if onweaponpickup[i] then
- OnWeaponPickup(i, m_objId, tagName, v, k)
- weapons[i][k] = tagName
- end
- end
- end
- local next_slot = readword(m_object, 0x2F4)
- if next_slot ~= switch[i] then
- local cur_slot = readword(m_object, 0x2F2)
- local cur_weapId = readdword(m_object, 0x118)
- local next_weapId = readdword(m_object, 0x2F8 + next_slot * 4)
- local _, cur_tagName = getobjecttag(cur_weapId)
- local __, next_tagName = getobjecttag(next_weapId)
- OnWeaponSwitch(i, m_objId, cur_tagName, next_tagName, cur_weapId, next_weapId, cur_slot, next_slot)
- switch[i] = next_slot
- end
- end
- end
- end
- return 1
- end
- local phasor_assignweapon = assignweapon
- function assignweapon(player, tagName)
- onweaponpickup[player] = false
- phasor_assignweapon(player, tagName)
- onweaponpickup[player] = true
- end
- function table.find(t, val)
- for k,v in pairs(t) do
- if v == val then
- return k
- end
- end
- end
- function opairs(t)
- local keys = {}
- for k,v in pairs(t) do
- table.insert(keys, k)
- end
- table.sort(keys,
- function(a,b)
- if type(a) == "number" and type(b) == "number" then
- return a < b
- end
- an = string.lower(tostring(a))
- bn = string.lower(tostring(b))
- if an ~= bn then
- return an < bn
- else
- return tostring(a) < tostring(b)
- end
- end)
- local count = 1
- return function()
- if unpack(keys) then
- local key = keys[count]
- local value = t[key]
- count = count + 1
- return key,value
- end
- end
- end
- -- The following were written by Smiley --
- function getobjecttag(m_objId)
- local m_object = getobject(m_objId)
- local object_map_id = readdword(m_object, 0x0)
- local map_pointer = 0x460678
- local map_base = readdword(map_pointer, 0x0)
- local map_tag_count = todec(endian(map_base, 0xC, 0x3))
- local tag_table_base = map_base + 0x28
- local tag_table_size = 0x20
- for i = 0, (map_tag_count - 1) do
- local tag_id = todec(endian(tag_table_base, 0xC + (tag_table_size * i), 0x3))
- if tag_id == object_map_id then
- local tag_class = readstring(tag_table_base, (tag_table_size * i), 0x3, 1)
- local tag_name_address = endian(tag_table_base, 0x10 + (tag_table_size * i), 0x3)
- local tag_name = readtagname("0x" .. tag_name_address)
- return tag_class, tag_name
- end
- end
- end
- function readstring(address, offset, length, endian)
- local char_table = {}
- local string = ""
- for i=0,length do
- if readbyte(address, (offset + (0x1 * i))) ~= 0 then
- table.insert(char_table, string.char(readbyte(address, (offset + (0x1 * i)))))
- end
- end
- for k,v in pairs(char_table) do
- if endian == 1 then
- string = v .. string
- else
- string = string .. v
- end
- end
- return string
- end
- function readtagname(address)
- local char_table = {}
- local i = 0
- local string = ""
- while readbyte(address, (0x1 * i)) ~= 0 do
- table.insert(char_table, string.char(readbyte(address, (0x1 * i))))
- i = i + 1
- end
- for k,v in pairs(char_table) do
- string = string .. v
- end
- return string
- end
- function endian(address, offset, length)
- local data_table = {}
- local data = ""
- for i=0,length do
- local hex = string.format("%X", readbyte(address, offset + (0x1 * i)))
- if tonumber(hex, 16) < 16 then
- hex = 0 .. hex
- end
- table.insert(data_table, hex)
- end
- for k,v in pairs(data_table) do
- data = v .. data
- end
- return data
- end
- function tohex(number)
- return string.format("%X", number)
- end
- function todec(number)
- return tonumber(number, 16)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement