Jump to content

[Help] Roadblock destroy problem


SAbJaN

Recommended Posts

Hey

I try use this command and it dont work.. Is it correct?

CLIENT SIDE

function destroy(source, cmd) 
    local px, py, pz = getElementPosition(getLocalPlayer()) 
    local rx, ry, rz = getElementRotation(getLocalPlayer()) 
    local tz, ty = getPointFromDistanceRotation(x, y, 2, rz) 
    local hit, hitX, hitY, hitZ, hitlineElement, normalX, normalY, normalZ = processLineOfSight(px, py, pz, tx, ty, pz+5, true, true, false, true, false, true, false, true, getLocalPlayer()) 
    if isElement(hitlineElement) then 
        if getElementModel(hitlineElement) == 979 then 
            triggerServerEvent ("destroyRoadblock", getLocalPlayer(), hitlineElement ) 
        end 
    end 
end 
addCommandHandler("destroyroadblock", destroy) 
  
function getPointFromDistanceRotation(x, y, dist, angle) 
  
    local a = math.rad(90 - angle); 
  
    local dx = math.cos(a) * dist; 
    local dy = math.sin(a) * dist; 
  
    return x+dx, y+dy; 
  
end 

Serverside

addEvent("destroyRoadblock", true) 
function destroyRoadblock() 
    destroyElement(roadblock) 
    end 
addEventHandler("destroyRoadblock", root, destroyRoadblock) 

Link to comment
function getPointFromDistanceRotation(x, y, dist, angle) 
    local a = math.rad(90 - angle); 
    local dx = math.cos(a) * dist; 
    local dy = math.sin(a) * dist; 
    return x+dx, y+dy; 
end 
  
function destroy( ) 
    local px, py, pz = getElementPosition( localPlayer ) 
    local rx, ry, rz = getElementRotation( localPlayer ) 
    local tz, ty = getPointFromDistanceRotation( x, y, 2, rz ) 
    local hit, hitX, hitY, hitZ, hitlineElement, normalX, normalY, normalZ =  
    processLineOfSight( px, py, pz, tx, ty, pz+5,true, true, false, true, false, true, false, true, localPlayer ) 
    if isElement( hitlineElement ) then 
        if getElementModel( hitlineElement ) == 979 then 
            triggerServerEvent ( "destroyRoadblock", localPlayer, hitlineElement ) 
        end 
    end 
end 
addCommandHandler( "destroyroadblock", destroy ) 

  
addEvent( "destroyRoadblock", true ) 
function destroyRoadblock( hitlineElement ) 
    destroyElement( hitlineElement ) 
end 
addEventHandler( "destroyRoadblock", root, destroyRoadblock ) 

Link to comment

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...