Soren Posted May 26, 2012 Share Posted May 26, 2012 Hi all, im working on my server but i got a little problem. I want to make slothbots spawn around you but sometimes they got underground and i hate that, i also wanted to make that when you kill a slothbot 1 min after a slothbots spawn replaicing him. Pls i need help! Link to comment
Guest Guest4401 Posted May 26, 2012 Share Posted May 26, 2012 For the height problem, add an amount to the z position to increase height For example, spawnBot(x, y, z+5) For the 1 minute respawn, use setTimer in the event onBotWasted Link to comment
Soren Posted May 26, 2012 Author Share Posted May 26, 2012 local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin for i = 1,10 do call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker,weapon,bodypart) local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(math.floor(21,23)) call ( getResourceFromName ( "slothbot" ), "spawnBot", x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) I have this . i got some problems. Dont span at random places (span in a line) and still dont respawn Link to comment
Flaker Posted May 26, 2012 Share Posted May 26, 2012 Try this: (instead of 11 and 26 strings) local dec = math.random(7,40) call ( getResourceFromName ( "slothbot" ), "spawnBot", x+v, y+dec, z, rot, skin, int, dim, teamZombie, weapon) Link to comment
Soren Posted May 26, 2012 Author Share Posted May 26, 2012 Try this:(instead of 11 and 26 strings) local dec = math.random(7,40) call ( getResourceFromName ( "slothbot" ), "spawnBot", x+v, y+dec, z, rot, skin, int, dim, teamZombie, weapon) This resolved the random position thingy. But i still cant respawn the slothbot Link to comment
Jaysds1 Posted May 26, 2012 Share Posted May 26, 2012 try this: local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin for i = 1,10 do exports.slothbot:spawnBot(x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker,weapon,bodypart) local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(math.floor(21,23)) local dec = math.random(7,40) exports.slothbot:spawnBot(x+y, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Link to comment
Soren Posted May 26, 2012 Author Share Posted May 26, 2012 try this:local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin for i = 1,10 do exports.slothbot:spawnBot(x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker,weapon,bodypart) local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(math.floor(21,23)) local dec = math.random(7,40) exports.slothbot:spawnBot(x+y, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Does not work,now the zombies does not spawn Link to comment
Flaker Posted May 27, 2012 Share Posted May 27, 2012 You spawn bots in "onSpawnSlothBot" event! In order to spawn bots, need to call this Event! Otherwise, you just did not execute the code inside the function "onSpawnSlothBot" Are you sure, that you have triggered "onSpawnSlothBot" event? Link to comment
Soren Posted May 27, 2012 Author Share Posted May 27, 2012 You spawn bots in "onSpawnSlothBot" event! In order to spawn bots, need to call this Event! Otherwise, you just did not execute the code inside the function "onSpawnSlothBot"Are you sure, that you have triggered "onSpawnSlothBot" event? addEventHandler("onClientResourceStart",root, function() triggerServerEvent("onSpawnSlothBot",localPlayer) end ) Edit: With this they spawn, but when i kill them all they dont respawn. and i have other problem, the spanw in the same line! And 1 more problem! they all spawn with the same skin. Pls Help! Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 try removing the triggerServerEvent or any event to those eventHandlers Link to comment
Soren Posted May 27, 2012 Author Share Posted May 27, 2012 try removing the triggerServerEventor any event to those eventHandlers No, cause if i remove the trigger, they will not spawn Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 try this: local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) local skin = math.random(math.floor(21,23)) -- Entre 21 y 23 el skin for i = 1,10 do exports.slothbot:spawnBot(x+i, y+i, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onBotSpawned",true) addEventHandler("onBotSpawned",getRootElement(),onSpawnSlothBot)--it's onBotSpawned not onSpawnBot function onBotWasted(attacker,weapon,bodypart) local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(math.floor(21,23)) local dec = math.random(7,40) exports.slothbot:spawnBot(x+y, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Link to comment
Soren Posted May 27, 2012 Author Share Posted May 27, 2012 [2012-05-27 09:16:35] restart: Requested by Console [2012-05-27 09:16:35] restart: Resource restarting... [2012-05-27 09:16:35] Stopping monstruos [2012-05-27 09:16:35] Resource 'monstruos' changed, reloading and starting [2012-05-27 09:16:35] Starting monstruos [2012-05-27 09:16:35] SCRIPT ERROR: monstruos\server.lua:13: '' expected near 'end' [2012-05-27 09:16:35] WARNING: Loading script failed: monstruos\server.lua:13: '' expected near 'end' [2012-05-27 09:16:35] monstruos restarted successfully [2012-05-27 09:16:35] ERROR: Client triggered serverside event onBotSpawned, but event is not added serverside Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 wait, I'm looking back at the onBotSpawned, Are you trying to get the player's position? or the bots? Link to comment
Flaker Posted May 27, 2012 Share Posted May 27, 2012 Try this code: local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) for i = 1,10 do local skin = math.random(21,23) local dec = math.random(5,40) exports.slothbot:spawnBot(x+dec, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker, weapon, bodypart) if (attacker) then local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(21,23) local dec = math.random(7,40) exports.slothbot:spawnBot(x + dec, y + dec, z, rot, skin, int, dim, teamZombie, weapon) else outputDebugString("Attacker doesn't exist") end end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Link to comment
Soren Posted May 27, 2012 Author Share Posted May 27, 2012 Try this code: local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) for i = 1,10 do local skin = math.random(21,23) local dec = math.random(5,40) exports.slothbot:spawnBot(x+dec, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker, weapon, bodypart) if (attacker) then local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(21,23) local dec = math.random(7,40) exports.slothbot:spawnBot(x + dec, y + dec, z, rot, skin, int, dim, teamZombie, weapon) else outputDebugString("Attacker doesn't exist") end end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Thx , it works expect for 1 thing. They still spawn in a line Link to comment
Flaker Posted May 28, 2012 Share Posted May 28, 2012 Try: local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) math.randomseed(os.time()) for i = 1,10 do local skin = math.random(21,23) local dec = math.random(10,200) exports.slothbot:spawnBot(x+dec, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker, weapon, bodypart) if (attacker) then local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 math.randomseed(os.time()) local skin = math.random(21,23) local dec = math.random(10,200) exports.slothbot:spawnBot(x + dec, y + dec, z, rot, skin, int, dim, teamZombie, weapon) else outputDebugString("Attacker doesn't exist") end end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Link to comment
Soren Posted May 28, 2012 Author Share Posted May 28, 2012 Try: local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) math.randomseed(os.time()) for i = 1,10 do local skin = math.random(21,23) local dec = math.random(10,200) exports.slothbot:spawnBot(x+dec, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker, weapon, bodypart) if (attacker) then local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 math.randomseed(os.time()) local skin = math.random(21,23) local dec = math.random(10,200) exports.slothbot:spawnBot(x + dec, y + dec, z, rot, skin, int, dim, teamZombie, weapon) else outputDebugString("Attacker doesn't exist") end end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) [2012-05-28 15:25:49] Starting monstruos [2012-05-28 15:25:49] start: Resource 'monstruos' started [2012-05-28 15:25:49] ADMIN: Resource 'monstruos' started by i#000000[S]#66ff55oReN(soren) [2012-05-28 15:25:49] ERROR: monstruos\server.lua:10: attempt to index global 'os' (a nil value) Link to comment
Flaker Posted May 28, 2012 Share Posted May 28, 2012 local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) for i = 1,10 do local skin = math.random(21,23) local dec = math.random(20,300) exports.slothbot:spawnBot(x+dec, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker, weapon, bodypart) if (attacker) then local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(21,23) local dec = math.random(20,300) exports.slothbot:spawnBot(x + dec, y + dec, z, rot, skin, int, dim, teamZombie, weapon) else outputDebugString("Attacker doesn't exist") end end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Link to comment
Soren Posted May 28, 2012 Author Share Posted May 28, 2012 local teamZombie = createTeam("Zombies") function onSpawnSlothBot() local x, y, z = getElementPosition (source) local rot = 0 local int = getElementInterior(source) local dim = getElementDimension(source) local weapon = 0 setTeamFriendlyFire(teamZombie,false) for i = 1,10 do local skin = math.random(21,23) local dec = math.random(20,300) exports.slothbot:spawnBot(x+dec, y+dec, z, rot, skin, int, dim, teamZombie, weapon) end end addEvent("onSpawnSlothBot",true) addEventHandler("onSpawnSlothBot",getRootElement(),onSpawnSlothBot) function onBotWasted(attacker, weapon, bodypart) if (attacker) then local x,y,z = getElementPosition(attacker) local rot = 0 local int = getElementInterior(attacker) local dim = getElementDimension(attacker) local weapon = 0 local skin = math.random(21,23) local dec = math.random(20,300) exports.slothbot:spawnBot(x + dec, y + dec, z, rot, skin, int, dim, teamZombie, weapon) else outputDebugString("Attacker doesn't exist") end end addEvent("onBotWasted",true) addEventHandler("onBotWasted",getRootElement(),onBotWasted) Now works! Thx! 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