Jump to content

What's wrong with my script? Slothbot does not respawn after death..


bencskrisz

Recommended Posts

function bot1() 
    bot1 = exports.slothbot:spawnBot (4845.0258789063, -1713.5711669922, 59.668750762939, 0, 108, 0, 0, teamLV, 31,  
  
"guarding", true ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(), bot1 ) 

addEventHandler( "onBotWasted", getRootElement( ), 
    function() 
        setTimer( spawnBot, 5000, 1, source , 4845.0258789063, -1713.5711669922, 59.668750762939, 0, 108, 0, 0, teamLV, 31,  
  
"guarding", true )  
    end 
) 

 

Edited by IIYAMA
Link to comment
  • Moderators
local container = createElement("bots")

function spawnBot(...)
	local bot = exports.slothbot:spawnBot(...) 
	setElementParent(bot, container)
end 

addEventHandler ( "onResourceStart", getResourceRootElement(), 
function ()
    spawnBot(4845.0258789063, -1713.5711669922, 59.668750762939, 0, 108, 0, 0, teamLV, 31,  "guarding", true) 
end) 


addEventHandler( "onBotWasted", container, 
    function()
        setTimer( spawnBot, 5000, 1 , 4845.0258789063, -1713.5711669922, 59.668750762939, 0, 108, 0, 0, teamLV, 31, "guarding", true )  
    end 
)  

Something like that.

 

@bencskrisz

Edited by IIYAMA
Link to comment
local bot1 = nil

addEventHandler("onResourceStart", getResourceRootElement(),
	function()
		bot1 = exports.slothbot:spawnBot(4845.0258789063, -1713.5711669922, 59.668750762939, 0, 108, 0, 0, teamLV, 31, "guarding", true)
	end
) 

addEventHandler("onBotWasted", getRootElement(), 
    function() 
        setTimer(spawnPlayer, 5000, 1, bot1, 4845.0258789063, -1713.5711669922, 59.668750762939)  
    end 
)

 

Link to comment
  • Moderators
1 hour ago, bencskrisz said:

Nah, it still does not respawn.. :|

 

1 minute ago, bencskrisz said:

It still does not respawn after killing him.. Still not :( 

Add some debug lines to your code and debug it, else you will get nowhere. And we will not be able to help you...

 

 

 

You don't know how to do that? There is a tutorial just for that.

 

Link to comment
addEventHandler("onResourceStart", getResourceRootElement(),
	function()
		exports.slothbot:spawnBot(3, 3, 5, 0, 108, 0, 0, teamLV, 31, "guarding", true)
	end
) 

addEvent("onBotWasted")
addEventHandler("onBotWasted", getRootElement(), 
	function() 
		setTimer(
			function()
				exports.slothbot:spawnBot(3, 3, 5, 0, 108, 0, 0, teamLV, 31, "guarding", true)
			end
		, 5000, 1)
    end 
)

You were missing 'addEvent' and on the timer to use exported functions you need to make the function inside the timer.

Edited by Feche1320
  • Thanks 1
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...