Jump to content

مساعدة في كود الدخان


Recommended Posts

السلآم عليكم ورحمة الله وبركاته

اليوم صممت سيارة أملاك خاصة يعني

حاب أحط دخان لو يوصل للسرعة 10 يسوي الأوبجكت

ولو أقل من 10 يروح

سويت هالكود ما نفع

function D5( ) 
        local vehicle =  getPedOccupiedVehicle ( localPlayer ) 
        if ( vehicle ) then 
        local Speed = getElementSpeed ( vehicle,"kmh" ) 
            if ( Speed >= 9 ) then 
               local x,y,z = getElementPosition(vehicle) 
               local d5an = createObject ( 2780, x,y,z-2, 0, 0, 0 ) 
               attachElements (d5an,vehicle,0,-2,-1) 
        end 
    end 
end 

مع العلم أن السيارة هي اللي تحت

local C = createVehicle ( 565, 1797.2901611328, 841.5078125, 10.643834114075 )  

Link to comment
function D5() 
    local vehicle =  getPedOccupiedVehicle(localPlayer) 
    if vehicle then 
        local Speed = getElementSpeed(vehicle,"kmh") 
        if Speed >= 10 then 
            local x,y,z = getElementPosition(vehicle) 
            d5an = createObject(2780, x, y, z-2, 0, 0, 0) 
            attachElements(d5an, vehicle, 0, -2, -1) 
        else 
            if isElement(d5an) then 
                destroyElement(d5an) 
            end 
        end 
    end 
end 
  
addEventHandler("onClientVehicleEnter", root, 
    function(thePlayer, seat) 
        if seat == 0 then 
            updateTimer = setTimer(D5, 50, 0) 
        end 
    end 
) 
  
addEventHandler("onClientVehicleExit", root, 
    function(thePlayer, seat) 
        if seat == 0 then 
            if isTimer(updateTimer) then 
                killTimer(updateTimer) 
                updateTimer = nil 
            end 
        end 
    end 
) 

Link to comment
  
Sever Side ! 
    function D5() 
        local vehicle =  getPedOccupiedVehicle(source) 
        if vehicle then 
            local Speed = getElementSpeed(vehicle,"kmh") 
            if Speed >= 10 then 
                local x,y,z = getElementPosition(vehicle) 
                d5an = createObject(2780, x, y, z-2, 0, 0, 0) 
                attachElements(d5an, vehicle, 0, -2, -1) 
            else 
                if isElement(d5an) then 
                    destroyElement(d5an) 
                end 
            end 
        end 
    end 
      
    addEventHandler("onVehicleEnter", root, 
        function(thePlayer, seat) 
            if seat == 0 then 
                updateTimer = setTimer(D5, 50, 0) 
            end 
        end 
    ) 
      
    addEventHandler("onVehicleExit", root, 
        function(thePlayer, seat) 
            if seat == 0 then 
                if isTimer(updateTimer) then 
                    killTimer(updateTimer) 
                    updateTimer = nil 
                end 
            end 
        end 
    ) 
  

Link to comment
  
Sever Side ! 
    function D5() 
        local vehicle =  getPedOccupiedVehicle(source) 
        if vehicle then 
            local Speed = getElementSpeed(vehicle,"kmh") 
            if Speed >= 10 then 
                local x,y,z = getElementPosition(vehicle) 
                d5an = createObject(2780, x, y, z-2, 0, 0, 0) 
                attachElements(d5an, vehicle, 0, -2, -1) 
            else 
                if isElement(d5an) then 
                    destroyElement(d5an) 
                end 
            end 
        end 
    end 
      
    addEventHandler("onVehicleEnter", root, 
        function(thePlayer, seat) 
            if seat == 0 then 
                updateTimer = setTimer(D5, 50, 0) 
            end 
        end 
    ) 
      
  

وشو ؟ D5 العنصر في الوظيفة

Link to comment
local timers = {} 
local objects = {} 
  
function D5(vehicle, player) 
    local Speed = getElementSpeed(vehicle,"kmh") 
    if Speed >= 10 then 
        local x,y,z = getElementPosition(vehicle) 
        objects[player] = createObject(2780, x, y, z-2, 0, 0, 0) 
        attachElements(d5an, vehicle, 0, -2, -1) 
    else 
        if isElement(objects[player]) then 
            destroyElement(objects[player]) 
        end 
    end 
end 
  
addEventHandler("onVehicleEnter", root, 
    function(thePlayer, seat) 
        if seat == 0 then 
            timers[thePlayer] = setTimer(D5, 1000, 0, source, thePlayer) 
        end 
    end 
) 
  
addEventHandler("onVehicleExit", root, 
    function(thePlayer, seat) 
        if seat == 0 then 
            if isTimer(timers[thePlayer]) then 
                killTimer(timers[thePlayer]) 
                timers[thePlayer] = nil 
                destroyElement(objects[thePlayer]) 
            objects[thePlayer] = nil 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if isTimer(timers[source]) then 
            killTimer(timers[source]) 
            timers[source] = nil 
            destroyElement(objects[source]) 
            objects[source] = nil 
        end 
    end 
) 

Link to comment
local timers = {} 
local objects = {} 
  
function D5(vehicle, player) 
    local Speed = getElementSpeed(vehicle,"kmh") 
    if Speed >= 10 then 
        local x,y,z = getElementPosition(vehicle) 
        if isElement(objects[player]) then return end 
        objects[player] = createObject(2780, x, y, z-2, 0, 0, 0) 
        attachElements(objects[player], vehicle, 0, -2, -1) 
    else 
        if isElement(objects[player]) then 
            destroyElement(objects[player]) 
            objects[player] = nil 
        end 
    end 
end 
  
addEventHandler("onVehicleEnter", root, 
    function(thePlayer, seat) 
        if seat == 0 then 
            timers[thePlayer] = setTimer(D5, 1000, 0, source, thePlayer) 
        end 
    end 
) 
  
addEventHandler("onVehicleExit", root, 
    function(thePlayer, seat) 
        if seat == 0 then 
            if isTimer(timers[source]) then 
                killTimer(timers[source]) 
                timers[source] = nil 
                if isElement(objects[source]) then 
                    destroyElement(objects[source]) 
                    objects[source] = nil 
                end 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if isTimer(timers[source]) then 
            killTimer(timers[source]) 
            timers[source] = nil 
            if isElement(objects[source]) then 
                destroyElement(objects[source]) 
                objects[source] = nil 
            end 
        end 
    end 
) 

جربتها واشتغلت ^

Link to comment
local timers = {} 
local objects = {} 
  
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
function D5(vehicle, player) 
    local Speed = getElementSpeed(vehicle,"kmh") 
    if Speed >= 10 then 
        local x,y,z = getElementPosition(vehicle) 
        if isElement(objects[player]) then return end 
        objects[player] = createObject(2780, x, y, z-2, 0, 0, 0) 
        attachElements(objects[player], vehicle, 0, -2, -1) 
    else 
        if isElement(objects[player]) then 
            destroyElement(objects[player]) 
            objects[player] = nil 
        end 
    end 
end 
  
addEventHandler("onVehicleEnter", C, 
    function(thePlayer, seat) 
        if seat == 0 then 
            timers[thePlayer] = setTimer(D5, 1000, 0, source, thePlayer) 
        end 
    end 
) 
  
addEventHandler("onVehicleExit", C, 
    function(thePlayer, seat) 
        if seat == 0 then 
            if isTimer(timers[source]) then 
                killTimer(timers[source]) 
                timers[source] = nil 
                if isElement(objects[source]) then 
                    destroyElement(objects[source]) 
                    objects[source] = nil 
                end 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if isTimer(timers[source]) then 
            killTimer(timers[source]) 
            timers[source] = nil 
            if isElement(objects[source]) then 
                destroyElement(objects[source]) 
                objects[source] = nil 
            end 
        end 
    end 
) 

C جرب هذا وحطه تحت كود سيارة

Link to comment

طيب أبي الألمنت مخفي

يعني الدخان مخفي حاولت كذا ما زبط

function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 
  
function D5(vehicle, player) 
    local Speed = getElementSpeed(vehicle,"kmh") 
    if Speed >= 10 then 
        local x,y,z = getElementPosition(vehicle) 
        if isElement(objects[player]) then return end 
        objects[player] = createObject(2780, x, y, z-2, 0, 0, 0) 
        setElementAlpha ( objects[player], 0 ) 
        attachElements(objects[player], vehicle, 0, -2, -1) 
    else 
        if isElement(objects[player]) then 
            destroyElement(objects[player]) 
            objects[player] = nil 
        end 
    end 
end 
  
addEventHandler("onVehicleEnter", C, 
    function(thePlayer, seat) 
        if seat == 0 then 
            timers[thePlayer] = setTimer(D5, 1000, 0, source, thePlayer) 
        end 
    end 
) 
  
addEventHandler("onVehicleExit", C, 
    function(thePlayer, seat) 
        if seat == 0 then 
            if isTimer(timers[source]) then 
                killTimer(timers[source]) 
                timers[source] = nil 
                if isElement(objects[source]) then 
                    destroyElement(objects[source]) 
                    objects[source] = nil 
                end 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerQuit", root, 
    function() 
        if isTimer(timers[source]) then 
            killTimer(timers[source]) 
            timers[source] = nil 
            if isElement(objects[source]) then 
                destroyElement(objects[source]) 
                objects[source] = nil 
            end 
        end 
    end 
) 

Link to comment

بدل هذي بالاخرى

function D5(vehicle, player) 
    local Speed = getElementSpeed(vehicle,"kmh") 
    if Speed >= 10 then 
        local x,y,z = getElementPosition(vehicle) 
        if isElement(objects[player]) then return end 
        objects[player] = createObject(2780, x, y, z-2, 0, 0, 0) 
        setElementAlpha(objects[player], 0.0) 
        attachElements(objects[player], vehicle, 0, -2, -1) 
    else 
        if isElement(objects[player]) then 
            destroyElement(objects[player]) 
            objects[player] = nil 
        end 
    end 
end 

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