Alexs Posted July 31, 2012 Posted July 31, 2012 Hola a Todos, acababa el spawn de Paintball y queria saber si esto deberia funcionar: function getDefinitions( startedMap ) local mapRoot = getResourceRootElement( startedMap ) local spawnred = getElementsByType ( "spawnred" , mapRoot ) local spawnblue = getElementsByType ( "spawnblue" , mapRoot ) for key, rojo in pairs( spawnred ) do posr = getElementData ( rojo, "position" ) rotred = getElementData ( rojo, "rotation" ) insert.table(posred, posr) end for key, azul in pairs( spawnblue ) do posb = getElementData ( azul, "position" ) rotblue = getElementData ( azul, "rotation" ) insert.table(posblue, posb) end for teamr, rojos in pairs ( getPlayersInTeam ( Rojos )) do spawnPlayer(rojos,math.random(#posred),rotred,170) end for teamb, azules in pairs ( getPlayersInTeam ( Blue )) do spawnPlayer(azules,math.random(#posblue),rotblue,188) end end addEventHandler("onGamemodeMapStart", getRootElement(), getDefinitions) El caso es que hay muchos elementos de "spawnred" y "spawnblue" y quiero que al comenzar el mapa spawneen aleatoriamente entre ellos ya que si no quedarian congelados uno en el otro, esto serviria para eso? Developer @ MYVAL
Castillo Posted July 31, 2012 Posted July 31, 2012 function getDefinitions ( startedMap ) local mapRoot = getResourceRootElement ( startedMap ) local spawnred = getElementsByType ( "spawnred", mapRoot ) local spawnblue = getElementsByType ( "spawnblue", mapRoot ) for teamr, rojos in pairs ( getPlayersInTeam ( Rojos ) ) do local randomPoint = math.random ( #getElementsByType ( "spawnred", mapRoot ) ) local x, y, z = unpack ( getElementData ( getElementsByType ( "spawnred", mapRoot ) [ randomPoint ], "position" ) ) local rot = getElementData ( getElementsByType ( "spawnred", mapRoot ) [ randomPoint ], "rotation" ) spawnPlayer ( rojos, x, y, z, rot, 170 ) end for teamb, azules in pairs ( getPlayersInTeam ( Blue ) ) do local randomPoint = math.random ( #getElementsByType ( "spawnblue", mapRoot ) ) local x, y, z = unpack ( getElementData ( getElementsByType ( "spawnblue", mapRoot ) [ randomPoint ], "position" ) ) local rot = getElementData ( getElementsByType ( "spawnblue", mapRoot ) [ randomPoint ], "rotation" ) spawnPlayer ( azules, x, y, z, rot, 188 ) end end addEventHandler ( "onGamemodeMapStart", getRootElement(), getDefinitions ) Suponiendo que "position" sea una tabla con 3 argumentos, deberia funcionar creo yo. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Alexs Posted July 31, 2012 Author Posted July 31, 2012 Error en la linea 9: bad argument #1 to pairs, expected table got boolean Error en la linea 11: bad argument #1 to unpack, expected table got userdata Developer @ MYVAL
Castillo Posted July 31, 2012 Posted July 31, 2012 Me equivoque en algo, copia el codigo de nuevo. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Alexs Posted July 31, 2012 Author Posted July 31, 2012 Gracias, cuando pueda lo testeo y reposteo para que se mueva hacia arriba y sepan que lo probe Developer @ MYVAL
Recommended Posts