Jump to content

How to do that?


Recommended Posts

  • Moderators

This maybe?

Animation probably created by increasing the material line and changing the offZet.

  
local PosX= ... 
local PosY= ... 
local PosZ= ... 
  
local offZetX1 = PosX+10 
local offZetY1 = PosY+10 
  
local offZetX2 = PosX-10 
local offZetY2 = PosY-10 
  
dxDrawMaterialLine3D ( offZetX1, offZetY1, PosZ, offZetX2,offZetY2, PosZ,material, 10) 

Link to comment

Okay, so I used dxDrawMaterialLine3D but I've a problem. We can't do rotation on the element? I mean, in the video, the thing is on the floor like rotation in 90°. In my script, it's in 0.

Possible?

3CWzX.jpg

My code:

function ckl ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
    if button == "left" and state == "down" then 
        local img = dxCreateTexture("img.png") 
        addEventHandler("onClientPreRender", getRootElement(), 
        function() 
            dxDrawMaterialLine3D ( worldX, worldY, worldZ,worldX, worldY, worldZ+10, img,  10, tocolor(255, 255, 255, 255), 0, 0, 0) 
        end) 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), ckl ) 
  

Link to comment
  • Moderators

It can, by changing the coordinates of the start and end.

You have the middle point, you create offset from there.

And you let the offset locations move around the middle point.

I hope you have learned to work with tables, because these are the one you need to manage for more then one icon.

At the moment your code is creating for every click a new event, that will start lagging and next to that it isn't manage able cause you can't stop it without turning off the script.

@ 6ArHxiMr'3a[Z]eF

Use what you have, to reason to create hundred of images for just one effect.

All you need is math to do the job.

Link to comment
It can, by changing the coordinates of the start and end.

You have the middle point, you create offset from there.

And you let the offset locations move around the middle point.

I hope you have learned to work with tables, because these are the one you need to manage for more then one icon.

At the moment your code is creating for every click a new event, that will start lagging and next to that it isn't manage able cause you can't stop it without turning off the script.

@ 6ArHxiMr'3a[Z]eF

Use what you have, to reason to create hundred of images for just one effect.

All you need is math to do the job.

Well, I try to edit the coordinates but I can't find for this rotation.

code:

Elements = {} 
img = dxCreateTexture("img.png") 
  
addEventHandler("onClientRender", getRootElement(), 
function() 
    for i, k in ipairs(Elements)do 
        dxDrawMaterialLine3D ( k.x, k.y, k.z, k.lx, k.ly, k.lz, img,  10, tocolor(255, 255, 255, 255), 0, 0, 0) 
    end 
end) 
  
function ckl ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
    if button == "left" and state == "down" then 
        local temp = {} 
        temp.x = worldX; 
        temp.y = worldY; 
        temp.z = worldZ; 
        temp.lx = worldX; 
        temp.ly = worldY; 
        temp.lz = worldZ; 
         
        table.insert(Elements, temp) 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), ckl ) 
  

Look:

  
temp.x = worldX; 
        temp.y = worldY; 
        temp.z = worldZ; 
        temp.lx = worldX+10; 
        temp.ly = worldY; 
        temp.lz = worldZ; 
  

3CXBc.jpg

  
temp.x = worldX; 
        temp.y = worldY; 
        temp.z = worldZ; 
        temp.lx = worldX; 
        temp.ly = worldY+10; 
        temp.lz = worldZ; 
  

3CXDM.jpg

  
temp.x = worldX; 
        temp.y = worldY; 
        temp.z = worldZ; 
        temp.lx = worldX; 
        temp.ly = worldY; 
        temp.lz = worldZ+10; 
  

3CXIm.jpg

I really don't undestand how this works.

Link to comment
local material = dxCreateTexture( "Medic.png" ) 
local x, y, z = 0, 0, 0 
  
addEventHandler( "onClientRender", root, 
    function() 
        dxDrawMaterialLine3D( x, y, z, x, y + 5, z +.05, material, 5, tocolor( 255,255,255,255 ), x, y, z + 1) 
    end 
) 
  
addCommandHandler( "aca",  
    function( ) 
        x, y, sz = getElementPosition( localPlayer ) 
        z = getGroundPosition( x, y, sz ) 
    end 
) 

faceTowardX/Y/Z: The direction the front of the line should face towards. If this is not set, the front of the line always faces toward the camera.

mta_screen_2013_07_14_18_28_45.png

Link to comment

dxDrawMaterialLine3D has facing direction parameters (last 3 params) which you can use to make the rotation. Your example shows the facing coords is the middle of the San Andreas (0.0, 0.0, 0.0). If you want it to face up, then use the same coords of the placement with exception of Z being higher.

float faceTowardX, float faceTowardY, float faceTowardZ 

Example:

dxDrawMaterialLine3D ( k.x, k.y, k.z, k.lx, k.ly, k.lz, img,  10, tocolor(255, 255, 255, 255), k.x, k.y, k.z+1) 

As you can see, I used the same coords for facing as the "start" coords but I added +1 to Z, which will make the material face UP the Z axis.

Link to comment
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...