Jump to content

destroyElement poblem


Fabioxps

Recommended Posts

I'm using this event in my RACE

triggerClientEvent("showNextMapTextx",getRootElement()) 

just me on the server works perfect when you have more people creates many vehicles and destroy function does not work

Client Side

local peds = {} 
  
function asd() 
  triggerServerEvent( "onCameraStartz",getRootElement(), inici) 
  addEventHandler("onClientRender",root,camera) 
        setTimer ( 
        function() 
                   removeEventHandler("onClientRender",root,camera) 
        end 
    ,4000,1) 
end 
addEvent("showNextMapTextx",true) 
addEventHandler("showNextMapTextx",getRootElement(),asd) 
  
function camera ( ) 
    for ped,veh in pairs(peds)do 
        local x, y, z = getElementPosition(veh) 
        setCameraMatrix(x+12, y+11, z+4, x, y, z) 
    end 
end 
  
  
function cameraStarts(ped1) 
    setPedControlState(ped1,"accelerate",true) 
    setTimer(function() setPedControlState(ped1,"accelerate",false) end,800,1) 
    car1 = getPedOccupiedVehicle(ped1) 
    if not peds[ped1] then 
        peds[ped1] = car1 
    end 
end 
addEvent( "onCameraStart", true ) 
addEventHandler( "onCameraStart",root, cameraStarts ) 
  
  
  

Server Side

addEvent("onCameraStartz",true) 
addEventHandler("onCameraStartz",getRootElement(), 
function() 
    ped1 = createPed(0, 138.70454406738, 2491.1267089844, 16.484375) 
    car1 = createVehicle(411, -73.699996948242, 2506.3999023438, 16.299999237061,0,0,270) 
    warpPedIntoVehicle ( ped1, car1 ,0 ) 
    triggerClientEvent("onCameraStart",root, ped1, car1) 
setTimer( 
    function() 
              destroyElement(car1) 
              destroyElement(ped1) 
    end 
,5000,1) 
end) 
  
  
  

from already thank you

Link to comment

try this:

Client:

local peds = {} 
  
function camera ( ) 
    for _,ped in ipairs(peds)do 
        local x, y, z = getElementPosition(peds[ped]) 
        setCameraMatrix(x+12, y+11, z+4, x, y, z) 
    end 
    removeEventHandler("onClientRender",root,camera) 
end 
  
addEvent("showNextMapTextx",true) 
addEventHandler("showNextMapTextx",root,function() 
  triggerServerEvent("onCameraStartz",root) 
  addEventHandler("onClientRender",root,camera) 
end) 
  
addEvent( "onCameraStart", true ) 
addEventHandler( "onCameraStart",root,function(ped1,car1) 
    setPedControlState(ped1,"accelerate",true) 
    setTimer(setPedControlState,800,1,ped1,"accelerate",false) 
    if not peds[ped1] then 
        peds[ped1] = car1 
    end 
end) 

Server:

addEvent("onCameraStartz",true) 
addEventHandler("onCameraStartz",root,function() 
    local ped1 = createPed(0, 138.70454406738, 2491.1267089844, 16.484375) 
    local car1 = createVehicle(411, -73.699996948242, 2506.3999023438, 16.299999237061,0,0,270) 
    warpPedIntoVehicle ( ped1, car1) 
    triggerClientEvent("onCameraStart",root, ped1, car1) 
    setTimer(function() 
        destroyElement(car1) 
        destroyElement(ped1) 
    end,5000,1) 
end) 

Link to comment
try this:

Client:

local peds = {} 
  
function camera ( ) 
    for _,ped in ipairs(peds)do 
        local x, y, z = getElementPosition(peds[ped]) 
        setCameraMatrix(x+12, y+11, z+4, x, y, z) 
    end 
    removeEventHandler("onClientRender",root,camera) 
end 
  
addEvent("showNextMapTextx",true) 
addEventHandler("showNextMapTextx",root,function() 
  triggerServerEvent("onCameraStartz",root) 
  addEventHandler("onClientRender",root,camera) 
end) 
  
addEvent( "onCameraStart", true ) 
addEventHandler( "onCameraStart",root,function(ped1,car1) 
    setPedControlState(ped1,"accelerate",true) 
    setTimer(setPedControlState,800,1,ped1,"accelerate",false) 
    if not peds[ped1] then 
        peds[ped1] = car1 
    end 
end) 

Server:

addEvent("onCameraStartz",true) 
addEventHandler("onCameraStartz",root,function() 
    local ped1 = createPed(0, 138.70454406738, 2491.1267089844, 16.484375) 
    local car1 = createVehicle(411, -73.699996948242, 2506.3999023438, 16.299999237061,0,0,270) 
    warpPedIntoVehicle ( ped1, car1) 
    triggerClientEvent("onCameraStart",root, ped1, car1) 
    setTimer(function() 
        destroyElement(car1) 
        destroyElement(ped1) 
    end,5000,1) 
end) 

not working

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