Jump to content

Ayuda con warpPedIntoVehicle


Mateito14

Recommended Posts

Hola, estoy haciendo un script para spawnear un auto y aparezca dentro, también que si spawnea un auto se destruya el anterior, el problema es que cuando spawneas otro se frena el auto, hay alguna forma de hacer que cambie el auto y no se frene?

El script.

function SpawnVeh ( vehid ) 
    if isPedInVehicle(source)==true then destroyElement (veh) end 
         if isElement( veh ) then destroyElement( veh ) end 
     local x,y,z = getElementPosition(source) 
      local rx,ry,rz = getElementRotation(source) 
         veh = createVehicle(vehid, x,y,z, rx, ry, rz) 
           warpPedIntoVehicle ( source, veh )       
end 
addEvent ("obtVeh", true) 
addEventHandler ("obtVeh", getRootElement(),  SpawnVeh) 
  

Link to comment

Intenta con esto:

  
vehicles = {} 
  
function SpawnVeh ( vehid ) 
    local veh = vehicles[source] 
    if (isPedInVehicle(source) and getPedOccupiedVehicle(source) == veh) then 
        setElementModel(veh, vehid) 
    else 
        if ( isElement(veh) ) then destroyElement(veh) vehicles[source] = nil end 
        local x, y, z = getElementPosition(source) 
        local rx, ry, rz = getElementRotation(source) 
        vehicles[source] = createVehicle(vehid, x ,y, z, rx, ry, rz) 
        warpPedIntoVehicle ( source, vehicles[source])     
    end   
end 
addEvent ("obtVeh", true) 
addEventHandler ("obtVeh", getRootElement(),  SpawnVeh) 
  

Link to comment
Intenta con esto:
  
vehicles = {} 
  
function SpawnVeh ( vehid ) 
    local veh = vehicles[source] 
    if (isPedInVehicle(source) and getPedOccupiedVehicle(source) == veh) then 
        setElementModel(veh, vehid) 
    else 
        if ( isElement(veh) ) then destroyElement(veh) vehicles[source] = nil end 
        local x, y, z = getElementPosition(source) 
        local rx, ry, rz = getElementRotation(source) 
        vehicles[source] = createVehicle(vehid, x ,y, z, rx, ry, rz) 
        warpPedIntoVehicle ( source, vehicles[source])     
    end   
end 
addEvent ("obtVeh", true) 
addEventHandler ("obtVeh", getRootElement(),  SpawnVeh) 
  

Funciona, gracias ;)

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...