tzn Posted June 13 Share Posted June 13 I'm a beginner and I don't know how to make my bot always work, that is, it doesn't matter if there are players nearby or not. Without a player, the bot stops working. Server function bot_move(ped, point) if (isElement(ped)) then if (getElementData(ped, "serverbot") == true) then local point = getElementData(ped, "point") local px, py, pz = getElementPosition(ped) if not isElement(pickup) then local random = math.random(1,#point) tx,ty,tz = point[random][1],point[random][2],point[random][3] pickup = createMarker ( tx, ty, tz, "cylinder", 1.5, 255, 255, 0, 170, ped ) end local fdist = (getDistanceBetweenPoints3D(px, py, pz, tx, ty, tz)) if fdist > 2 then local angle = (360 - math.deg(math.atan2((tx - px), (ty - py)))) % 360 setPedRotation(ped, angle) triggerClientEvent("bot_Forwards", ped) setTimer(bot_move, 10, 1, ped, point) else triggerClientEvent("bot_animFarm", ped) destroyElement(pickup) setElementData(ped, "point", nil) setElementData(ped, "point", point) setTimer(bot_start_move, 100, 1, ped) end end end end function bot_start_move(ped) local point = getElementData(ped, "point") setTimer(bot_move, 200, 1, ped, point) end function createBot(x, y, z, skin, point) local bot = createPed(tonumber(skin), tonumber(x), tonumber(y), tonumber(z)) if not point then point = nil end if (bot ~= nil) then setElementData(bot, "serverbot", true) setElementData(bot, "fire", boolFire) setElementData(bot, "point", point) return bot end end a = createBot(-376.03802, -1434.80457, 25.72656, 110, m) bot_start_move(a) Client addEvent("bot_Forwards", true) function Bforward() if (isElement(source)) then setPedControlState(source, "forwards", true) end end addEventHandler("bot_Forwards", getRootElement(), Bforward) addEvent("bot_animFarm", true) function Banimation() if (isElement(source)) then setTimer(setPedAnimation, 1, 1, source, 'CARRY','liftup') setTimer(setPedAnimation, 1000, 1, source, 'CARRY', 'crry_prtial') end end addEventHandler("bot_animFarm", getRootElement(), Banimation) Link to comment
Spakye Posted June 16 Share Posted June 16 Hello, not sure if it will work but you can try to make it move when your bot is streamed in with onClientElementStreamIn or to make it always streamed with setElementStreamable. 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