Turbesz Posted December 28, 2020 Share Posted December 28, 2020 I want to spawn a bot, and when the player enter in the colshape then bot attack player, when the player leave the colshape then the bot stop attack, and follow. I use for this the slothbot script. Buut, when i spawn the bot, the bot automatically start follow and attack me, not dealing with the colshape events... Does not matter i enter or leave the colshape, the code does not work, only the spawn part... No any error and warning in debugscript... What wrong in my code? local zzone = createColCuboid(-78.946533203125, 1462.0727539063, 11.346961021423, 151.5, 124, 19) function lerakja() bot = exports.v5_slothbot:spawnBot(-8.23485, 1520.40417, 12.75000, 0, 23,0,0,_,0,"waiting",nil) end addCommandHandler("teszt",lerakja) function attack() exports.v5_slothbot:setBotFollow(bot, source ) exports.v5_slothbot:setBotAttackEnabled(true) end addEventHandler( "onElementColShapeHit", zzone, attack ) function stopattack() exports.v5_slothbot:setBotWait(bot) end addEventHandler( "onElementColShapeLeave", zzone, stopattack ) Link to comment
Addlibs Posted December 28, 2020 Share Posted December 28, 2020 bot isn't defined in attack or stopattack contexts. You need to declare the variable bot globally with bot = nil or declare it a local variable for the file by writing local bot at the top. Link to comment
Turbesz Posted December 28, 2020 Author Share Posted December 28, 2020 2 minutes ago, Addlibs said: bot isn't defined in attack or stopattack contexts. You need to declare the variable bot globally with bot = nil or declare it a local variable for the file by writing local bot at the top. i tried, but same problem :s Link to comment
Spakye Posted December 29, 2020 Share Posted December 29, 2020 (edited) Hello, I didnt use Slothbot in a long time but i believe "waiting" state wont make him peacefull, it will make him wait until he sees someone, if the player isnt in his team then the bot will chase and shoot, if the player is in his team then he will follow him. So in your script the Bot will always shoot you as soon as he sees you ( assuming im right about the waiting state and if you are not in the same team). Maybe try to use setBotAttackEnabled to false when you spawn it. Edited December 29, 2020 by Spakye 1 Link to comment
Turbesz Posted December 29, 2020 Author Share Posted December 29, 2020 1 hour ago, Spakye said: Hello, I didnt use Slothbot in a long time but i believe "waiting" state wont make him peacefull, it will make him wait until he sees someone, if the player isnt in his team then the bot will chase and shoot, if the player is in his team then he will follow him. So in your script the Bot will always shoot you as soon as he sees you ( assuming im right about the waiting state and if you are not in the same team). Maybe try to use setBotAttackEnabled to false when you spawn it. Ah thank you, i understand now. 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