Daniel30896 Posted May 27, 2015 Share Posted May 27, 2015 Since I am a complete noob in LUA scripting, help me to understand your code and help to make it so that bots would not shoot at each other. local randomSpawnTable = { { -1970.82886, 661.22388, 46.57,}, { -1931.52368, 668.14990, 46.57 } } function Bot2 () local random = math.random ( #randomSpawnTable ) local x, y, z = unpack ( randomSpawnTable [ random ] ) Nemesis = exports [ "slothBot" ]:spawnBot ( -1569.7438964844, 656.30401611328, 7.1875, 90, math.random ( 300, 303 ), 0, 0, Nemesis, 30, "hunting", true ) if Nemesis then setElementModel ( Nemesis, 9 ) exports.extra_health:setElementExtraHealth ( Nemesis, 200 ) end end addEventHandler ( "onResourceStart", resourceRoot, Bot2 ) function Bot3 () local random = math.random ( #randomSpawnTable ) local x, y, z = unpack ( randomSpawnTable [ random ] ) Nemesis = exports [ "slothBot" ]:spawnBot ( -1559.7438964844, 656.30401611328, 7.1875, 90, math.random ( 300, 303 ), 0, 0, Nemesis, 30, "hunting", true ) if Nemesis then setElementModel ( Nemesis, 9 ) exports.extra_health:setElementExtraHealth ( Nemesis, 200 ) end end addEventHandler ( "onResourceStart", resourceRoot, Bot3 ) addEvent("onBotWasted", true) addEventHandler("onBotWasted", root, function() if (source == Nemesis) then setTimer(Bot2, 600000, 1) local attached = getAttachedElements ( source ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end) addEvent("onBotWasted", true) addEventHandler("onBotWasted", root, function() if (source == Nemesis) then setTimer(Bot3, 600000, 1) local attached = getAttachedElements ( source ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end) Link to comment
ALw7sH Posted May 27, 2015 Share Posted May 27, 2015 Use onBotFindEnemy event and check if the enemy is bot using isPedBot function 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