Jump to content

Why not working this script?


Turbe$Z

Recommended Posts

-- client --

local w, h = guiGetScreenSize ()
local destroyTime
local asd = 0.138
local target
local localPlayer = getLocalPlayer ()
local allowed = true
addEvent ( "allowIt", true )
addEventHandler ( "allowIt", root,
    function ( element )
        allowed = true
    end )

addEventHandler ( "onClientPlayerWeaponFire", localPlayer,
    function ( weapon, _, _, _, _, _, element )
        if not element or not allowed then return end
        if weapon == 23 then
            target = element
            if not destroyTime then
                addEventHandler ( "onClientRender", root, drawProgress )
            end
            destroyTime = getTickCount ()
        end
    end )

function drawProgress ()
    if not getPedTarget ( localPlayer ) then
        destroyTime = nil
        target = nil
        removeEventHandler ( "onClientRender", root, drawProgress )
    end
    local prog = getTickCount () - ( destroyTime or getTickCount () )
    if prog > 1000 then
    triggerServerEvent ( "destroyIt", localPlayer, target )
        destroyTime = nil
        target = nil
        removeEventHandler ( "onClientRender", root, drawProgress )
    end
    
    local w2, h2 = math.floor ( w/2 ), math.floor ( h/2 )
    dxDrawLine ( w2 - 72, h2 - 6, w2 - 72, h2 + 6 )
    dxDrawLine ( w2 + 72, h2 - 6, w2 + 72, h2 + 6 )
    dxDrawRectangle ( w2 - 69, h2 - 6, prog * asd, 12 )
end

-- server --

function destroyIt (target)
destroyElement(source, target)
end
addEvent( "destroyIt", true )
addEventHandler( "destroyIt", root, destroyIt )

no warnings / errors...

Edited by Turbo777
Link to comment
3 minutes ago, MR.S3D said:

try with this

 

server

 


function destroyIt (target)	if getElementType(target) == "player" then return end	destroyElement(target)endaddEvent( "destroyIt", true )addEventHandler( "destroyIt", root, destroyIt )

 

Thanks maan :DDDDDD

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