matucha123 Posted February 19, 2012 Share Posted February 19, 2012 (edited) How crate multiply table (in other languages 2d, 3d arrays)? I want something like that: spwanPoints[team][key]["x"] = x spwanPoints[team][key]["y"] = y spwanPoints[team][key]["z"] = z spwanPoints[team][key]["r"] = r Tried: spwanPoints = {keyss = {valuses={}}} Error: maploader_s.lua:28: attempt to index field '?' (a nil value) Edited February 20, 2012 by Guest Link to comment
Castillo Posted February 19, 2012 Share Posted February 19, 2012 You mean something like this? spawnPoints = {} spawnPoints["keys"] = {} spawnPoints["keys"]["values"] = {} Link to comment
matucha123 Posted February 19, 2012 Author Share Posted February 19, 2012 I dont want that indexes is predefined, i want what indexes names is set while runinning script: Server full script spawnPoints = {} spawnPoints["Team1"] = {} spawnPoints["Team1"][1] = {} --[[addEventHandler( "onPlayerWasted", root, function() setTimer( spawnPlayer, 2000, 1, source, get("startx"),get("starty"), get("startz"), get("startrot")) end )]] function loadMap(startedMap) mapRoot = getResourceRootElement(startedMap) loadSpawns( ) end addEventHandler("onGamemodeMapStart", root, loadMap) function loadSpawns() local spawn = getElementsByType("minispawnpoint", mapRoot) local x,y,z,r, team --spawnPoints["Team1"] = {} --spawnPoints["Team2"] = {} for key, value in pairs(spawn) do x = getElementData(value, "posX") y = getElementData(value, "posY") z = getElementData(value, "posZ") r = getElementData(value, "rotZ") team = getElementData(value, "team") spawnPoints[team][key]["x"] = x spawnPoints[team][key]["y"] = y spawnPoints[team][key]["z"] = z spawnPoints[team][key]["r"] = r end end addEventHandler("onPlayerJoin", root, function () fadeCamera(source,true) setCameraTarget(source, source) spawnPlayer(source,spawnPoints["Team1"][1]["x"], spawnPoints["Team1"][1]["y"],spawnPoints["Team1"]["z"] ) end ) Link to comment
Kenix Posted February 19, 2012 Share Posted February 19, 2012 You need create if map started spawn all players in spawnpoints ( random spawnpoints )? Link to comment
matucha123 Posted February 19, 2012 Author Share Posted February 19, 2012 Yeah for now random would be OK. Later I will add random spawns for different teams. BTW map file: "MiniMissions,editor_main"> "minispwanpoint (2)" team="Team1" rotZ="0" model="0" posX="2480.1999511719" posY="-1658.6999511719" posZ="13.300000190735" rotX="0" rotY="0"> "minispwanpoint (3)" team="Team2" rotZ="0" model="0" interior="0" posX="2467" posY="-1657.6999511719" posZ="13.300000190735" rotX="0" rotY="0"> Link to comment
Kenix Posted February 19, 2012 Share Posted February 19, 2012 (edited) https://wiki.multitheftauto.com/wiki/RU/ ... awnmanager https://wiki.multitheftauto.com/index.ph ... Mapmanager Edited February 19, 2012 by Guest Link to comment
sora+ Posted February 19, 2012 Share Posted February 19, 2012 you should ask about that in the minimission forums in my humble opinion. Link to comment
Kenix Posted February 19, 2012 Share Posted February 19, 2012 Server addEventHandler( 'onGamemodeMapStart', root, function( startedMap ) local spawns = getElementsByType( 'minispawnpoint', resourceRoot ) for _,v in pairs( getElementsByType 'player' ) do local random = math.random ( #spawns ) local posX = getElementData( spawns[ random ], 'posX' ) local posY = getElementData( spawns[ random ], 'posY' ) local posZ = getElementData( spawns[ random ], 'posZ' ) local team = getElementData( spawns[ random ], 'team' ) local rot = getElementData( spawns[ random ], 'rot' ) or getElementData( spawns[ random ], 'rotZ' ) or 0 spawnPlayer( v,posX,posY,posZ,rot, 0,0,0,getTeamFromName( team ) ) end end ) addEventHandler( 'onPlayerJoin',root, function( ) local spawns = getElementsByType( 'minispawnpoint', resourceRoot ) local random = math.random ( #spawns ) local posX = getElementData( spawns[ random ], 'posX' ) local posY = getElementData( spawns[ random ], 'posY' ) local posZ = getElementData( spawns[ random ], 'posZ' ) local team = getElementData( spawns[ random ], 'team' ) local rot = getElementData( spawns[ random ], 'rot' ) or getElementData( spawns[ random ], 'rotZ' ) or 0 spawnPlayer( source,posX,posY,posZ,rot, 0,0,0,getTeamFromName( team ) ) end ) Updated. But i think you need create 2 type elements( for 2 teams ). Example:redspawnpoint,greenspawnpoint. And loop it. Link to comment
matucha123 Posted February 19, 2012 Author Share Posted February 19, 2012 OK. I have questions about edf. Lets say in setting I chose gametype, and elements (like spawnpoint, marker and etc) change, lets say in gamemode settings I enter that there would be 3 teams. Is it possible that in definitions would be 3 teams after changing? now teams is created like this: EDF "team" type="selection:Team1,Team2" default="TeamA" /> Link to comment
matucha123 Posted February 19, 2012 Author Share Posted February 19, 2012 In gamemode settings (in mapeditor) I select that there would be 3 teams and set their names. How make than then I put spwan point, in it's setting appears created teams. Link to comment
karlis Posted February 19, 2012 Share Posted February 19, 2012 for multidimensional arrays you need to define a new table in a main table, and put contents in it. you can pre-create it only if you know the size at the start. example: local spawnPoints = {} for _,team in ipairs(getElementsByType("team")) do local name = getTeamName(team) spawnPoints[name]={} spawnPoints[name].x=x spawnPoints[name].y=y spawnPoints[name].z=z end Link to comment
matucha123 Posted February 20, 2012 Author Share Posted February 20, 2012 How read settings from map meta? "MiniMissions" type="map" version="1.0.0"> "MiniMiss.map" dimension="0"> "#greenteamskins" value='[ "0" ]'> "#greenteamcolor" value='[ "#00FF00FF" ]'> "#maxplayers" value="[ 128 ]"> "#gamespeed" value="[ 1 ]"> "#greenteamob" value='[ "Kill other teams" ]'> "#respawndissable" value="[ 0 ]"> "#minplayers" value="[ 0 ]"> "#weather" value="[ 0 ]"> "#gravity" value="[ 0.008000 ]"> "#waveheight" value="[ 0 ]"> "#greenteamname" value='[ "Green team" ]'> "#locked_time" value="[ false ]"> "#duration" value="[ 600 ]"> "#time" value="12:0"> Let's say I need "#greenteamname" name Link to comment
matucha123 Posted February 20, 2012 Author Share Posted February 20, 2012 Thank you! Is there way to know which EDF (editor definitions) are added to map? Link to comment
Castillo Posted February 20, 2012 Share Posted February 20, 2012 In the top of the map file you'll find: "editor_main"> Link to comment
matucha123 Posted February 21, 2012 Author Share Posted February 21, 2012 I need to read that in LUA, while gamemode running Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now