side Posted May 10, 2019 Share Posted May 10, 2019 You could help me, I would like to create an indicator about the world of gta sa, if you could give me an example, I thank you ---------------------------------------------------------------------------------------------------------------------------------------------- -- OBJECTIVE INDICATORS BY MADNESSRELOADED -- -- createObjectiveIndicator (x,y,z,name[,maxdistance,mindistance,r,g,b,image]) -- RETURNS ID -- destroyObjectiveIndicator (id) -- GET THE ID RETURNED BY CREATEOBJECTIVEINDICATOR -- drawObjectiveIndicator (x,y,z,name[,maxdistance,mindistance,r,g,b,image]) allzones = { } function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end function isPedAiming ( thePedToCheck ) --https://wiki.multitheftauto.com/wiki/IsPedAiming if isElement(thePedToCheck) then if getElementType(thePedToCheck) == "player" or getElementType(thePedToCheck) == "ped" then if getPedTask(thePedToCheck, "secondary", 0) == "TASK_SIMPLE_USE_GUN" then return true end end end return false end function dxDrawBordered( text, x, y, w, h, color, scale, font, ax, ay, clip, wb, postgui ) dxDrawText ( text, x - 1.2, y - 1.2, w - 1.2, h - 1.2, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x + 1.2, y - 1.2, w + 1.2, h - 1.2, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x - 1.2, y + 1.2, w - 1.2, h + 1.2, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x + 1.2, y + 1.2, w + 1.2, h + 1.2, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x - 1.2, y, w - 1.2, h, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x + 1.2, y, w + 1.2, h, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x, y - 1.2, w, h - 1.2, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x, y + 1.2, w, h + 1.2, tocolor ( 0, 0, 0, 255 ), scale, font, ax, ay, clip, wb, false ) dxDrawText ( text, x, y, w, h, color, scale, font, ax, ay, clip, wb, postgui ) end function drawObjectiveIndicator (wwx,wwy,wwz,type,maxdist,lowdist,r,g,b,image) local measure = "m" local screenW, screenH = getScreenFromWorldPosition(wwx, wwy, wwz+1) if not screenW then return end local x,y,z = getElementPosition(localPlayer) local dst = math.floor(getDistanceBetweenPoints3D (x,y,z,wwx,wwy,wwz)) if dst< (lowdist or 50) then return end if dst > (maxdist or 5000) then return end dxDrawImage(screenW-16, screenH-16, 25, 25,image or "pin.png",0,0,0,tocolor (255,255,255,150)) local wr = screenW-16 local wu = screenH-32 local sz =32 local sy =32 dst = math.floor(getDistanceBetweenPoints3D (x,y,z,wwx,wwy,wwz)) if dst <100 then wr = screenW-16 elseif dst > 99 and dst<1000 then wr = screenW-13 elseif dst >999 then wr = screenW-16 dst = round(dst/1000,1) measure = "km" end dxDrawBordered (type.." ("..dst..""..measure..")",wr, wu,sz,sy+1,tocolor (r or 255,g or 255,b or 255,255),1,"sans serif","left") end function createObjectiveIndicator (x,y,z,name,maxdistance,mindistance,r,g,b,image) if not x or not y or not z then outputDebugString ("Objective indicator position not specified.",2) elseif not name then outputDebugString ("Objective name not specified.",2) return end if not maxdistance or maxdistance == nil then maxdistance = 5000 end if not mindistance or mindistance == nil then mindistance = 50 end if not r or not g or not b then r,g,b = 255,255,255 end local id = #allzones+1 table.insert (allzones, id, {x,y,z,name,maxdistance,mindistance,r,g,b,image}) return #allzones end function destroyObjectiveIndicator (id) table.remove (allzones,id) end addEventHandler ("onClientRender",root,function() if isPedAiming (localPlayer) then return end for i,zone in ipairs (allzones) do x,y,z,name,maxdistance,mindistance,r,g,b,image = unpack (zone) drawObjectiveIndicator (x,y,z,name,maxdistance,mindistance,r,g,b,image) end end) - - - - - - - - - - - -- - - - -- - - -- - -- - - -- - - -- - - - -- - - - - - <meta> <info author="MadnessReloaded" name="Objective Indicators" version="1.0" type="script"/> <script src="client.lua" type="client" cache="false"/> <min_mta_version client="1.5.0" server="1.4.0"/> <file src="pin.png"/> <export function="createObjectiveIndicator" type="client"/> <export function="drawObjectiveIndicator" type="client"/> <export function="removeObjectiveIndicator" type="client"/> </meta> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now