evex Posted March 4, 2017 Share Posted March 4, 2017 Hey Iam using Slothbot and I want to make that player wont see when bot spawns so I tried to make the radius bigger After I added +100 bot dont spawn any help? function spawnBot(x, y, z, rot, skin, interior, dimension, team, weapon, mode, modesubject) if not x then return false end if not y then return false end if not z then return false end if not rot then return false end if not skin then skin = 0 end if not interior then interior = 0 end if not dimension then dimension = 0 end if isElement(team) == false then team = nil end if not weapon then weapon = 0 end if not mode then mode = "hunting" end if not modesubject then modesubject = nil end if mode == "following" then if not modesubject then return false end end if mode == "chasing" then if not modesubject then return false end end local slothbot = createPed (tonumber(skin),tonumber(x+100),tonumber(y+100),tonumber(z+100))--SPOT I CHANGED Link to comment
Mr.Loki Posted March 4, 2017 Share Posted March 4, 2017 This isn't the radius you are just adding 100 to the x, y and z positions. 100 z is spawning the peds in the air plus the 100 x and y is adding to that making it spawn really far from the player. This example calculates a random position around the player with a radius of 20 function spawnThePed(plr) local x,y,z = getElementPosition(plr) local radius = 20 local r = math.random(360) x = x - math.sin ( math.rad(r) ) * radius y = y + math.cos ( math.rad(r) ) * radius createPed(211,x,y,z) end addCommandHandler("spawn",spawnThePed) Link to comment
evex Posted March 5, 2017 Author Share Posted March 5, 2017 (edited) I think I added ur example bad becose its not working. function spawnBot(x, y, z, rot, skin, interior, dimension, team, weapon, mode, modesubject) --checks the function commands to see if all neccesary parts are filled, sets defaults if not or returns false. if not x then return false end if not y then return false end if not z then return false end if not rot then return false end if not skin then skin = 0 end if not interior then interior = 0 end if not dimension then dimension = 0 end if isElement(team) == false then team = nil end if not weapon then weapon = 0 end if not mode then mode = "hunting" end if not modesubject then modesubject = nil end if mode == "following" then if not modesubject then return false end end if mode == "chasing" then if not modesubject then return false end end local radius = 20 local r = math.random(360) x = x - math.sin ( math.rad(r) ) * radius y = y + math.cos ( math.rad(r) ) * radius local slothbot = createPed (tonumber(skin),tonumber(x),tonumber(y),tonumber(z))--spawns the ped if (slothbot ~= false) then triggerEvent ( "onBotSpawned", slothbot ) setTimer ( setElementData, 200, 1, slothbot, "slothbot", true ) -- makes it a bot setTimer ( setElementData, 200, 1, slothbot, "AllowFire", true ) -- makes it able to shoot when it wants setTimer ( assigncontroller, 300, 1, slothbot ) --sets the bots controller setTimer ( giveWeapon, 800, 1, slothbot, tonumber(weapon), 99999, true ) --gives the weapon setElementData(slothbot, "BotWeapon", tonumber(weapon)) if team ~= nil then setElementData(slothbot, "BotTeam", team) end setTimer ( setElementInterior, 100, 1, slothbot, tonumber(interior)) --sets interior setTimer ( setElementDimension, 100, 1, slothbot, tonumber(dimension)) --sets dimension --sets the mode if mode == "waiting" then setTimer ( setElementData, 600, 1, slothbot, "status", "waiting") elseif mode == "following" then setTimer ( setElementData, 400, 1, slothbot, "leader", modesubject ) setTimer ( setElementData, 600, 1, slothbot, "status", "following") elseif mode == "chasing" then setTimer ( setElementData, 400, 1, slothbot, "target", modesubject ) setTimer ( setElementData, 600, 1, slothbot, "status", "chasing") elseif mode == "guarding" then setTimer ( setBotGuard, 400, 1, slothbot, x, y, z) else setTimer ( setElementData, 600, 1, slothbot, "status", "hunting") end return slothbot end end Edited March 5, 2017 by evex Link to comment
Mr.Loki Posted March 5, 2017 Share Posted March 5, 2017 Don't modify the slothbot resource, nothing needs to be changed in it. you have to learn about using exported functions. In another resource where you want to spawn the bots use this for example function spawnThePed(plr) local x,y,z = getElementPosition(plr) local radius = 20 local r = math.random(360) x = x - math.sin ( math.rad(r) ) * radius y = y + math.cos ( math.rad(r) ) * radius exports.slothbot:spawnBot(x,y,z,r) end addCommandHandler("spawn",spawnThePed) 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