ELmarcoS. Posted September 18, 2012 Share Posted September 18, 2012 function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end slothBot = exports [ "slothBot" ]:spawnBot ( 249.16796875, -1822.9938964844, 3.3400845527649, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) Tengo este script que crea un bot en la playa de los santos, pero quiero que aparesca cerca de todos los jugadores, osea que obtenga las coordenadas del jugador y se spawnee cerca de el Link to comment
Matty Posted September 18, 2012 Share Posted September 18, 2012 Que se Spawnee serca de todos los jugadores, no se si sea posible. Pero que se spawnee serca de cualquier jugador si, usando: getRandomPlayer Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end slothBot = exports [ "slothBot" ]:spawnBot ( getRandomPlayer ( ), 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) Así? Link to comment
Renkon Posted September 18, 2012 Share Posted September 18, 2012 Usa un bucle for for index, player in ipairs getElementsByType("players") do -- Bucleamos la lista de jugadores. local x, y, z = getElementPosition(player) -- Conseguimos la posición --[[ Aca ponemos todo lo que queres que pase para cada jugador ]] end Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 No entendí ._.' soy novato en esto Link to comment
Renkon Posted September 18, 2012 Share Posted September 18, 2012 Si usas egtRandomPlayer, será solo a un jugador, en cambio con el bucle, revisas TODOS Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end slothBot = exports [ "slothBot" ]:spawnBot ( for index, player in ipairs getElementsByType("players") do local x, y, z = getElementPosition(player), 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) Asi quedaria? Link to comment
Matty Posted September 18, 2012 Share Posted September 18, 2012 Vos queres que aparezca 1 nemesis para cada jugador o 1 para todos ?. Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 Sólo que aparesca cerca de los jugadores Link to comment
NodZen Posted September 18, 2012 Share Posted September 18, 2012 Probaste Con getElementPosition--aca pones para que sea el jugador spawnBot ( x , y, z + 15 )--Algo asi Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end getElementPosition ( player ) slothBot = exports [ "slothBot" ] spawnBot ( x, y, z + 15, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) Nose si esta bien ;s Link to comment
Matty Posted September 18, 2012 Share Posted September 18, 2012 function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end slothBot = exports [ "slothBot" ]:spawnBot ( x + 15, y, z, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) function SpawnOnPlayer() local randomPlayer = getRandomPlayer () local x, y, z = getElementPosition ( randomPlayer ) end addEventHandler ( "onResourceStart", getRootElement(), SpawnOnPlayer ) Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 Error: nemesis/nemesis.lua:10: attempt to perform arithmetic on global 'x' (a nil value ) Link to comment
Matty Posted September 18, 2012 Share Posted September 18, 2012 function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end slothBot = exports [ "slothBot" ]:spawnBot ( x, y, z, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) function SpawnOnPlayer() local randomPlayer = getRandomPlayer () local x, y, z = getElementPosition ( randomPlayer ) x = x + 15 end addEventHandler ( "onResourceStart", getRootElement(), SpawnOnPlayer ) Proba. Link to comment
ELmarcoS. Posted September 18, 2012 Author Share Posted September 18, 2012 Pues al parecer no tiene ningun error, pero no aparece el bot ._., le quite lo de +15 y nada Link to comment
Renkon Posted September 19, 2012 Share Posted September 19, 2012 pone resourceRoot en lugar de getRootElement Link to comment
Plate Posted September 19, 2012 Share Posted September 19, 2012 prova haci function boss ( ) if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end x,y,z = getElementPosition(source) slothBot = exports [ "slothBot" ]:spawnBot ( x + 15, y, z, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) haci te tiene que andar Link to comment
ELmarcoS. Posted September 19, 2012 Author Share Posted September 19, 2012 No funciona ;/, creo que lo dejaré como estaba Link to comment
Plate Posted September 19, 2012 Share Posted September 19, 2012 creo que el error no esta en nel getElementPosition() sino que en el if ( isElement ( slothbot ) ) then destroyElement ( slothbot ) end if ( isElement ( myBlip ) ) then destroyElement ( myBlip ) end sacaselo y prova Link to comment
ELmarcoS. Posted September 20, 2012 Author Share Posted September 20, 2012 x,y,z = getElementPosition(source) slothBot = exports [ "slothBot" ]:spawnBot ( x + 15, y, z, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) outputChatBox ( "Zombie Boss has been generated!!, run!", root, 255, 0, 0, true ) end setTimer ( boss, 300000, 0 ) addEventHandler ( "onResourceStart", resourceRoot, boss ) WARNING: Loading script failed nemesis/nemesis.lua:5: '' expected near 'end' ._.? Link to comment
Renkon Posted September 20, 2012 Share Posted September 20, 2012 function bot() for index, player in ipairs getElementsByType("player") do local x, y, z = getElementPosition(player) slothBot = exports [ "slothBot" ]:spawnBot ( x, y, z+10, 90, 287, 0, 0, Nemesis, 22, "hunting", true ) exports.extra_health:setElementExtraHealth ( slothBot, 1000 ) end outputChatBox ( "Zombie Bosses have been generated!!, run!", root, 255, 0, 0, true ) end addCommandHandler("crearbots", bot) Prueba el comando /crearbots Creará un NEMESIS al lado de cada jugador online Link to comment
ELmarcoS. Posted September 20, 2012 Author Share Posted September 20, 2012 'do' expected near getElementsByType Si es muy dificil lo que estoy pidiendo mejor lo hago con las coordenadas para no molestarlos más Link to comment
Renkon Posted September 20, 2012 Share Posted September 20, 2012 Pero si el DO esta a la derecha, lo copiaste bien? Link to comment
ELmarcoS. Posted September 20, 2012 Author Share Posted September 20, 2012 Lo copié tal cual , lo copié denuevo y sale lo mismo Link to comment
Renkon Posted September 20, 2012 Share Posted September 20, 2012 A mi me funcionó correctamente. Link to comment
Recommended Posts