Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/12/22 in all areas

  1. I'm glad that was helpful
    1 point
  2. I'm not sure if I understood what your problem is because it doesn't make sense to somehow get some Z coordinate from two XY points and some angle which was used to get one of those XY points. But I'll assume this is what you're trying to achieve: you have two points, origin and target, and you want to get a third point, which is in the same direction from origin as target is, but at arbitrary distance. So you could effectively push the target towards or away from origin. Is that right? If so, then it's some basic vector math. local newDistance = 50 -- set dX, dY, dZ to offset from origin to target local dX, dY, dZ = targetX-originX, targetY-originY, targetZ-originZ -- using Pythagorean theorem, calculate the length of dX, dY, dZ vector local oldDistance = math.sqrt(dX*dX + dY*dY + dZ*dZ) -- multiply each component dX, dY, dZ by newDistance and divide by oldDistance -- so newX, newY, newZ becomes the offset from origin to your desired point local newX, newY, newZ = dX*newDistance/oldDistance, dY*newDistance/oldDistance, dZ*newDistance/oldDistance -- add origin to newX, newY, newZ newX, newY, newZ = originX+newX, originY+newY, originZ+newZ -- newX, newY, newZ now contains the coordinates we're looking for newDistance/oldDistance expression repeats 3 times so we can calculate it once, store it in a variable and reuse for each component. Also, multiplication/division line can be combined with addition line. Then we get this: local newDistance = 50 local dX, dY, dZ = targetX-originX, targetY-originY, targetZ-originZ local oldDistance = math.sqrt(dX*dX + dY*dY + dZ*dZ) local multiplier = newDistance/oldDistance local newX, newY, newZ = originX+dX*multiplier, originY+dY*multiplier, originZ+dZ*multiplier
    1 point
  3. I tried the code I sent you and observed that there is no problem with the z coordinate and it works properly. ray = {} addEventHandler("onClientPlayerWeaponFire", getRootElement(), function( _, tAmmo, cAmmo, hX, hY, hZ, hElement, sX, sY, sZ) local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) local targetX, targetY, targetZ = getPedTargetEnd(source) local collisionX, collisionY, collisionZ = getPedTargetCollision(source) if(collisionX) then table.insert(ray, {muzzleX, muzzleY, muzzleZ, collisionX, collisionY, collisionZ}) else table.insert(ray, {muzzleX, muzzleY, muzzleZ, targetX, targetY, targetZ}) end end) function drawRays() for i, v in ipairs( ray ) do dxDrawLine3D( v[ 1 ], v[ 2 ], v[ 3 ], v[ 4 ], v[ 5 ], v[ 6 ], tocolor( 255, 0, 0, 100 ), 2 ) end end addEventHandler( "onClientRender", root, drawRays )
    1 point
  4. https://community.multitheftauto.com/index.php?p=resources&s=details&id=652 I did a lot of research, but I didn't find much information, there was a study similar to this in the community, can you check it, maybe there is some code that will work for you ray = {} addEventHandler("onClientPlayerWeaponFire", getRootElement(), function( _, tAmmo, cAmmo, hX, hY, hZ, hElement, sX, sY, sZ) local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) local targetX, targetY, targetZ = getPedTargetEnd(source) local collisionX, collisionY, collisionZ = getPedTargetCollision(source) if(collisionX) then table.insert(ray, {muzzleX, muzzleY, muzzleZ, collisionX, collisionY, collisionZ}) else table.insert(ray, {muzzleX, muzzleY, muzzleZ, targetX, targetY, targetZ}) end end) function drawRays() for i, v in ipairs( ray ) do dxDrawLine3D( v[ 1 ], v[ 2 ], v[ 3 ], v[ 4 ], v[ 5 ], v[ 6 ], tocolor( 255, 0, 0, 100 ), 2 ) end end addEventHandler( "onClientRender", root, drawRays ) bro can you test it i tested it works
    1 point
  5. try this function https://wiki.multitheftauto.com/wiki/FindRotation
    1 point
  6. 1 point
  7. Hi, welcome to the forums! Make sure you enter the right IP and port into the "server IP" and "server port" input boxes before hitting the "find server" button on https://multitheftauto.com/toplist/ From your screenshot it looks like you left both of those boxes blank.
    0 points
×
×
  • Create New...