Jump to content

Problem with Custom Objects


Giovanni

Recommended Posts

Hey there, I took a look at a tutorial for creating custom objects and got this:

meta:

<meta> 
    [b]<file src="map/ramp.col" />[/b] 
    [b]<file src="map/ramp.dff" />[/b] 
    <script src="test2.lua" type="client" /> 
    <info gamemodes="race" type="map" version="1.0.0" /> 
    <map src="race-Testmap.map" dimension="0" /> 
    <settings> 
        <setting name="#minplayers" value="[ 0 ]" /> 
        <setting name="#maxplayers" value="[ 128 ]" /> 
        <setting name="#gravity" value="[ 0.008000 ]" /> 
        <setting name="#weather" value="[ 0 ]" /> 
        <setting name="#time" value="1:0" /> 
        <setting name="#locked_time" value="[ false ]" /> 
        <setting name="#waveheight" value="[ 0 ]" /> 
        <setting name="#gamespeed" value="[ 1 ]" /> 
    </settings> 
</meta> 

test2.lua

local modelNames = { "map/Quader001", } 
  
function reloadModels( ) 
    for i, modelName in ipairs( modelNames ) do 
        local temp = engineLoadDFF( modelName .. "ramp.dff", 0 ); 
        engineReplaceModel( temp, (i-1) + 4000 ); 
        temp = engineLoadCOL( modelName .. "ramp.col" ); 
        engineReplaceCOL( temp, (i-1) + 4000 ); 
    end 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement(), reloadModels ); 
addCommandHandler( "reload", reloadModels ); 

---------------------------------------------------------------------------------------------

Well that's the code. My objects are inside the folder "map" as you can see. I've there following objcets:

  • ramp.dff
    ramp.col

I don't have a txd file since I wasn't able to figure out how to create it. Anyway the problem is, that

1. The script isn't able to be loaded, also if I use /start test2

2. I doubt that it'll work, also if the script will be loaded.

So if you could help me. Thank you.

Link to comment

I can't help you much with the scripting but I'm reasonably handy with custom models - I'm surprised you were able to make a DFF and COL, but not the TXD? It's a very simple process, I'll explain briefly, hopefully it helps you:

*Download a TXD-creating program > I personally use TXDWorkshop 4.0B

*Click File > New > 32BPP

*Press the 'insert' button on the keyboard and add more 32BPP slots, as many as you need for each of the textures used in your model

*Click on a slot, click the 'Import' button at the top, navigate to the textures you used in your model

*Double-click the slot you imported an image to, and change the image name so that it is the same as the texture's filename/same as the name you gave it in the modeller

*Click 'compress' - non-Alpha images will compress to DXT1, images with Alpha will compress to DXT3

(For textures with alpha, click the 'alpha' tickbox, then click the 'Alpha/Mask' tab at the bottom, Import your alpha and compress as above)

*Make sure the image names you used are exactly the same as your filenames (hopefully you already truncated them to 8 characters or less before using them in the modeller, or you may be destined to fail) and that each one is compressed.

*Save it

Link to comment

Thank you. But still it doesn't work. I created a txd file now. I also made a new 3D object and worked over the script now so it looks like that:

client.lua

addEventHandler('onClientResourceStart', resourceRoot,  
function()  
  
    local col = engineLoadCOL('smile.col')  
    engineReplaceCOL(col, 1234) 
     
    local dff = engineLoadDFF('smile.dff', 0)  
    engineReplaceModel(dff, 1234)    
     
    local txd = engineLoadTXD('smile.txd') 
    engineImportTXD(txd, 1234) 
     
end  
) 

When i test the map, the object was replaced, but it is invisible and not solid. When I use /start client it tells me that the resource could not be found. So if you could please help me again,

Thank you

Link to comment

/start argument is resource you want to run, not separate file of your resource (they are all running when resource is started).

why object is invisible and doesnt have collisions? because:

1. common bug with custom objects. you have to reload custom objects from time to time, as gta like to remove custom objects from its memory :/

2. or your collision file and/or model and or texture files are broken or inproperly imported (although your code looks fine).

Link to comment
/start argument is resource you want to run, not separate file of your resource (they are all running when resource is started).

why object is invisible and doesnt have collisions? because:

1. common bug with custom objects. you have to reload custom objects from time to time, as gta like to remove custom objects from its memory :/

2. or your collision file and/or model and or texture files are broken or inproperly imported (although your code looks fine).

So when it says the resource can't be found it means it´s already running Nvm lol, is there a way i can load a separate file as well? And about the 3D object, I did it like in the tutorial for 3D moddeling on the MTA YouTube channel.

Link to comment

If it's your first custom model, chances are high that there will be some fail. The process of getting 3D models into SA is fine once you get the hang of it, but to begin with it seems pretty complicated and there's a lot that can go wrong. If you're still having problems with your resource I'll be happy to take a look at your model files if you'd like, at least then we can find out whether the problem lies there or elsewhere.

Link to comment

I agree with Oz.

It's the beginning of your modelling journey. Just make something simple at first, later you can make something even better and harder!

I know it takes a long time, but I knew sometime you can be a modeller, like in most skins and objects used in games and mods.

A long journey starts with a single step.

Oz can do modelling too. Maybe Oz can be one of your helpers at your modelling experience? :)

Link to comment

Thank you for your support guys! Here is a link to download my DFF, COL and .max files(in case of you want to edit or w/e): http://solidfiles.com/d/c746/ || That's a new object but I changed my script to fit for this one.

A little update: I was able to insert the model now. Realy thank you. But I´ve another problem. There is like an area around my model which is solid, not the model itself. I replaced Object ID 4000 now. I decided to turn around the object in the editor. From the other side the object isn't solid at all, that means you can drive through it:

uploadmex.th.png

Uploaded with ImageShack.us

I probably made a mistake at saving/exporting the object but you'll see. But again, thank you all. I came forward very much now with this work.

Link to comment

Ok, well there were a few things wrong with that, so your problem may have been one of several.

1. You exported your DFF as 'Rampy', but in 3DS your object was called 'Quader001'. You should always name your 3DS entity the same as the DFF/COL you will be exporting to. So in your case, the entity should have been called 'Rampy'.

2. Your object was not aligned to the pivot point (centre of the 'world' in 3DS). Unless you have a good reason not to, it's good practice to align your object to the pivot point, so that the relative position of the object you are replacing, and the position of your replacement object are the same.

3. There were some geometry issues, even though you were only making a triangular prism (should be 5 faces) it had 12 instead. May have also been the reason behind your COL problems, in my experience COLs work better if the surfaces are somewhat similar in size. In your case you had 5 large faces, and 7 very small/overlapping ones.

Anyway, I fixed those and made a TXD for you. I haven't tested it but it should work as long as I didn't bugger up something myself :P

Should look like this:

rampy.png

(Of course you can change the textures or whatever you want)

Download link:

http://rapidshare.com/files/439503259/Rampy.zip

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