Jump to content

Creating new objects?


iPot

Recommended Posts

I got my dff, txd and col ready for use. Made a meta with a reference to them. But now I have to know how to spawn/create the objects ingame. Everyone who's going to help me, thank you ;)

I made this script, but nothing happens but no errors are given too..

function mapLoad ( name ) 
    txd_weedisland = engineLoadTXD("weedisland.txd") 
    engineImportTXD(txd_weedisland,3374) 
    col_weedisland = engineLoadCOL("weedisland") 
    dff_weedisland = engineLoadDFF("weedisland", 0 ) 
    engineReplaceCOL(col_weedisland,3374) 
    engineReplaceModel(dff_weedisland,3374)  
   createObject ( 3374, 3092.17, -2054.60, 0.0, 0, 0, 0 ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), mapLoad ) 

Link to comment

DFFs, TXDs, COLs and images must be downloaded by client to make a use of them, so... you have to make the script client-side. Add type="client" as an attribute to the file in meta.xml.

Example:

<script src="load_custom_objects.lua" type="client" /> 

Client-side events have different names.. basically they have "onClient" as prefix and server events just "on". To use onResourceStart client-side you have to use onClientResourceStart, simple, huh?

Also, don't use getRootElement when adding onClientResourceStart/onResourceStart, unless you want that function to be called every time any resource start. Use getResourceRootElement( getThisResource( ) ) instead.

Example:

addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), mapLoad ) 

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