Jump to content

What is wrong?


iPanda

Recommended Posts

I create bots. Not to write a lot of code, I took the variable "i", but for some reason does not work. The following error occurred.

local sniper = {} 
addEventHandler("onResourceStart", resourceRoot, function() 
    local sniper[1] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    local sniper[2] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    local sniper[3] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    local sniper[4] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    for i=1,4 do 
        setElementHealth( sniper[i], 100 ) 
    end 
end) 

ojcHJ4D6bIo.jpg

Link to comment

Not tested but you did the for statement wrong i believe.

  
sniper = {} 
addEventHandler("onResourceStart", resourceRoot, function() 
    local sniper[1] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    local sniper[2] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    local sniper[3] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    local sniper[4] = exports.slothbot:spawnBot( myX, myY, myZ, 0,  286, 0, 0, nil, 33, "guarding", true ) 
    for _,data in ipairs(sniper) do 
        setElementHealth( data, 100 ) 
    end 
end) 
  

Link to comment
  • Moderators
What is wrong?
local sniper = {} 
addEventHandler("onResourceStart", resourceRoot, function() 

local sniper[1] = exports.slothbot:spawnBot( myX, myY, myZ, 0, 286, 0, 0, nil, 33, "guarding", true )

local sniper[2] = exports.slothbot:spawnBot( myX, myY, myZ, 0, 286, 0, 0, nil, 33, "guarding", true )

local sniper[3] = exports.slothbot:spawnBot( myX, myY, myZ, 0, 286, 0, 0, nil, 33, "guarding", true )

local sniper[4] = exports.slothbot:spawnBot( myX, myY, myZ, 0, 286, 0, 0, nil, 33, "guarding", true )

    for _,data in ipairs(sniper) do 
        setElementHealth( data, 100 ) 
    end 
end) 
  

That's wrong...
Link to comment

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...