Jump to content

Gaimo

Members
  • Posts

    209
  • Joined

  • Last visited

Posts posted by Gaimo

  1. I'm creating a zipline resource, and I'd like to know how to create a rope between two points, any ideas? I remember seeing a resource for a gas station, where there was a hose that changed size dynamically.
     

    Resource: zipline 

    I don't know if it's a smart option, but I can make some models with fixed sizes, 10 meters, 5 meters, 2 meters and 1 meter.

    Depending on the distance, I calculate how many objects I need to create and create them in sequence.

    Example 23 meters away, 2x10m + 2m + 1m.

    What do you think?

  2.  

    I have the following problem, I need the blip to be stuck to the edge of the radar.

    Spoiler

    unknown.pngunknown.png

    Spoiler
    function drawBlip(posX, posY, size, texture, color, visibleDistance)
    	-- @description: Draw a blip
    	-- @implementation version: Alpha
    
    	-- @param: {posX} (Float) Blip X position.
    	-- @param: {posY} (Float) Blip Y position.
    	-- @param: {size} (Int) Blip size.
    	-- @param: {texture} (Texture) Blip texture.
    	-- @param: {color} (Color) Blip color.
    	-- @param: {visibleDistance} (Float) Maximum distance the blip should be rendered.
    
    	-- @return: No return.
    	-- @example: createCustomBlip(50,0, 10, nil, tocolor(0,255,0,255), 300)
    
    	local distance = getDistanceBetweenPoints2D(posX, posY, playerPosition.x, playerPosition.y)
    	
    	--Avoid rendering blips that are not in the player's view.
    	if distance > visibleDistance then return end 
    
    	local radarCenter = getRadarCenter()
    	local radarFix = 2.5
    	local blipDistance = Vector2((posX - playerPosition.x), (posY - playerPosition.y))
    	local x,y = ( blipDistance.x / radarFix), ( blipDistance.y / radarFix ) 
    	local position = Vector2(
    		radarCenter.x - (size/2) + x,
    		radarCenter.y - (size/2) - y
    	)
    
    	dxDrawImage(position.x, position.y, size, size, texture, camRot, -x, y, color)
    end

    I know I need to do some sort of math.clump, to prevent the blip from rendering outside of the minimap's border
     

    function math.clamp( _in, low, high )
    	return math.min( math.max( _in, low ), high )
    end

    I performed some tests and almost succeeded, however, I'm not sure if the way I implemented to position the blips was the most efficient.


    How does the radar work?
    It is based on shader_hud_mask, and it is rendered like this:
     

    Spoiler
    local radar = {
    	currentShape = "circle",
    	zoom = 8,
    	arrowSize = 16,
    }
    
    radar.square = {}
    radar.square.size = Vector2(300, 200)
    radar.square.position = Vector2(10, SH - radar.square.size.y - 10)
    
    radar.circle = {}
    radar.circle.size = Vector2(300, 300)
    radar.circle.position = Vector2(10, SH - radar.circle.size.y - 10)
    
    function drawMinimap()
    	playerPosition = Vector2(getElementPosition(localPlayer))
    	_,_,camRot = getElementRotation(getCamera())
    	_,_,playerRot = getElementRotation(localPlayer)
    
    	-- Transform world x,y into -0.5 to 0.5
    	local x,y = playerPosition.x, playerPosition.y
    	x = ( x ) / 6000
    	y = ( y ) / -6000
    	dxSetShaderValue( SHADER_MASK, "gUVPosition", x,y )
    
    	local radarCenter = getRadarCenter()
    
    	if radar.currentShape == "circle" then 
    		dxSetShaderValue( SHADER_MASK, "gUVScale", 1/radar.zoom, 1/radar.zoom )
    
    		dxDrawImage( radar.circle.position.x, radar.circle.position.y, radar.circle.size.x, radar.circle.size.y, SHADER_MASK, camRot,0,0)
    		drawBlips()
    		dxDrawImage(radar.circle.position.x, radar.circle.position.y, radar.circle.size.x, radar.circle.size.y, TEXTURE_OUTLINE_CIRCLE)
    		dxDrawImage(radarCenter.x - (radar.arrowSize/2), radarCenter.y - (radar.arrowSize/2), radar.arrowSize, radar.arrowSize, TEXTURE_ARROW, camRot - playerRot)
    	else -- Square
    		dxSetShaderValue( SHADER_MASK, "gUVScale", 1/radar.zoom, 0.667/radar.zoom )
    		dxSetShaderValue( SHADER_MASK, "gUVRotAngle", math.rad(-camRot) )
    
    		dxDrawImage(radar.square.position.x, radar.square.position.y, radar.square.size.x, radar.square.size.y, SHADER_MASK, 0,0,0)
    		drawBlips()
    		dxDrawImage(radar.square.position.x, radar.square.position.y, radar.square.size.x, radar.square.size.y, TEXTURE_OUTLINE_SQUARE)
    		dxDrawImage(radarCenter.x - (radar.arrowSize/2), radarCenter.y - (radar.arrowSize/2), radar.arrowSize, radar.arrowSize, TEXTURE_ARROW, camRot - playerRot)
    	end
    end

     

    Any idea how I can do this?

  3. Add kick animation - Any animation suggestions, I don't know how to create animations.
    Add a power bar - This one is good for changing the ball's distance.
    Add a way to guide the ball while running - This one I don't exactly know how to do.

    why don't you share your ressource on the mta community ? 

    I'm too lazy to put the information in meta.xml

    I use Google Translate.

  4. All function related to physics are unavailable yet right?

     

    local terrainData = {
      3,3,3,3,
      3,0,0,3,
      3,0,0,3,
      3,3,3,3,
    }
    local terrainShape = physicsCreateShape(physics, "heightfieldterrain", 4,4, terrainData)
    local terrain = physicsCreateStaticCollision(terrainShape)
    physicsSetProperties(terrain, "position", 0,0,5)
    physicsSetProperties(terrain, "scale", 5,5,1) -- in terrain, sets mesh density, now mesh has size 20x20units, one vertex every 5 units


    With this script plus shader it would be possible to create custom terrains, right?

  5. local tick = getTickCount()
    local delay = 150 -- ms
    local jump = false
    
    addEventHandler("onClientRender", root, function()
        if getTickCount() - tick > delay then
            
            if getPedControlState(localPlayer, "jump") and not jump then
                outputChatBox("jump")
                jump = true
            elseif not getPedControlState(localPlayer, "jump") and jump then
                jump = false
            end
    
            tick = getTickCount()
        end
    end)

    So you can detect, regardless of the key that the player presses.

    • Like 1
  6. local function removeShadow(vehicle)
    
        local shader = dxCreateShader("files/replace.fx", 0, 0, false, "vehicle")
        local texture = dxCreateTexture("files/remove.png")
    
        dxSetShaderValue(shader, "gTexture", texture)
        engineApplyShaderToWorldTexture(shader, "shad_car", vehicle)
    end

    and

    local function removeShadow(vehicle)
    
        local shader = dxCreateShader("files/replace.fx", 0, 0, false)
        local texture = dxCreateTexture("files/remove.png")
    
        dxSetShaderValue(shader, "gTexture", texture)
        engineApplyShaderToWorldTexture(shader, "shad_car", localPlayer)
    end

    Neither worked, I want to remove the shadow of a specific vehicle, not all.
    The texture name of the shadow I know is "shad_car"

    And this replace shader works because I used it in other things, I just don't understand why it didn't work for the shade.

    Any solution?

  7.  

    My voice resource is this https://community.multitheftauto.com/index.php?p=resources&s=details&id=15958

    I couldn't test it, but does it work?

    CLIENT-SIDE:

    addEventHandler("onClientElementStreamIn", root,
        function ()
            if source:getType() == "player" then
    
                if getElementData(source, "call") then return end
    
                triggerServerEvent("proximity-voice::broadcastUpdate", localPlayer, getElementsByType("player", root, true))
            end
        end
    )
    
    addEventHandler("onClientElementStreamOut", root,
        function ()
            if source:getType() == "player" then
    
                if getElementData(source, "call") then return end
    
                triggerServerEvent("proximity-voice::broadcastUpdate", localPlayer, getElementsByType("player", root, true))
                setSoundPan(source, 0)
                setSoundVolume(source, 0)
            end
        end
    )



    SERVER-SIDE:

    addCommandHandler("call", function(plr, cmd, target)
    
        local target = getPlayerFromPartialName(target) -- return a player
    
        setElementData(plr, "call", true)
        setElementData(target, "call", true)
    
        setPlayerVoiceBroadcastTo(plr, target)
        setPlayerVoiceBroadcastTo(target, plr)
    
    end)
  8. A simple vehicle alarm system.

    I accept suggestions for improvements.

    Demo: 

    NOTE: It is only possible to open the dashboard after you leave a vehicle as a driver.

    [Download]

    UPDATE #1 - Fixed an issue that the menu was not open.

  9. Spoiler

    spacer.png

    spacer.png

    Code:
     

    local obj
    local shader = dxCreateShader("shader.fx", 0, 0, false) 
    
    function positioning()
        local x,y,z = getPositionFromElementOffset(localPlayer, 0, 1.2, 0)
        local rx,ry,rz = getElementRotation(localPlayer)
    
        setElementPosition(obj, x,y,z)
        setElementRotation(obj, rx,ry,rz)
            
    
    end
    
    function setItemPosition(button, press)
        if button == "mouse1" and press then
    
            setElementAlpha(obj, 255)
            setElementCollisionsEnabled(obj, true)
            engineApplyShaderToWorldTexture(shader, "crate128") 
            dxSetShaderValue(shader, "gColor", 255, 255, 255, 255) 
    
            removeEventHandler("onClientRender",root, positioning)
            removeEventHandler("onClientKey",root, setItemPosition)
            
        end
    
    end
    
    function getPositionFromElementOffset(element,offX,offY,offZ)
        local m = getElementMatrix ( element )  -- Get the matrix
        local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform
        local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]
        local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]
        return x, y, z                               -- Return the transformed point
    end
    
    
    addCommandHandler("criar", function()
    
        local x,y,z = getPositionFromElementOffset(localPlayer, 0, 1.2, 0)
        local rx,ry,rz = getElementRotation(localPlayer)
        obj = createObject(1224, x,y,z,rx,ry,rz)
    
        setElementAlpha(obj, 141)
        setElementCollisionsEnabled(obj, false)
    
        engineApplyShaderToWorldTexture(shader, "crate128") 
        dxSetShaderValue(shader, "gColor", 0, 255, 0, 200) 
    
    
    
        addEventHandler("onClientRender",root, positioning)
        addEventHandler("onClientKey",root, setItemPosition)
    
    end)

    Error:

    spacer.png

    I am starting the script and this warning already appears.

    shader line 13,9 -> sampler Sampler0 = sampler_state 

  10. 49 minutes ago, SpecT said:

    ‎Esta é uma espécie de limitação GTA:SA. Existem mods (para GTA:SA) que podem remover essa limitação, mas sem mods eu não acho que seja possível no MTA.‎

    You can create a ped and warp it in the vehicle and use setPedAnalogControlState to turn to the last known direction by the player BUT warpPedIntoVehicle only works with client created peds and vehicles (those are not seen by the other players).
    Sooo it seems impossible.

    ‎Você poderia escrever isso ‎‎aqui‎‎ como um problema, mas eu não sei se eles vão se importar com isso. ‎

    I think the easiest thing would be to add a ped with alpha 0 and remove it when the player enters.

    9 minutes ago, JustinMTA said:

    ‎Eu poderia tentar separar o volante como um componente separado, permitindo que você faça engenharia reversa de todo o processo do zero.. Eu poderia até adicionar uma roda 3D para você. ‎
    ‎ Adicione-me em Discord ou Telegram, o nome está na minha assinatura. ‎

    I don't know if I would know how to do this reverse engineering.

×
×
  • Create New...