Jump to content

Respawn Slothbots


Soren

Recommended Posts

Posted

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!

Guest Guest4401
Posted

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

Posted
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

Posted

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) 

Posted
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

Posted

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) 

Posted
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

Posted

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?

Posted
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!

mta-screen_2012-05-27_08-11-22.png

mta-screen_2012-05-27_08-11-24.png

And 1 more problem! they all spawn with the same skin. Pls Help!

Posted
try removing the triggerServerEvent

or any event to those eventHandlers

No, cause if i remove the trigger, they will not spawn

Posted

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) 

Posted
[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 

Posted

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) 

Posted
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 :/

Posted

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) 

Posted
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) 
  

Posted
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) 

Posted
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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...