Jump to content

مشكلة في addEvent


Recommended Posts

انا عملت الكود دا لما تيجي تدوس على  button اسمها Engine On / Off المحرك  بتاع السيارة بيطفا و لما دوس كليك عليه تاني بشتغل المحرك بس الكود دا فيه غلط علشان خرب لوحة السيارة 

addEvent( 'VehiclesSystem;off/onPersonalVehicle', true )
addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root,
function switchEngine ( playerSource )
    local theVehicle = getPedOccupiedVehicle ( playerSource )

    -- Check if the player is in any vehicle and if he is the driver
    if theVehicle and getVehicleController ( theVehicle ) == playerSource then
        local state = getVehicleEngineState ( theVehicle )
        setVehicleEngineState ( theVehicle, not state )
    end
end
end
)

الأصلي 

function turnEngineOff ( theVehicle, leftSeat, jackerPlayer )
    -- if it's the driver who got out, and he was not jacked,
    if leftSeat == 0 and not jackerPlayer then
        -- turn off the engine
        setVehicleEngineState ( theVehicle, false )
    end
end
-- add 'turnEngineOff' as a handler for "onPlayerExitVehicle"
addEventHandler ( "onPlayerVehicleExit", getRootElement ( ), turnEngineOff )

 

Link to comment
3 minutes ago, Abdul KariM said:

switchEngine  سطر 3 شيل 

وجرب


function switchEngine ( playerSource )
    local theVehicle = getPedOccupiedVehicle ( playerSource )

    -- Check if the player is in any vehicle and if he is the driver
    if theVehicle and getVehicleController ( theVehicle ) == playerSource then
        local state = getVehicleEngineState ( theVehicle )
        setVehicleEngineState ( theVehicle, not state )
    end
end
end
addEvent( 'VehiclesSystem;off/onPersonalVehicle', true )
addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root, switchEngine)

 

Link to comment
19 hours ago, coNolel said:


function switchEngine ( playerSource )
    local theVehicle = getPedOccupiedVehicle ( playerSource )

    -- Check if the player is in any vehicle and if he is the driver
    if theVehicle and getVehicleController ( theVehicle ) == playerSource then
        local state = getVehicleEngineState ( theVehicle )
        setVehicleEngineState ( theVehicle, not state )
    end
end
end
addEvent( 'VehiclesSystem;off/onPersonalVehicle', true )
addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root, switchEngine)

 

غلط مش رادي يشتغل

20 hours ago, #ZA7F //= said:

وضح لي المشكلة بالضبط ما فهمت !

انا عملت كود يقدر يخليك طفي محرك السيارة و تشغل بضغطة زر 
المشكلة لما تضغط ، المحرك يبقا شغال ، يعني الكود مش شغال فيه مشكلة 
انا عايز اخلي الكود شغال يعني لما اجي اضغط على الزر المحرك بيطفا و لما اضغط تاني بيشتغل المحرك 

reVty7w.png

Edited by Droam|Oussez
Link to comment
addEvent( 'VehiclesSystem;off/onPersonalVehicle', true )
addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root,
function switchEngine ()
local theVehicle = getPedOccupiedVehicle (source)
-- Check if the player is in any vehicle and if he is the driver
if theVehicle and getVehicleController (theVehicle) == source then
local state = getVehicleEngineState ( theVehicle )
if state == false then 
setVehicleEngineState (theVehicle,true)
else
setVehicleEngineState (theVehicle,false)
end
end
end
)

 

Link to comment
44 minutes ago, Ahmed Ly said:

addEvent( 'VehiclesSystem;off/onPersonalVehicle', true )
addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root,
function switchEngine ()
local theVehicle = getPedOccupiedVehicle (source)
-- Check if the player is in any vehicle and if he is the driver
if theVehicle and getVehicleController (theVehicle) == source then
local state = getVehicleEngineState ( theVehicle )
if state == false then 
setVehicleEngineState (theVehicle,true)
else
setVehicleEngineState (theVehicle,false)
end
end
end
)

 

مش شغال 

iT8jheO.png

Link to comment

طيب انا عايز اعمل  outputchatbox لما تضغط على  Engine On المحرك بيشتغل و بيجيلك في الشات  [Vehicle SySTEM] Engine on و لما تضغط تاني المحرك بيطفا و بيجيلك في  الشات [Vehicle SySTEM] Engine off

Link to comment
Just now, Droam|Oussez said:

طيب انا عايز اعمل  outputchatbox لما تضغط على  Engine On المحرك بيشتغل و بيجيلك في الشات  [Vehicle SySTEM] Engine on و لما تضغط تاني المحرك بيطفا و بيجيلك في  الشات [Vehicle SySTEM] Engine off

شكلي بفتح الكمبيوتر مخصوص :D

Link to comment
addEvent( 'VehiclesSystem;off/onPersonalVehicle', true )
addEventHandler( 'VehiclesSystem;off/onPersonalVehicle', root,
function  ()
local theVehicle = getPedOccupiedVehicle (source)
-- Check if the player is in any vehicle and if he is the driver
if theVehicle and getVehicleController (theVehicle) == source then
local state = getVehicleEngineState ( theVehicle )
if state == false then 
setVehicleEngineState (theVehicle,true)
outputChatBox("[Vehicle SySTEM] Engine on ",source,0,255,0,true)
else
setVehicleEngineState (theVehicle,false)
outputChatBox("[Vehicle SySTEM] Engine off ",source,0,255,0,true)
end
end
end
)

 

Link to comment
addEvent("FixMyVehicle", true)
addEventHandler("FixMyVehicle", root, 
function(id)
    if (getElementData(source, "Money") or 0) >= tonumber(5000) then
        setElementData(source, "Money", getElementData(source, "Money") - 5000)
        local vehicle = getVehicleByID(id)
        if isElement(vehicle) then
            fixVehicle(vehicle)
            setVehicleEngineState(vehicle, true)
            if isVehicleDamageProof(vehicle) then
                setVehicleDamageProof(vehicle, false)
            end
        end
        dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND ID = ?", 1000, getAccountName(getPlayerAccount(source)), id)
        updateVehicleInfo(source)
        exports["Notice"]:outputNotice(source,"#58FAF4Your Vehicle #00FF00has been fixed.", "success", true)
outButDxChat ("[Vehicle System] #58FAF4Your Vehicle #00FF00has been fixed.", source, 255, 85, 0, true)
    else
        exports["Notice"]:outputNotice(source,"#FF0000You don't have enough money to fix the vehicle.", "error", true)
outButDxChat ("[Vehicle System] #FF0000You don't have enough money to fix the vehicle.", source, 255, 85, 0, true)
    end
end)

جديدة لما تكون عاوز تصلح السيارة و هي مش موجودة معاك outButDxChat عايز احط  

else
outButDxChat ("[Vehicle System] #FF0000Your vehicle is not spawned", source, 255, 85, 0, true)

لو حطتها ، السكريبت مش بيشتغل ايه هو الغلط ؟

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