Jump to content

Custom Elements doesnt load on gamemode?! Maybe bad defition


DarkLink

Recommended Posts

Okay guys, I made some custom elements for my gamemode and I am trying to load them on my script, but I guess its not getting it like an object, cant see object playing my map.

So first I have my edf file here:

  
<def name="borderpatrol"> 
  
<element name="mine" friendlyname="Mine" instructions="Place your mine wherever you want, police need do defend USA!" icon="mine.png" > 
    <object editorOnly="true" model="3053" posZ="0" /> 
        <data name="position" type="coord3d" default="0,0,0" /> 
        <data name="rotation" type="coord3d" default="0,0,0" /> 
         
    </element> 
     
</def> 
  

Then My map here:

  
<map edf:definitions="borderpatrol,editor_main"> 
  
   <mine id="mine1"  posX="177.49530029297" posY="2518.6298828125" posZ="15.657386779785" rotX="0" rotY="0" rotZ="0" /> 
    <mine id="mine2"  posX="177.57591247559" posY="2522.3798828125" posZ="15.732385635376" rotX="0" rotY="0" rotZ="0" /> 
    <mine id="mine3" posX="177.66137695313" posY="2526.3798828125" posZ="15.782384872437" rotX="0" rotY="0" rotZ="0" /> 
    <mine id="mine4" posX="177.37162780762" posY="2510.9431152344" posZ="15.50737285614" rotX="0.25" rotY="0" rotZ="0" /> 
     
</map> 
  

I am using on my map file definitions editor_main too, dont know if its messing or not, but I think I need it to load the objects?

Thanks guys, I dont know much about defitions, but I guess u can help me.

Thanks ;)

Link to comment
Introduction

Some resources use custom map elements. A capture the flag gamemode, for example, will likely use elements that contain flag positions and teams. When a map is loaded, the gamemode looks for any elements and installs flags accordingly - for example by creating a flag object and a collision shape.

The problem with these custom elements is that, unlike built-in MTA elements, the map editor has no idea of their meaning. How should a element be visually represented? What properties does it have? Without telling the editor this information, you could not use it to create these custom elements and would instead have to resort to manually editing the .map file with a text editor. Fortunately this isn't necessary: any resource can contain an editor definition file that describes the custom map elements used by that resource.

So you still have to create the objects yourself. What the map editor does is creating a visual representation of your mine, so mappers can easily put it somewhere. Then it stores all the necessary data (position and rotation) in the .map file. The objects shouldn't be in the .map file, since you can easily create them in your gamemode.

So when you load the map with your gamemode, you load all the custom elements (and there position+rotation) and then create the visuals (objects) yourself.

Link to comment

Hmmm thanks for ur reply SDK, so If I want to control all the mines on my gamemode.

What I need to do is:

getElementsByType('mine') so I get all the mines, right? and then I create a object for each element right? with the position and rotation I get from getElementData right?

Then If I want to control all these objects (all the mines), I can easly put all the objects (mines) on a table? right?

And I make what I want for all the objects on that table, right?

I guess I understand, thanks SDK!

Link to comment

Example:

for i, mine in ipairs(getElementsByType("mine")) do 
local posX, posY, posZ = getElementData(mine, "posX"), getElementData(mine, "posY"), getElementData(mine, "posZ") 
local rotX, rotY, rotZ = getElementData(mine, "rotX"), getElementData(mine, "rotY"), getElementData(mine, "rotZ") 
--createObject(model, posX, posY, posZ, rotX, rotY, rotZ) 
end 

Link to comment
Example:
for i, mine in ipairs(getElementsByType("mine")) do 
local posX, posY, posZ = getElementData(mine, "posX"), getElementData(mine, "posY"), getElementData(mine, "posZ") 
local rotX, rotY, rotZ = getElementData(mine, "rotX"), getElementData(mine, "rotY"), getElementData(mine, "rotZ") 
--createObject(model, posX, posY, posZ, rotX, rotY, rotZ) 
end 

Hmmm I see! Thanks alot Jacob ;)

Thanks SDK ;)

The mod can close .

Link to comment

Hey guys just one more question!

I found out that doesnt make difference the order I write the elements on my edf file.. The order of custom elements will always be from the ones with less code to the others with more code? right?

I tryed this two ways:

  
<def name="borderpatrol"> 
     
    <element name="mine" friendlyname="Mine" instructions="Place your mine wherever you want, police need do defend USA!" icon="mine.png" > 
        <object editorOnly="true" model="3053" posZ="0" /> 
        <data name="position" type="coord3d" default="0,0,0" /> 
        <data name="rotation" type="coord3d" default="0,0,0" /> 
         
    </element> 
     
    <element name="spawnpoint" friendlyname="Spawnpoint" instructions="Place your spawnspoints!" icon="spawnpoint.png"> 
        <data name="team" type="selection:Emigrants,Police" required="true" default="Emigrants" /> 
         
        <data name="position" type="coord3d" default="0,0,0" /> 
        <data name="rotation" type="coord3d" default="0,0,0" /> 
        <data name="skin" type="skinID" default="0" /> 
        <ped model="!skin!" rotation="!rotation!" position="!position!" team="!team!"/> 
         
         
    </element> 
     
</def> 
  
  

  
  
<def name="borderpatrol"> 
     
     
     
    <element name="spawnpoint" friendlyname="Spawnpoint" instructions="Place your spawnspoints!" icon="spawnpoint.png"> 
        <data name="team" type="selection:Emigrants,Police" required="true" default="Emigrants" /> 
         
        <data name="position" type="coord3d" default="0,0,0" /> 
        <data name="rotation" type="coord3d" default="0,0,0" /> 
        <data name="skin" type="skinID" default="0" /> 
        <ped model="!skin!" rotation="!rotation!" position="!position!" team="!team!"/> 
         
         
    </element> 
  
       <element name="mine" friendlyname="Mine" instructions="Place your mine wherever you want, police need do defend USA!" icon="mine.png" > 
        <object editorOnly="true" model="3053" posZ="0" /> 
        <data name="position" type="coord3d" default="0,0,0" /> 
        <data name="rotation" type="coord3d" default="0,0,0" /> 
         
    </element> 
     
</def> 
  
  

And its the same, I always get mine as the first custom object and then the spawnpoint as the second?

So can someone tell me how to control the order of this custom elements on map editor?

Thanks in Advance!

Link to comment

By the way guys, I have another problem.

I want to add a data node to a custom element, like a selection tab. When people want to create a teleport, they need to specify which area, if it is outside usa or inside usa. you see?

I mean something like this: area="selection:outside,inside" on the edf, but I dont know how to make it good, I am getting some problem on map editor, and I cant even see the custom elements now, when I try this area data node..

So how can I implement this?

Then on my scripts I want to get all the teleports, and do function A for inside teleports and do function B for outside teleports.

I think you get it. Thanks guys :)

Link to comment

I think the order is alphabetical, so you only can controll it by changing the names...

as for the other thing:

<element name="passage" friendlyname="Teleport" instructions="Place your teleport, emigrants need to reach USA!" icon="teleport.png" > 
        <data name="position" type="coord3d" default="0,0,0" /> 
        
        <data name="size" type="number" required="false" default="2"/> 
        <data name="color" type="color" required="false" default="##0ff94dff" /> 
        <data name="area" type="selection:outside,inside" required="false" default="outside" /> 
        
  
        <marker type="cylinder" size="!size!" color="!color!" /> 
        
        
        <marker size="0.5" type="cylinder" color="#ffff00ff" /> 
         
    </element> 

mtascreen20110717121042.th.jpg

but i don't really know how you going to make the teleport assignment user friendly, i used two diferent elements - one for the marker and other for destination

viewtopic.php?f=108&t=32529

Link to comment
I think the order is alphabetical, so you only can controll it by changing the names...

as for the other thing:

<element name="passage" friendlyname="Teleport" instructions="Place your teleport, emigrants need to reach USA!" icon="teleport.png" > 
        <data name="position" type="coord3d" default="0,0,0" /> 
        
        <data name="size" type="number" required="false" default="2"/> 
        <data name="color" type="color" required="false" default="##0ff94dff" /> 
        <data name="area" type="selection:outside,inside" required="false" default="outside" /> 
        
  
        <marker type="cylinder" size="!size!" color="!color!" /> 
        
        
        <marker size="0.5" type="cylinder" color="#ffff00ff" /> 
         
    </element> 

mtascreen20110717121042.th.jpg

but i don't really know how you going to make the teleport assignment user friendly, i used two diferent elements - one for the marker and other for destination

viewtopic.php?f=108&t=32529

alphabetical? omfg that kinda sucks :S

But ok thanks I got it :)

And the other situation, I am trying to do something like.

The user places a passage with type inside which name will be "teleport_one" and then need to place another passage with type outside and with same name, "teleport_one". And then the script will get the passage with name "teleport_one", and make each function for inside and outside, inside will teleport to outside and outside will teleport to inside, of this "teleport_one". you get it? I think its friendly, just need to tell on instructions that mappers should place a inside and outside passage to make it work.

I just dont know if its possible to set elements with same name (ID) on map editor, didnt had time yet to test, but I think its possible.

By the way Wojak thanks alot for your help, and if u know something better to implement this and more user friendly, please tell me.

Thanks bro.

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