-
Posts
91 -
Joined
-
Last visited
-
Days Won
2
Jayceon last won the day on November 28 2023
Jayceon had the most liked content!
About Jayceon
- Birthday 14/04/2000
Recent Profile Visitors
6,090 profile views
Jayceon's Achievements
Punk-@ss B*tch (12/54)
30
Reputation
-
To achieve the desired result, you need to calculate the chain length, for example, with getDistanceBetweenPoints3D. In the dxDrawMaterialSectionLine3D function, the U Section Size needs to be the same as the texture width (16), and the V Section Size needs to be the texture height (64). However, this alone does not yield the desired results. You also need to multiply the V Section Size with the calculated chain length, divide by the texture aspect ratio (in your case, 64/16) and finally, multiply by the line thickness ("width"). I recommend to create a helper drawing function for this, with arguments: start position, end position, chain thickness.
-
You can rotate it via setElementMatrix: function setMarkerHeading(markerElement, rotationDegrees) local markerMatrix = getElementMatrix(markerElement) -- Convert degrees to radians rotationDegrees = math.rad(rotationDegrees) -- Rotate around Z axis local cosAngle = math.cos(rotationDegrees) local sinAngle = math.sin(rotationDegrees) markerMatrix[1][1] = cosAngle markerMatrix[1][2] = sinAngle markerMatrix[1][3] = 0 markerMatrix[2][1] = -sinAngle markerMatrix[2][2] = cosAngle markerMatrix[2][3] = 0 markerMatrix[3][1] = 0 markerMatrix[3][2] = 0 markerMatrix[3][3] = 1 -- Apply updated matrix return setElementMatrix(markerElement, markerMatrix) end It's only rotates it around the Z axis like in Single-Player, if you want to rotate it in more axes you should search for rotation matrix in your preferred search engine.
- 1 reply
-
- 1
-
Hi. I've put together a code for you in which the door movement works as expected, there is one up and down movement involved at a certain camera/vehicle angle (see the pictures below). If you don't need that up/down movement either, we can remove it. local cameraElement = getCamera() local oldCursorRelX = 0.5 local oldCursorRelY = 0.5 local moveSensitivity = 2 function moveDoor(cursorRelX, cursorRelY) if not isCursorShowing() then return end local vehicleElement = getPedOccupiedVehicle(localPlayer) if not isElement(vehicleElement) then return end local cameraMatrix = getElementMatrix(cameraElement) local vehicleMatrix = getElementMatrix(vehicleElement) local dotProductX = cameraMatrix[1][1] * vehicleMatrix[1][1] + cameraMatrix[1][2] * vehicleMatrix[1][2] local dotProductY = cameraMatrix[3][1] * vehicleMatrix[1][1] + cameraMatrix[3][2] * vehicleMatrix[1][2] local cursorDeltaX = (cursorRelX - oldCursorRelX) * moveSensitivity local cursorDeltaY = (cursorRelY - oldCursorRelY) * moveSensitivity oldCursorRelX = cursorRelX oldCursorRelY = cursorRelY local dotProductCombined = cursorDeltaX * -dotProductX + cursorDeltaY * dotProductY local openRatio = getVehicleDoorOpenRatio(vehicleElement, 2) + dotProductCombined if openRatio < 0 then openRatio = 0 elseif openRatio > 1 then openRatio = 1 end setVehicleDoorOpenRatio(vehicleElement, 2, openRatio) end bindKey("f1", "down", function () addEventHandler("onClientCursorMove", root, moveDoor) end ) bindKey("f2", "down", function () removeEventHandler("onClientCursorMove", root, moveDoor) end )
- 1 reply
-
- 1
-
You can convert the normal vectors to euler angles with the following function, you can use the phi for the so called Z rotation and the theta for one of the remaining (check it which one is better for you). It's a working function, I had a fun time with it shooting trash cans everywhere function directionToEuler(dirX, dirY, dirZ) local radius = (dirX*dirX + dirY*dirY + dirZ*dirZ) ^ 0.5 local theta = math.deg(math.acos(dirZ / radius)) local phi = math.deg(math.atan2(dirY, dirX)) % 360 return theta, phi end
-
First, you don't need to convert the normal vectors to euler angles, beacuse the fxAddSparks function needs a direction vector that is exactly what normal vectors is. Second, you need to extend the TargetEndX/Y/Z values a bit because sometimes it's too short and the raycast returns false. For scaling: TargetEndX = TargetX + (TargetEndX - TargetX) * 5 TargetEndY = TargetY + (TargetEndY - TargetY) * 5 TargetEndZ = TargetZ + (TargetEndZ - TargetZ) * 5
-
Jayceon changed their profile photo
-
FernandoMTA started following Jayceon
-
The CPU usage was normal (average 0.62% in IPB when flying around the map) on my Intel Celeron E3200 (2.40 GHz) This PC only have a integrated video card with 128 MB dedicated video memory, so the only problem is the lower fps because a lot of objects drawed. (Tested on a green venturas map with the forest generator publiced by Essle ~ Total 2124 tree objects created) But yeah, this is a great work
- 27 replies
-
- 2
-
- repository
- draw
-
(and 8 more)
Tagged with:
-
fileDelete download the file and then delete (and not secure bc the file visible for 3-5 seconds while the server is still downloading), cache false not download the file but load it into the memory.
-
My res.: https://community.multitheftauto.com/index.php?p=resources&s=details&id=12624 Reuploaded: https://community.multitheftauto.com/?p=resources&s=details&id=15990 DONE
-
scorpionMTA started following Jayceon
-
Create one shader but replace multiple textures
Jayceon replied to Dzsozi (h03)'s topic in Scripting
Try this: texture cj_ped_torso; texture cj_ped_head; texture cj_ped_legs; texture cj_ped_feet; technique TexReplace { pass P0 { DepthBias = -0.0002; Texture[0] = cj_ped_torso; } pass P1 { DepthBias = -0.0002; Texture[0] = cj_ped_head; } pass P2 { DepthBias = -0.0002; Texture[0] = cj_ped_legs; } pass P3 { DepthBias = -0.0002; Texture[0] = cj_ped_feet; } } -
function getRandomSpawnPoint(cityName) if spawnPositions[cityName] then local realTime = getRealTime() math.randomseed(realTime.second + realTime.minute + realTime.hour) local minX = math.min(spawnPositions[cityName].minPos[1], spawnPositions[cityName].maxPos[1]) local minY = math.min(spawnPositions[cityName].minPos[2], spawnPositions[cityName].maxPos[2]) local maxX = math.max(spawnPositions[cityName].minPos[1], spawnPositions[cityName].maxPos[1]) local maxY = math.max(spawnPositions[cityName].minPos[2], spawnPositions[cityName].maxPos[2]) return math.random(minX, maxX), math.random(minY, maxY) end end
-
You need a color shader, or a renderTarget -> draw the texture image then draw one rectangle with the selected color -> create texture from the renderTarget pixels then destroy renderTarget. What did I say before? function changeTextureColor(textureElement, red, green, blue, alpha) local textureWidth, textureHeight = dxGetMaterialSize(textureElement) -- get the texture size local tempRenderTarget = dxCreateRenderTarget(textureWidth, textureHeight) -- create render target with texture size dxSetRenderTarget(tempRenderTarget) -- start rt dxDrawImage(0, 0, textureWidth, textureHeight, textureElement) -- draw the texture image to the rt dxDrawRectangle(0, 0, textureWidth, textureHeight, tocolor(red, green, blue, alpha)) -- draw the selected color rectangle to the rt -- you can add custom texts to texture etc.. dxSetRenderTarget() -- end rt local rt_pixels = dxConvertPixels(dxGetTexturePixels(tempRenderTarget), "png") -- get the rt pixels and convert to png destroyElement(tempRenderTarget) -- destroy rt because I converted to texture return dxCreateTexture(rt_pixels) -- return the new texture element end Or the shader way (I dont tested the shader): float red; float green; float blue; float alpha; technique colorChange { pass P0 { MaterialAmbient = float4(red, green, blue, alpha); } } -- You need to divide the r/g/b with 255 because shader color float range is 0-1. local selectedRed = 128 local selectedGreen = 64 local selectedBlue = 32 local selectedAlpha = 200 dxSetShaderValue(colorChangeShader, "red", selectedRed / 255) dxSetShaderValue(colorChangeShader, "green", selectedGreen / 255) dxSetShaderValue(colorChangeShader, "blue", selectedBlue / 255) dxSetShaderValue(colorChangeShader, "alpha", selectedAlpha / 255) -- then apply the shader to the world texture
-
I misunderstood.
-
local screenX, screenY = guiGetScreenSize() local repBarTexture = dxCreateTexture("reputation.png") local barWidth, barHeight = dxGetMaterialSize(repBarTexture) local maxRep = 200 local currentRep = 100 local repBarPosX = currentRep * (barWidth - 1) / maxRep local repBarPixels = dxGetTexturePixels(repBarTexture) local r, g, b = dxGetPixelColor(repBarPixels, math.floor(repBarPosX), barHeight / 2) outputChatBox("HEX: " .. string.format("#%.2X%.2X%.2X", r, g, b) .. ", R: " .. r .. ", G: " .. g .. ", B: " .. b) local barX = (screenX - barWidth) / 2 local barY = (screenY - barHeight) / 2 addEventHandler("onClientRender", getRootElement(), function () dxDrawImage(barX, barY, barWidth, barHeight, repBarTexture) dxDrawRectangle(barX + repBarPosX - 2, barY - 3, 4, barHeight + 6, tocolor(255, 255, 255)) end )
-
Like in Vice City camera/ped rotation? When you move your cursor the ped rotate by the camera.
-
Real function but only FROM VERSION 1.5.5 r13977 ONWARDS