Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Return Coordinates, Weapon & Vehicle ###]]--
- --[[ ### by H® Shaft for Phasor v2 ###]]--
- --[[ ### consoletext overload by Nugget ###]]--
- -- Scripting tool, not a game play script
- -- Type: 'coord' - returns your x,y,z coordinates in or out of a vehicle
- -- Type: 'hogname' - returns the tagname of the vehicle you are in - useful for CE maps. Note: Protected CE maps will return '<protected>'
- -- Type: 'weapon' - returns the tagname of the weapon you are holding - useful for CE maps. Note: Protected CE maps will return '<protected>'
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- end
- function OnServerChat(player, type, message)
- local response = nil
- if player then
- --will tell you the tagname of the vehicle you are in: primarily for CE
- if string.lower(message) == "hogname" and isinvehicle(player) then
- if isinvehicle(player) then
- local m_player = getplayer(player)
- local m_objectId = readdword(m_player + 0x34)
- local m_object = getobject(m_objectId)
- if m_object then
- local m_vehicleId = readdword(m_object + 0x11C)
- local m_vehicle = getobject(m_vehicleId)
- local vehname = gettaginfo(readdword(m_vehicle))
- sendconsoletext(player, "Vehicle tag name: " .. vehname, 15, 0)
- -- tag returned would be: vehicles/warthog/mp_warthog then scripted as: vehicles//warthog//mp_warthog
- end
- end
- return true
- end
- -- returns your coordinates in or out of vehicle: x, y, z
- if string.lower(message) == "coord" then
- local m_playerObjId = getplayerobjectid(player)
- if m_playerObjId then
- if isinvehicle(player) then
- local m_vehicleId = readdword(getobject(m_playerObjId) + 0x11C)
- m_objectId = m_vehicleId
- elseif m_playerObjId then
- m_objectId = m_playerObjId
- end
- if m_objectId then
- local x,y,z = getobjectcoords(m_objectId)
- sendconsoletext(player, "X: " .. x .. " Y: " .. y .. " Z: " .. z, 15, 0)
- end
- end
- return true
- end
- --will tell you the tagname of the primary weapon you are holding: primarily for CE
- if string.lower(message) == "weapon" and not isinvehicle(player) then
- local m_player = getplayer(player)
- local m_objectId = readdword(m_player + 0x34)
- local m_object = getobject(m_objectId)
- if m_object then
- local m_weaponId = readdword(m_object + 0x118)
- if m_weaponId then
- local m_weapon = getobject(m_weaponId)
- local weapname = gettaginfo(readdword(m_weapon))
- if m_weapon then
- sendconsoletext(player, "Weapon tag name: " .. weapname, 15, 0)
- -- tag returned would be: weapons/pistol/pistol then scripted as: weapons//pistol//pistol
- end
- end
- end
- return true
- end
- end
- end
- -- Start sendconsoletext overloaded by Nugget
- console = {}
- console.__index = console
- consoletimer = registertimer(100, "ConsoleTimer")
- phasor_sendconsoletext = sendconsoletext
- function sendconsoletext(player, message, time, order, align, height, func)
- if player then
- console[player] = console[player] or {}
- local temp = {}
- temp.player = player
- temp.id = nextid(player, order)
- temp.message = message or ""
- temp.time = time or 0.7
- temp.remain = temp.time
- temp.align = align or "left"
- temp.height = height or 0
- if type(func) == "function" then
- temp.func = func
- elseif type(func) == "string" then
- temp.func = _G[func]
- end
- console[player][temp.id] = temp
- setmetatable(console[player][temp.id], console)
- return console[player][temp.id]
- end
- end
- function nextid(player, order)
- if not order then
- local x = 0
- for k,v in pairs(console[player]) do
- if k > x + 1 then
- return x + 1
- end
- x = x + 1
- end
- return x + 1
- else
- local original = order
- while console[player][order] do
- order = order + 0.001
- if order == original + 0.999 then break end
- end
- return order
- end
- end
- function getmessage(player, order)
- if console[player] then
- if order then
- return console[player][order]
- end
- end
- end
- function getmessages(player)
- return console[player]
- end
- function getmessageblock(player, order)
- local temp = {}
- for k,v in opairs(console[player]) do
- if k >= order and k < order + 1 then
- table.insert(temp, console[player][k])
- end
- end
- return temp
- end
- function console:getmessage()
- return self.message
- end
- function console:append(message, reset)
- if console[self.player] then
- if console[self.player][self.id] then
- if getplayer(self.player) then
- if reset then
- if reset == true then
- console[self.player][self.id].remain = console[self.player][self.id].time
- elseif tonumber(reset) then
- console[self.player][self.id].time = tonumber(reset)
- console[self.player][self.id].remain = tonumber(reset)
- end
- end
- console[self.player][self.id].message = message or ""
- return true
- end
- end
- end
- end
- function console:shift(order)
- local temp = console[self.player][self.id]
- console[self.player][self.id] = console[self.player][order]
- console[self.player][order] = temp
- end
- function console:pause(time)
- console[self.player][self.id].pausetime = time or 5
- end
- function console:delete()
- console[self.player][self.id] = nil
- end
- function ConsoleTimer(id, count)
- for i,_ in opairs(console) do
- if tonumber(i) then
- if getplayer(i) then
- for k,v in opairs(console[i]) do
- if console[i][k].pausetime then
- console[i][k].pausetime = console[i][k].pausetime - 0.1
- if console[i][k].pausetime <= 0 then
- console[i][k].pausetime = nil
- end
- else
- if console[i][k].func then
- if not console[i][k].func(i) then
- console[i][k] = nil
- end
- end
- if console[i][k] then
- console[i][k].remain = console[i][k].remain - 0.1
- if console[i][k].remain <= 0 then
- console[i][k] = nil
- end
- end
- end
- end
- if table.len(console[i]) > 0 then
- local paused = 0
- for k,v in pairs(console[i]) do
- if console[i][k].pausetime then
- paused = paused + 1
- end
- end
- if paused < table.len(console[i]) then
- local str = ""
- for i = 0,30 do
- str = str .. " \n"
- end
- phasor_sendconsoletext(i, str)
- for k,v in opairs(console[i]) do
- if not console[i][k].pausetime then
- if console[i][k].align == "right" or console[i][k].align == "center" then
- phasor_sendconsoletext(i, consolecenter(string.sub(console[i][k].message, 1, 78)))
- else
- phasor_sendconsoletext(i, string.sub(console[i][k].message, 1, 78))
- end
- end
- end
- end
- end
- else
- console[i] = nil
- end
- end
- end
- return true
- end
- function consolecenter(text)
- if text then
- local len = string.len(text)
- for i = len + 1, 78 do
- text = " " .. text
- end
- return text
- 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 table.unpack(keys) then
- local key = keys[count]
- local value = t[key]
- count = count + 1
- return key,value
- end
- end
- end
- function table.len(t)
- local count = 0
- for k,v in pairs(t) do
- count = count + 1
- end
- return count
- end
- -- Stop sendconsoletext overloaded
- -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement