LiOneLMeSsIShoT Posted November 25, 2013 Author Share Posted November 25, 2013 What you want the bot to do other than following you? i mean. the bot is hardly follows me...the bot stop for long time then starts to keep following.. i mean not always follow me .. why? Link to comment
TAPL Posted November 25, 2013 Share Posted November 25, 2013 Try to lower the distance checker, open slothbot > sbserver.lua > go to line 666 and search for this: if (fdist < 13) and (getElementData (ped, "follow_shooting") == true) then Change the distance from 13 to 2 and save the file and restart slothbot and your script and try, i hope it will work. Link to comment
LiOneLMeSsIShoT Posted November 25, 2013 Author Share Posted November 25, 2013 Try to lower the distance checker, open slothbot > sbserver.lua > go to line 666 and search for this: if (fdist < 13) and (getElementData (ped, "follow_shooting") == true) then Change the distance from 13 to 2 and save the file and restart slothbot and your script and try, i hope it will work. ok i will try. Link to comment
LiOneLMeSsIShoT Posted November 25, 2013 Author Share Posted November 25, 2013 Try to lower the distance checker, open slothbot > sbserver.lua > go to line 666 and search for this: if (fdist < 13) and (getElementData (ped, "follow_shooting") == true) then Change the distance from 13 to 2 and save the file and restart slothbot and your script and try, i hope it will work. ok i will try. Alright tried..work as the ped follows, but when i stop the ped starts to jump behind me and move around me like a mad guy Link to comment
TAPL Posted November 25, 2013 Share Posted November 25, 2013 It should stop when it became near you. Link to comment
LiOneLMeSsIShoT Posted November 25, 2013 Author Share Posted November 25, 2013 It should stop when it became near you. actually it's not...try to use the script man and you will see Link to comment
TAPL Posted November 25, 2013 Share Posted November 25, 2013 Try this and see if there any difference. addCommandHandler ("guard", function(player) local x, y, z = getElementPosition(player) Guard = exports["slothbot"]:spawnBot(x+2, y+2, z, 0, 240, 0, 0, nil, 0, "following", player) setTimer(function() exports["slothbot"]:setBotAttackEnabled(Guard, false) setElementData(Guard, "seestarget", true) end, 250, 1) end) i can't help you more as the script (slothbot) is long and modifying it require known the script logic and how it work and then making your own script will be better than modifying (slothbot). The example was there: https://forum.multitheftauto.com/viewtopic.php?f=91&t=67785 Link to comment
LiOneLMeSsIShoT Posted November 25, 2013 Author Share Posted November 25, 2013 Try this and see if there any difference. addCommandHandler ("guard", function(player) local x, y, z = getElementPosition(player) Guard = exports["slothbot"]:spawnBot(x+2, y+2, z, 0, 240, 0, 0, nil, 0, "following", player) setTimer(function() exports["slothbot"]:setBotAttackEnabled(Guard, false) setElementData(Guard, "seestarget", true) end, 250, 1) end) i can't help you more as the script (slothbot) is long and modifying it require known the script logic and how it work and then making your own script will be better than modifying (slothbot). The example was there: https://forum.multitheftauto.com/viewtopic.php?f=91&t=67785 ped = createPed(0, getElementPosition(localPlayer)) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(ped) local dis = getDistanceBetweenPoints2D(x, y, tx, ty) if dis > 2 then setPedControlState(ped, "forwards", true) else setPedControlState(ped, "forwards", false) end setPedRotation(ped, findRotation(tx, ty, x, y)) end) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end Alright yeah this Example...but i don't understand the script 100% can you explain me somethings on it? 1- setPedRotation(ped, findRotation(tx, ty, x, y)) 2- function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end Thanks Link to comment
TAPL Posted November 25, 2013 Share Posted November 25, 2013 https://wiki.multitheftauto.com/wiki/FindRotation This function takes two sets of XY coordinates. It returns the direction from point A to point B. This can for example be used to make peds face a given point. Link to comment
LiOneLMeSsIShoT Posted November 25, 2013 Author Share Posted November 25, 2013 https://wiki.multitheftauto.com/wiki/FindRotationThis function takes two sets of XY coordinates. It returns the direction from point A to point B. This can for example be used to make peds face a given point. Well, what is x1, y1, x2, y2? and what's "math.deg and math.atan2..and what's x2-x1,y2-y1 ..and what's t = t +360 ...please man tell me what or even how they work Link to comment
TAPL Posted November 25, 2013 Share Posted November 25, 2013 https://wiki.multitheftauto.com/wiki/FindRotationThis function takes two sets of XY coordinates. It returns the direction from point A to point B. This can for example be used to make peds face a given point. Well, what is x1, y1, x2, y2? https://wiki.multitheftauto.com/wiki/FindRotation Xa: The X coordinate of the starting point. Ya: The Y coordinate of the starting point. Xb: The X coordinate of the target point. Yb: The Y coordinate of the target point. and what's "math.deg and math.atan2..and what's x2-x1,y2-y1 ..and what's t = t +360 ...please man tell me what or even how they work math.deg and math.atan2 is lua math function, findRotation is useful function you don't need to know how and why it made like this just use it. The example already showed how it used. ped = createPed(0, getElementPosition(localPlayer)) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(ped) local dis = getDistanceBetweenPoints2D(x, y, tx, ty) if dis > 2 then setPedControlState(ped, "forwards", true) else setPedControlState(ped, "forwards", false) end setPedRotation(ped, findRotation(tx, ty, x, y)) end) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end Line 13 is used to make the ped face you, so when it move forwards it will follow you. Link to comment
LiOneLMeSsIShoT Posted November 26, 2013 Author Share Posted November 26, 2013 https://wiki.multitheftauto.com/wiki/FindRotationThis function takes two sets of XY coordinates. It returns the direction from point A to point B. This can for example be used to make peds face a given point. Well, what is x1, y1, x2, y2? https://wiki.multitheftauto.com/wiki/FindRotation Xa: The X coordinate of the starting point. Ya: The Y coordinate of the starting point. Xb: The X coordinate of the target point. Yb: The Y coordinate of the target point. and what's "math.deg and math.atan2..and what's x2-x1,y2-y1 ..and what's t = t +360 ...please man tell me what or even how they work math.deg and math.atan2 is lua math function, findRotation is useful function you don't need to know how and why it made like this just use it. The example already showed how it used. ped = createPed(0, getElementPosition(localPlayer)) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(ped) local dis = getDistanceBetweenPoints2D(x, y, tx, ty) if dis > 2 then setPedControlState(ped, "forwards", true) else setPedControlState(ped, "forwards", false) end setPedRotation(ped, findRotation(tx, ty, x, y)) end) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end Line 13 is used to make the ped face you, so when it move forwards it will follow you. Alright well Thanks but can you make the script more simple with server side and trigger clinet side ? Link to comment
LiOneLMeSsIShoT Posted November 26, 2013 Author Share Posted November 26, 2013 Your turn to try. Tried already here viewtopic.php?f=91&t=67858 but need help 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