Jump to content

Spawnpoint groups? type of elements ? .map file


DarkLink

Recommended Posts

Guys I have these on .map files, the spawnpoints.

  
  
<map edf:definitions="ctf,editor_main"> 
  
  
    <spawnpoint id="spawnpoint (3)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (4)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (5)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (6)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (7)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
  
  
  
<spawnpoint id="spawnpoint (8)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (9)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (10)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (11)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (12)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
  
  
  
  
     
</map> 
  
  

And now I want to separate them, like first fives for polices and last five for drug dealers .

I tryed to change from spawnpoint to spawnpointPolice and spawnpointDrug

And then use getElementsByType("spawnpointPolice") ... and bad argument :S

Also tryed to put on lines of .map file the type data like these:

  
    <spawnpoint id="spawnpoint (12)"[b] type="police"[/b] skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
  

type="police" on first fives and on the last fives type="drug" . and then use also getElementsByType("police") and also bad argument.

can someone tell me how I can get them in groups ? using type.. something?

thanks alot btw!!

cya

Link to comment
which spawnpoints they are ? Zombies ? For players ? or something else ? :)

for players, but I want to make two different zones .

1 zone - the first 5 spawn

for police only, when they join police team

2 zone - the last 5 spawn

for drugs dealers only, when they join drug dealer team

did u understand?

thanks

Link to comment
I think easier is make it in scripts than map files.

but this is a gamemode, I dont want players to always change the .lua file :/

I want them to go on map editor. make spawnpoints for team1 and spawnpoints for team2, and then on .lua file i get spawnpoints of team1 to a table and spawnpoints of team2 to another table u see?

But I dont know how to manage spawnpoints on .map file, can I put a data element ? like type="team1" ?

thanks

Link to comment

You can use teams: https://wiki.multitheftauto.com/wiki/Element/Team

<map mod="deathmatch" version="1.0"> 
    <team name="Grove" red="0" green="255" blue="0"> 
        <spawnpoint posX="2495.1257324219" posY="-1686.6124267578" posZ="13.513834953308" rot="3.4530944824219"/> 
        <spawnpoint posX="2519.9204101563" posY="-1678.9359130859" posZ="14.879755020142" rot="91.500610351563"/> 
    </team> 
</map> 
  

Link to comment

And how do I get all those spawnpoints defined in that team?

In this case, how to get that 2 spawnpoints of team grove on .lua file ?

getElementsByType("Grove") ?

Thanks!

EDIT: I use getElementChild("grove", indexofspawnpoint)

right?

thanks!

Link to comment

guys I tested it and still getting me errors on console..

console error: bad argument at getElementChild

this is .map file:

<map edf:definitions="ctf,editor_main"> 
  
  
<team name="policeSP"> 
    <spawnpoint id="spawnpoint (3)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (4)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (5)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (6)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (7)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
</team> 
  
<team name="immigrantsSP"> 
    <spawnpoint id="spawnpoint (8)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (9)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (10)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (11)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (12)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
</team> 
  
  
     
</map> 
  
  

and now this is my code on .lua file:

function joinHandler(equipa) 
     
    local listaSpawnpointPolice = getElementByID("policeSP") 
    local listaSpawnpointImmigrants = getElementByID("immigrantsSP") 
    local nr = tonumber(math.random ( 0, 4 )) 
    local spawnPointPolice = getElementChild(listaSpawnpointPolice, nr)    --line13 
    local spawnPointImmigrants = getElementChild(listaSpawnpointImmigrants, nr)   --line14 
  
     
     
    local playersOnImmigrants = countPlayersInTeam ( immigrantsTeam ) 
    local playersOnPolice = countPlayersInTeam ( policeTeam ) 
... 
... 
.. 
  

the first problems appear right on the 13 and 14 line...

so can u guys tell me what is wrong??

Thanks again.

Link to comment

Try it this way, not tested:

function joinHandler(equipa) 
    -- first find the team elements 
    local team_policeSP= getElementByID("policeSP") 
    local team_immigrantsSP= getElementByID("immigrantsSP") 
     
    -- put all children from the teams that are from type 'spawnpoint' in tables 
    local spawns_policeSP= getElementsByType ( 'spawnpoint', team_policeSP) 
    local spawns_immigrantsSP = getElementsByType ( 'spawnpoint', team_immigrantsSP ) 
  
    -- select a random element from the table 
    local nr = math.random ( #spawns_policeSP ) 
    local spawnPointPolice = spawns_policeSP [ nr ] 
  
    -- repeat 
    nr = math.random ( #spawns_immigrantsSP ) 
    local spawnPointImmigrants = spawns_immigrantsSP [ nr ] 
  

The key is getElementsByType, you can choose the type ( ='spawnpoint') and the parent element ( = team ), it will return all children in a table

Link to comment

Now I have bad argument at getElementsByType .. on line 7 and 8 of ur code.. why? :c

I dont understand what is wrong .

Does the map file is fine?

  
<map> 
    <marker id="marker1" type="cylinder" color="#0000ff99" size="2" interior="0" dimension="0" posX="770.58630371094" posY="1668.0819091797" posZ="4.1890187263489" rotX="0" rotY="0" rotZ="0" /> 
    <marker id="marker2" type="cylinder" color="#0000ff99" size="1" interior="0" dimension="0" posX="796.76818847656" posY="1668.2836914063" posZ="6.8681697845459" rotX="0" rotY="0" rotZ="0" /> 
  
<team name="policeSP"> 
    <spawnpoint id="spawnpoint (3)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (4)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (5)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (6)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (7)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
</team> 
  
<team name="immigrantsSP"> 
    <spawnpoint id="spawnpoint (8)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (9)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (10)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (11)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (12)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
</team> 
  
  
     
</map> 
  

i think yes.. but anyways, look at it

thanks bro

Link to comment
ah, you used "name" in the map file. That's why getElementByID didnt work and returned false => error at getElementsByType in my script/getElementChild in your script.

Change

so I change from name to id ?

edit: now i get this error:

bad/missing name' in attribute in (team) (line 5)

bad/missing name' in attribute in (team) (line 13)

I had tryed that before

Link to comment
Hm, I'm messing up.
<team name="policeSP"> 

local team_policeSP= getTeamFromName("policeSP") 

Okay bro! thanks alot, working now!!

Just one more little question, doing this:

  
<team name = "policeSP"> 
    <spawnpoint id="spawnpoint (3)" skin="0" posX="916.21356201172" posY="1951.1668701172" posZ="10.724204063416" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (4)" skin="0" posX="929.68695068359" posY="2066.69921875" posZ="21.701473236084" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (5)" skin="0" posX="942.68170166016" posY="1853.6920166016" posZ="10.671875" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (6)" skin="0" posX="976.0068359375" posY="1877.2258300781" posZ="15.496273994446" rotX="0" rotY="0" rotZ="0" /> 
    <spawnpoint id="spawnpoint (7)" skin="0" posX="975.92828369141" posY="1974.7801513672" posZ="15.487140655518" rotX="0" rotY="0" rotZ="0" /> 
</team> 
  

we already created a team right? we dont need to create again using createTeam on lua? right?

The team is already created if someone uses one spawn right?

and then i can use functions of team, dont need to create it , because its already created on .map

thanks bro

EDIT: Found the answer to my question, teams on .map file are already created, dont need to use createTeam next on .lua. I can already use functions of team, like countPlayersInTeam and such :)

Thanks guys for all the time u lost (u didnt lost, u helped a mate :b) ;)

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