Mateito14 Posted January 28, 2016 Share Posted January 28, 2016 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
Tomas Posted January 28, 2016 Share Posted January 28, 2016 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
Mateito14 Posted January 28, 2016 Author Share Posted January 28, 2016 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
Recommended Posts