h4x7o0r Posted October 7, 2012 Posted October 7, 2012 Hello, I've seen an useful radar resource on a cross server. The particularity of this radar is that u can see the cross roads (vgsh...). Here is a picture to see exactly why am i looking for :
Jaysds1 Posted October 7, 2012 Posted October 7, 2012 Sorry, but did you check here: community.multitheftauto.com
TwiX! Posted October 7, 2012 Posted October 7, 2012 getElementsByType Type object Then you can replace and draw image (this object) dxDrawImage or dxDrawLine
h4x7o0r Posted October 7, 2012 Author Posted October 7, 2012 @jaysds1 : Yeah I've checked community resources and haven't found any to display the roads and so on. @TwiX! : Thank you for your reply, I've seen the docs of getElementsByType but haven't got the right answer . local objects = getElementsByType ( "object" ) But i don't know how to retrieve a specific id. For example. The cross road has 8558 id. Should i use getElementModel ? function radar ( targetElem ) if ( getElementType ( targetElem ) == "object" ) and ( getElementModel ( targetElem ) == 8558) then ... end
h4x7o0r Posted October 7, 2012 Author Posted October 7, 2012 Thank you for your reply, good is correct but how can i continue ? for example on the radar to have the road visible on the radar ? All the best.
Jaysds1 Posted October 7, 2012 Posted October 7, 2012 Do you have the model ID for those? if you do, then you could use: dxDrawLine for the road.
h4x7o0r Posted October 7, 2012 Author Posted October 7, 2012 yes i'm having .img of the road that needs to be replaced on the map and also the id for each one of road, but i don't know how can i modify the dxDrawLine to fit my requirements.
denny199 Posted October 7, 2012 Posted October 7, 2012 You need to calculate the radar first. because it's a circle
TwiX! Posted October 7, 2012 Posted October 7, 2012 yes i'm having .img of the road that needs to be replaced on the map and also the id for each one of road, but i don't know how can i modify the dxDrawLine to fit my requirements. you can get X,Y,Z from object, and draw line
h4x7o0r Posted October 7, 2012 Author Posted October 7, 2012 Thank you very much for your reply, sincerly i don't know how to calculate or what should i do LE : I wanna have all roads visible on the radar not only one.
Jaysds1 Posted October 7, 2012 Posted October 7, 2012 try using these: getWorldFromScreenPosition getScreenFromWorldPosition
h4x7o0r Posted October 7, 2012 Author Posted October 7, 2012 Thank you for reply, I've just read about those 2 functions but i think it's not what I am looking for because i want that every road (every object) that has the desire id to be positioned on the radar. I can't use x,y,z for each road by itself. LE: I've tried to figure it out how can i create the script but i think all it's a mess I've even found a resource for "custom blips" https://community.multitheftauto.com/index.php?p= ... ils&id=960 that has some exported functions. Here's what i've tried : addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), function () if ( getElementType ( targetElem ) == "object" ) and ( getElementModel ( targetElem ) == 8558) then local x, y, z = getElementPosition(targetElem) local sx, sy = getScreenFromWorldPosition(x, y, z+3) exports.customblips:createCustomBlip ( x,y, 160, 32, "road.png" ) else exports.customblips:destroyCustomBlip ( x,y, 160, 32, "road.png" ) end
h4x7o0r Posted October 11, 2012 Author Posted October 11, 2012 Anyone ? I really need this script thanks in advance for any help.
h4x7o0r Posted October 11, 2012 Author Posted October 11, 2012 I've read about what u've suggested but couldn't do it by myself that's why i've posted my *fail*script to see what should i need to change. I still don't know how to make visible on the radar my image.
Sohatoch Posted October 12, 2012 Posted October 12, 2012 First of all, calculate the radar (TwiX! just suggested that before) because it's a circle.
TwiX! Posted October 12, 2012 Posted October 12, 2012 local rObjects = { [3458] = true,[8558] = true }; -- Radar objects function getObjectsInMyDistance() rObjectsTabele = {}; local pX,pY,pZ = getElementPosition(localPlayer); if not pX or not pY or not pZ then return end for _,object in ipairs(getElementsByType("object")) do local id = getElementModel(object); if rObjects[id] then local eX,eY,eZ = getElementPosition(object); if not eX or not eY or not eZ then return end local distance = getDistanceBetweenPoints2D(pX,pY,eX,eY); if distance < 180 then table.insert(rObjectsTabele,object); end end end return rObjectsTabele; end addEventHandler("onClientRender",getRootElement(), function() local pX,pY,pZ = getElementPosition(localPlayer); local cX,cY,_,tX,tY = getCameraMatrix(); local n = findRotation(cX,cY,tX,tY); for _,object in ipairs(getObjectsInMyDistance()) do local oX,oY,oZ = getElementRotation(object); local id = getElementModel(object); local eX,eY,eZ = getElementPosition(object); if id == 3458 then img = "yourImage.png"; --Here you can set rotation for object elseif id == 8558 then img = "YouImageForThisID.png"; --Here you can set rotation for object end dxDrawImage(yourX,yourY,yourWidth,yourHeight,img,n-oZ,0,0,tocolor(255,255,255,255)); --Or dxDrawLine end end ); function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)); if t < 0 then t = t + 360; end return t end something like this don't forget to change "yourX","yourY","yourWidth","yourHeight"
h4x7o0r Posted October 12, 2012 Author Posted October 12, 2012 Thank you so much for your effort, u made my day. There are some errors : LINE 37: Bad argument @ "dxDrawImage" [Expected number at argument 1, got nil]
TwiX! Posted October 13, 2012 Posted October 13, 2012 [don't forget to change "yourX","yourY","yourWidth","yourHeight"] i not will make all script for you
h4x7o0r Posted October 13, 2012 Author Posted October 13, 2012 I've used some values, like : 200 20 160 32. (didn't let that unmodified) Should I need another function to retrieve this ? Thank you for all and still sorry for bothering. All the best.
TwiX! Posted October 14, 2012 Posted October 14, 2012 I've used some values, like : 200 20 160 32. (didn't let that unmodified) why? you need there object x,y,z,rx,ry,z
h4x7o0r Posted October 14, 2012 Author Posted October 14, 2012 Those are values that i can find somewhere .. or do i need another function to get them all ? This is kinda ambiguous. Feel sorry for bothering you with my misunderstood and also thanks for your help.
TwiX! Posted October 14, 2012 Posted October 14, 2012 Those are values that i can find somewhere .. or do i need another function to get them all ? This is kinda ambiguous. Feel sorry for bothering you with my misunderstood and also thanks for your help. you have everything to do it learn lua here pls: https://wiki.multitheftauto.com/wiki/Scr ... troduction or other's lua tutorials
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