-
Posts
6,063 -
Joined
-
Last visited
-
Days Won
209
Everything posted by IIYAMA
-
ah yea, indeed. Here + tested. local imageLocation = "image.png" local imageSizeX,imageSizeY = 100,100 local extendLine = function ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local texture = dxCreateTexture(imageLocation,"dxt5") or imageLocation -- createTexture + fallback local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c","world" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a","world" ) if x and x1 then local endX,endY,endZ = extendLine(x1,y1,z1,x,y,z,10000) local hit,endX2,endY2,endZ2 = processLineOfSight ( x,y,z,endX,endY,endZ, true, -- checkBuildings true, -- checkVehicles true, -- checkPlayers true, -- checkObjects true, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff theVeh -- ignoredElement ) if hit then endX,endY,endZ = endX2,endY2,endZ2 end local imageCenterX,imageCenterY = getScreenFromWorldPosition (endX,endY,endZ) if imageCenterX and imageCenterY then dxDrawImage(imageCenterX-imageSizeX/2,imageCenterY-imageSizeY/2,imageSizeX,imageSizeY,texture) end dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0,255),10) end end end addEventHandler("onClientRender",root,renderTankLine)
-
This tutorial is not for beginners. This code will successfully find the player scaling factor, to convert the 3D world units to 2D pixels on your monitor. The factor 0.622388530006 is probably a standard, but you never know. Image1 Image2 Image3 Image4 The function that finds this factor. local screenX,screenY = guiGetScreenSize() local scaleFactorBuffer = nil function findScaleFactor () if scaleFactorBuffer then return scaleFactorBuffer else local startX,startY,startZ = getWorldFromScreenPosition ( 0,0, 1 ) local endX,endY,endZ = getWorldFromScreenPosition ( screenX,screenY, 1 ) if startX and endX then scaleFactorBuffer = 1/getDistanceBetweenPoints3D(startX,startY,startZ,endX,endY,endZ) return scaleFactorBuffer end end return false end The set up for the example below: -- the set up -- local imagePosX,imagePosY,imagePosZ = -21.38184, 5.24524, 3.10965 local imageResolution = 1000 ---------------- The example on how to use: addEventHandler("onClientRender",root, function () local scaleFactor = findScaleFactor () if scaleFactor then dxDrawText("scaleFactor: " .. scaleFactor,300,300) -- The scale factor is circa 0.622388530006 (units). local rectangleCenterX,rectangleCenterY = getScreenFromWorldPosition(imagePosX,imagePosY,imagePosZ) if rectangleCenterX and rectangleCenterY then local playerX,playerY,playerZ = getElementPosition(getCamera()) local size = (imageResolution*scaleFactor)/getDistanceBetweenPoints3D(playerX,playerY,playerZ,imagePosX,imagePosY,imagePosZ) dxDrawText("size: " .. size,300,320) dxDrawRectangle(rectangleCenterX+size/2,rectangleCenterY+size/2,size,size,tocolor(0,0,200)) end end end)
-
and why? Have you filled everything in correctly? And added the image location in the meta.xml?
-
Try this, edit the variables on the top. local imageLocation = "image.png" local imageSizeX,imageSizeY = 100,100 local extendLine = function ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local texture = createTexture(imageLocation,"dxt5") or imageLocation -- createTexture + fallback local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c","world" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a","world" ) if x and x1 then local endX,endY,endZ = extendLine(x1,y1,z1,x,y,z,10000) local hit,endX2,endY2,endZ2 = processLineOfSight ( x,y,z,endX,endY,endZ, true, -- checkBuildings true, -- checkVehicles true, -- checkPlayers true, -- checkObjects true, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff theVeh -- ignoredElement ) if hit then endX,endY,endZ = endX2,endY2,endZ2 end local imageCenterX,imageCenterY = getScreenFromWorldPosition (endX,endY,endZ) if imageCenterX and imageCenterY then dxDrawImage(imageCenterX-imageSizeX/2,imageCenterY-imageSizeY/2,imageCenterX,imageCenterY,texture) end dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0,255),10) end end end addEventHandler("onClientRender",root,renderTankLine)
-
Try this: local extendLine = function ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c","world" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a","world" ) if x and x1 then local = extendLine(x1,y1,z1,x,y,z,10000) local hit,endX2,endY2,endZ2 = processLineOfSight ( x,y,z,endX,endY,endZ true, -- checkBuildings true, -- checkVehicles true, -- checkPlayers true, -- checkObjects true, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff theVeh, -- ignoredElement ) if hit then endX,endY,endZ = endX2,endY2,endZ2 end dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0,255),10) end end end addEventHandler("onClientRender",root,renderTankLine)
-
Now I tested it my self. local extendLine = function ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c","world" ) -- < problem local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a","world" ) -- < problem if x and x1 then local endX,endY,endZ = extendLine(x1,y1,z1,x,y,z,10000) dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0,255),10) end end end addEventHandler("onClientRender",root,renderTankLine) And solved the problem...
-
dxDrawLine3D ( float startX, float startY, float startZ, float endX, float endY, float endZ, int color[, int width, bool postGUI ] ) dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0,255)[color=#FF0000],10[/color]) dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0,255),10)
-
Amazing, that you say it doesn't work, when you haven't even make the line thicker. And if you did, show us that code and a screenshot of it.
-
Source is the resourceRoot and not a payer. OnResourceStart event doesn't ever have a player as source.
-
No that is incorrect. That warning is from another line. Line 1 is correct.
-
That warning you see is not from me. @HUNGRY:3 what did you change? I don't see any differences. @-Lemonade- Try to make the line a little bit thicker, because it must be somewhere.
-
Any errors or warnings? Because exactly those from that screenshot shouldn't be visible any more.
-
Did you copied the code after 19:35? I didn't add those red letters for nothing.
-
Try this, I used to use flags, but doing it like this should be working too. setWeaponProperty ( 35,"pro","flag_aim_arm",true)-- Rocket Launcher setWeaponProperty ( 36,"pro","flag_aim_arm",true)--Heat-Seeking RPG
-
It is not really optimised based on when it renders. But it should be working. I added dxDrawLine3D instead of dxDrawLine because it is easier to use for 3D. But if you want to keep the line the same thickness, you will have to study this function: https://wiki.multitheftauto.com/wiki/Ge ... ldPosition in order to use dxDrawLine > 3D. function extendLine ( x,y,z,x2,y2,z2,length ) local vx = x2 - x local vy = y2 - y local vz = z2 - z local ratio = length/(getDistanceBetweenPoints3D ( x,y,z,x2,y2,z2 )) vx = vx*ratio vy = vy*ratio vz = vz*ratio return (x + vx),(y + vy),(z + vz) end local renderTankLine = function () local theVeh = getPedOccupiedVehicle(localPlayer) if theVeh and getElementModel(theVeh) == 432 then local x,y,z = getVehicleComponentPosition( theVeh, "misc_c" ) local x1,y1,z1 = getVehicleComponentPosition( theVeh, "misc_a" ) if x and x1 then local endX,endY,endZ = extendLine(x,y,z,x1,y1,z1,300) dxDrawLine3D (x,y,z,endX,endY,endZ,tocolor(255,0,0)) end end end addEventHandler("onClientRender",root,renderTankLine) Update 19:35
-
In the code you posted there is only a reference to that function. You have to get the full function. function extendLine ( .... ... .. .. end
-
Get the function extendLine from the stealth resource, to extend the line... Which you probably can find in the main client file from stealth. And don't forget that the z variable is required from getVehicleComponentPosition to make this work.
-
He could try to create all elements in 1 resource. -- RESOURCE A local myElement = nil local elementCustomName = "HelloWorld!" myElement = exports.B.createElementForResource( elementCustomName, -- a custom name for your element, to prevent multiply elements of the same use. createObject, -- the functions you want to execute bla,bla,bla,bla -- arguments ) -- RESOURCE B local customElementNames = {} function createElementForResource(...) if isElement(customElementNames[elementCustomName]) then return customElementNames[elementCustomName] else local data = {...} local elementCustomName = data[1] table.remove(data,1) local functionInUSe = data[1] table.remove(data,1) local element = functionInUSe(unpack(data)) if element then customElementNames[elementCustomName] = element return element end end return false,"Element failed to create." end As long this(B) is the only resource the is running, it will work.
-
Objects that are created by scripting are bounded to the resourceDynamicElementRoot. Once that element is destroyed it will take all his children with him. When you stop a resource, the resourceRoot is destroyed, which means that all children bellow are destroyed too. It works like this: resourceRoot resourceDynamicElementRoot Elements created by scripting getResourceMapRootElement Map elements Wiki: Afaik, you can't edit this with setElementParent. You will have to initialize the elements again once you start it.
-
When you subtract(-) the player position from the ball position, you get the oposide direction vector. When you devide(/) each vector(x, y, z) by the distance between ball and player position, you get a relative direction vector. Which you can multiply(*) by a value of choice to pick the Next moving distance. And the last step is to add(+) the moving distance to the position of the ball. So you know where it is going to end.
-
http://mta.dzek.eu/mmove/
-
A circle becomes smoother when there are pixels with a lower alpha level around it. Those are also known as sub-pixels. The function dxDrawCircle is in my opinion a little bit bad example of drawing dx, because it is executing a MTA function a lot just for 1 circle. The bigger the circle to more it has to execute it. Of course the same problem you will have with images, yet there we talk about 1 execution. You could try to make custom circle textures with: https://wiki.multitheftauto.com/wiki/DxCreateTexture https://wiki.multitheftauto.com/wiki/DxGetPixelColor https://wiki.multitheftauto.com/wiki/DxSetPixelColor + the way dxDrawCircle is created. This way of doing is in the beginning slower by loading, but will catch up within a few seconds. The sub pixels are on the last pixel rings of the process. Yet this will always be a problem as long mta doesn't support svg formats.
-
That doesn't work well with more players and it is using too much bandwidth(because those are "set" and "toggle" functions). toggleControl(thePlayer, "fire", false) toggleControl(thePlayer, "zoom_in", false) toggleControl(thePlayer, "vehicle_fire", false) setElementData(thePlayer, "blood", playerBlood, true)
-
Maybe possible with: setWeaponProperty Using flags. You only know when you try.