Jump to content

I can't verify vehicle's id [HELP!]


Murilo_apa

Recommended Posts

I can't verify if the vehicle's id is the same as the spawned one and if it's going to destroy it!

addEvent('onPlayerRequestSpawnV', true)
addEventHandler('onPlayerRequestSpawnV', root, function(vid)
    local x,y,z = getElementPosition(source);
    local _,_,r = getElementRotation(source);
    local spawnedV = getElementData(source, 'conce.garagem.spawneds') or {};
    for i,v in ipairs(spawnedV) do
        if i.vidC == vid then
            if i.vh and isElement(i.vh) then
                destroyElement(i.vh)
                return false;
            end
        end  
    end

    vehicleSV = createVehicle(vid, x,y,z,_,_,r)
    warpPedIntoVehicle(source, vehicleSV)
    table.insert(spawnedV, {vidC = vid, vh = vehicleSV})

end);

This is my current code...

 
 
Link to comment
addEvent('onPlayerRequestSpawnV', true)
addEventHandler('onPlayerRequestSpawnV', root, function(vid)
    local x,y,z = getElementPosition(source);
    local _,_,r = getElementRotation(source);
    local spawnedV = getElementData(source, 'conce.garagem.spawneds') or {};
    for i,v in ipairs(spawnedV) do
        if v.vidC == vid then
            if v.vh and isElement(v.vh) then
                destroyElement(v.vh)
                return false;
            end
        end  
    end

    vehicleSV = createVehicle(vid, x,y,z,_,_,r)
    warpPedIntoVehicle(source, vehicleSV)
    table.insert(spawnedV, {vidC = vid, vh = vehicleSV})

end);

Hm..

Link to comment
addEvent('onPlayerRequestSpawnV', true)
addEventHandler('onPlayerRequestSpawnV', root, function(vid)
    local x,y,z = getElementPosition(source);
    local _,_,r = getElementRotation(source);
    local spawnedV = getElementData(source, 'conce.garagem.spawneds') or {};
    for i,v in ipairs(spawnedV) do
        if v.vidC == vid then
            if v.vh and isElement(v.vh) then
                destroyElement(v.vh)
                return false;
            end
        end  
    end

    vehicleSV = createVehicle(vid, x,y,z,_,_,r)
    warpPedIntoVehicle(source, vehicleSV)
    table.insert(spawnedV, {vidC = vid, vh = vehicleSV})

end);

 

Link to comment
4 hours ago, Murilo_apa said:

it dont work! i don't undertand :/

addEvent('onPlayerRequestSpawnV', true)
addEventHandler('onPlayerRequestSpawnV', root, function(vid)
    local x,y,z = getElementPosition(source);
    local _,_,r = getElementRotation(source);
    local spawnedV = getElementData(source, 'conce.garagem.spawneds') or {};
    for i,v in ipairs(spawnedV) do
        if v.vidC == vid then
            if v.vh and isElement(v.vh) then
                destroyElement(v.vh)
                return false;
            end
        end  
    end

    vehicleSV = createVehicle(vid, x,y,z,_,_,r)
    warpPedIntoVehicle(source, vehicleSV)
    table.insert(spawnedV, {vidC = vid, vh = vehicleSV})
    setElementData(source, 'conce.garagem.spawneds', spawnedV)
end);

Try this

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