Jump to content

[HELP] What wrong in this script?


Turbesz

Recommended Posts

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

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 by Spakye
  • Thanks 1
Link to comment
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. :D

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...