-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
You are talking nonsense... This has nothing to do with a M4 id. setWeaponProperty ( 32,"pro","flag_aim_arm", true ) setWeaponProperty ( 32,"std","flag_aim_arm", true ) setWeaponProperty ( 32,"poor","flag_aim_arm", true )
-
Remove everything, except line 4... No event needed, just that line.
-
That is not so hard, you can do that by yourself. getPlayerTeam
-
Try this: 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,hitElement = 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 ) local laserColor = tocolor(0,255,0,255) if hit then endX,endY,endZ = endX2,endY2,endZ2 if hitElement then local elementType = getElementType(hitElement) if elementType == "vehicle" or elementType == "ped" then laserColor = tocolor(255,0,0,255) end end 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,laserColor,10) end end end addEventHandler("onClientRender",root,renderTankLine)
-
Try it first yourself and show us what you did.
-
Syntax projectile createProjectile ( element creator, int weaponType [, float posX, float posY, float posZ, float force = 1.0, element target = nil, float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] ) projectile createProjectile ( element creator, int weaponType [, float posX, float posY, float posZ, float force = 1.0, [color=#FF0000]element target = nil[/color], float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] )
-
You can do that yourself. I am here to tell you how etc. and help you, but I am not going to change every little part. https://wiki.multitheftauto.com/wiki/CreateProjectile
-
Line 24: if not veh or getElementModel(veh) ~= 425 then return end
-
That should probably be: "anim_group" https://wiki.multitheftauto.com/wiki/GetWeaponProperty But this is a get only property, MTA can't do it yet. They(MTA team) didn't give this priority, so that's unfortunately.
-
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
