Jump to content

Collision problem on custom vehicle


KITT1995

Recommended Posts

Why when i put a custom vehicle the collisions remain the same of the original vehicle and not of the custom one?

This is the script:

txd = engineLoadTXD("data/bullet.txd") 
engineImportTXD(txd,541) 
dff = engineLoadDFF("data/bullet.dff",541) 
engineReplaceModel(dff,541) 
  
txd = engineLoadTXD("data/faggio.txd") 
engineImportTXD(txd,462) 
dff = engineLoadDFF("data/faggio.dff",462) 
engineReplaceModel(dff,462) 
  
txd = engineLoadTXD("data/copcarsf.txd") 
engineImportTXD(txd,597) 
dff = engineLoadDFF("data/copcarsf.dff",597) 
engineReplaceModel(dff,597) 
  
txd = engineLoadTXD("data/androm.txd") 
engineImportTXD(txd,592) 
dff = engineLoadDFF("data/androm.dff",592) 
engineReplaceModel(dff,592) 
  
txd = engineLoadTXD("data/cargobob.txd") 
engineImportTXD(txd,548) 
dff = engineLoadDFF("data/cargobob.dff",548) 
engineReplaceModel(dff,548) 

Link to comment

No, you just need to make a function wich load and replace the model a second time :

  
function replaceVeh()  
    txd = engineLoadTXD("data/bullet.txd") 
    engineImportTXD(txd,541) 
    dff = engineLoadDFF("data/bullet.dff",541) 
    engineReplaceModel(dff,541) 
      
    txd = engineLoadTXD("data/:O.txd") 
    engineImportTXD(txd,462) 
    dff = engineLoadDFF("data/:O.dff",462) 
    engineReplaceModel(dff,462) 
      
    txd = engineLoadTXD("data/copcarsf.txd") 
    engineImportTXD(txd,597) 
    dff = engineLoadDFF("data/copcarsf.dff",597) 
    engineReplaceModel(dff,597) 
      
    txd = engineLoadTXD("data/androm.txd") 
    engineImportTXD(txd,592) 
    dff = engineLoadDFF("data/androm.dff",592) 
    engineReplaceModel(dff,592) 
      
    txd = engineLoadTXD("data/cargobob.txd") 
    engineImportTXD(txd,548) 
    dff = engineLoadDFF("data/cargobob.dff",548) 
    engineReplaceModel(dff,548) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceVeh) 
  
function reload () 
    setTimer(replaceVeh, 1000, 1) -- make the modding function to load a second time after 1 second 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), reload 
  

But there is just a little problem, the modded vehicles must be already created as the collision will not load.

I.E.: If you start the resource which change the vehicles models, and then you create a vehicle with the admin panel, the collision will not load.

Link to comment
No, you just need to make a function wich load and replace the model a second time :
  
function replaceVeh()  
    txd = engineLoadTXD("data/bullet.txd") 
    engineImportTXD(txd,541) 
    dff = engineLoadDFF("data/bullet.dff",541) 
    engineReplaceModel(dff,541) 
      
    txd = engineLoadTXD("data/:O.txd") 
    engineImportTXD(txd,462) 
    dff = engineLoadDFF("data/:O.dff",462) 
    engineReplaceModel(dff,462) 
      
    txd = engineLoadTXD("data/copcarsf.txd") 
    engineImportTXD(txd,597) 
    dff = engineLoadDFF("data/copcarsf.dff",597) 
    engineReplaceModel(dff,597) 
      
    txd = engineLoadTXD("data/androm.txd") 
    engineImportTXD(txd,592) 
    dff = engineLoadDFF("data/androm.dff",592) 
    engineReplaceModel(dff,592) 
      
    txd = engineLoadTXD("data/cargobob.txd") 
    engineImportTXD(txd,548) 
    dff = engineLoadDFF("data/cargobob.dff",548) 
    engineReplaceModel(dff,548) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceVeh) 
  
function reload () 
    setTimer(replaceVeh, 1000, 1) -- make the modding function to load a second time after 1 second 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), reload 
  

But there is just a little problem, the modded vehicles must be already created as the collision will not load.

I.E.: If you start the resource which change the vehicles models, and then you create a vehicle with the admin panel, the collision will not load.

There isn't a way to do it when creating vehicle? With the event "onVehicleSpawn"?

Link to comment
  • 3 weeks later...

Use the script of dragofdark, that's the way to replace vehicle collisions. Those collisions are just very poorly implemented in MTA, so there's not much you can do about it too at the moment.

If it doesnt work, use onClientElementStreamIn as the event. I've been told that replacing collisions only works when the vehicle you want to replace is streamed in, but I haven't tried this myself.

megaman54 and Jesseunit, please know what you're posting before you actually post. Vehicles do not have a .col file!

Link to comment
Use the script of dragofdark, that's the way to replace vehicle collisions. Those collisions are just very poorly implemented in MTA, so there's not much you can do about it too at the moment.

If it doesnt work, use onClientElementStreamIn as the event. I've been told that replacing collisions only works when the vehicle you want to replace is streamed in, but I haven't tried this myself.

megaman54 and Jesseunit, please know what you're posting before you actually post. Vehicles do not have a .col file!

It doesn't work with onClientElementStreamIn, everytime the original collision

function replaceVeh() 
    txd = engineLoadTXD("data/bullet.txd") 
    engineImportTXD(txd,541) 
    dff = engineLoadDFF("data/bullet.dff",541) 
    engineReplaceModel(dff,541) 
      
    txd = engineLoadTXD("data/faggio.txd") 
    engineImportTXD(txd,462) 
    dff = engineLoadDFF("data/faggio.dff",462) 
    engineReplaceModel(dff,462) 
      
    txd = engineLoadTXD("data/copcarsf.txd") 
    engineImportTXD(txd,597) 
    dff = engineLoadDFF("data/copcarsf.dff",597) 
    engineReplaceModel(dff,597) 
      
    txd = engineLoadTXD("data/androm.txd") 
    engineImportTXD(txd,592) 
    dff = engineLoadDFF("data/androm.dff",592) 
    engineReplaceModel(dff,592) 
      
    txd = engineLoadTXD("data/cargobob.txd") 
    engineImportTXD(txd,548) 
    dff = engineLoadDFF("data/cargobob.dff",548) 
    engineReplaceModel(dff,548) 
end 
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceVeh) 
  
 function reload () 
    setTimer(replaceVeh, 1000, 1) -- make the modding function to load a second time after 1 second 
end 
addEventHandler ( "onClientElementStreamIn", getResourceRootElement(getThisResource()), reload ) 

Link to comment
  • Discord Moderators
If it doesnt work, use onClientElementStreamIn as the event. I've been told that replacing collisions only works when the vehicle you want to replace is streamed in, but I haven't tried this myself.

I told you that there was a high chance of success if a vehicle of the replacing model was streamed in, not that it's the only way at all. :P

The problem is really that MTA is unable to load embedded collisions via engineReplaceModel the first time it is called. The only way is to load the dff several times. Now the trick is to find a way to determine if the vehicle collision failed, and then keep replacing until the opposite of course. I almost found a failproof way to do this, and I just need to make it more efficient. I'm planning a vehicle replacement resource at some point, at which it'll be included and ya'll can grab the code if you want :P

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