Jump to content

Bad Argument | Need help


myonlake

Recommended Posts

Hello,

I have one error on script that I downloaded from community.multitheftauto.com (link to the resource)

I guess some of you are experienced of scripting and can help me. I don't know how to script so well but I am trying to find out why Beta Carrier -script is saying bad argument error.

WARNING: carrier\Objects\Server\ObjCarrier.lua:32: Bad argument @ 'getResourceConfig'

WARNING: carrier\Objects\Server\ObjCarrier.lua:61: Bad argument @ 'getResourceConfig'

WARNING: carrier\Objects\Server\ObjCarrier.lua:81: Bad argument @ 'getResourceConfig'

-- server script 
-- MTA:SA Deathmatch 1.0 Developer preview 2 compatible
 
ObjCarrier = {}
ObjCarrier.__index = ObjCarrier
 
function ObjCarrier.create(resource)
  local _objCarrier = {}
  setmetatable(_objCarrier, ObjCarrier)
  _objCarrier._resource = resource
  _objCarrier._resourceMapRoot = false
  _objCarrier._centerToBase = 0
  _objCarrier._objects = {}
  _objCarrier._carriers = {}
  _objCarrier._samgroups =
    {
      ["sambow"] = {},
      ["samstern"] = {}
    }
  _objCarrier._panelgroups =
    {
      ["sidepanel"] = {},
      ["rearpanel"] = {},
      ["backdoor"] = {}
    }
  _objCarrier._mainTimer = false
  _objCarrier._funcMainTimer = nil
  return _objCarrier
end
 
function ObjCarrier:regCarrier(resourceMapRoot)
  local rootNode = getResourceConfig(self._resource, "../../config/objects.xml")
  local nextSibling = 0
  local firstSibling = false
  local node = false
  self._resourceMapRoot = resourceMapRoot
  self._centerToBase = get(getResourceName(self._resource) .. ".centertobase")
  if (rootNode) then
    node = xmlFindChild(rootNode, "object", nextSibling)
    while (node) do
      table.insert(self._objects,
          {
            ["name"] = xmlNodeGetAttribute(node, "name"),
            ["model"] = tonumber(xmlNodeGetAttribute(node, "model") or 0),
            ["posX"] = tonumber(xmlNodeGetAttribute(node, "posX") or 0),
            ["posY"] = tonumber(xmlNodeGetAttribute(node, "posY") or 0),
            ["posZ"] = tonumber(xmlNodeGetAttribute(node, "posZ") or 0),
            ["rotX"] = tonumber(xmlNodeGetAttribute(node, "rotX") or 0),
            ["rotY"] = tonumber(xmlNodeGetAttribute(node, "rotY") or 0),
            ["rotZ"] = tonumber(xmlNodeGetAttribute(node, "rotZ") or 0),
            ["object"] = false,
            ["xPosOffset"] = 0,
            ["yPosOffset"] = 0,
            ["zPosOffset"] = 0
          }
        )
      nextSibling = nextSibling + 1
      node = xmlFindChild(rootNode, "object", nextSibling)
    end
  end
  rootNode = getResourceConfig(self._resource, "../../config/samgroups.xml")
  if (rootNode) then
    for groupName, group in pairs(self._samgroups) do
      nextSibling = 0
      firstSibling = xmlFindChild(rootNode, groupName, nextSibling)
      if (firstSibling) then
        node = xmlFindChild(firstSibling, "mover", nextSibling)
        while (node) do
          table.insert(self._samgroups[groupName],
              {
                ["time"] = tonumber(xmlNodeGetAttribute(node, "time") or 0) / 1000,
                ["moverZ"] = tonumber(xmlNodeGetAttribute(node, "moverZ") or 0)
              }
            )
          nextSibling = nextSibling + 1
          node = xmlFindChild(firstSibling, "mover", nextSibling)
        end
      end
    end
  end
  rootNode = getResourceConfig(self._resource, "../../config/panelgroups.xml")
  if (rootNode) then
    for groupName, group in pairs(self._panelgroups) do
      nextSibling = 0
      firstSibling = xmlFindChild(rootNode, groupName, nextSibling)
      if (firstSibling) then
        node = xmlFindChild(firstSibling, "target", nextSibling)
        while (node) do
          table.insert(self._panelgroups[groupName],
              {
                ["time"] = tonumber(xmlNodeGetAttribute(node, "time") or 0),
                ["targetX"] = tonumber(xmlNodeGetAttribute(node, "targetX") or 0),
                ["targetY"] = tonumber(xmlNodeGetAttribute(node, "targetY") or 0),
                ["targetZ"] = tonumber(xmlNodeGetAttribute(node, "targetZ") or 0)
              }
            )
          nextSibling = nextSibling + 1
          node = xmlFindChild(firstSibling, "target", nextSibling)
        end
      end
    end
  end
  self._funcMainTimer =
    function ()
      for _, carrier in ipairs(self._carriers) do
        for groupName, group in pairs(self._samgroups) do
          if (carrier.count >= self._samgroups[groupName][carrier.mover].time) then
            moveObject(carrier[groupName .. "clone"], self._samgroups[groupName][carrier.mover].time * 1000, 0, 0, -100, 0, 0, self._samgroups[groupName][carrier.mover].moverZ)
            if ((carrier.mover + 1) > #self._samgroups[groupName]) then
              carrier.mover = 1
            else
              carrier.mover = carrier.mover + 1
            end
            carrier.count = 1
          else
            carrier.count = carrier.count + 1
          end
        end
      end
      self._mainTimer = setTimer(self._funcMainTimer, 1000, 1)
    end
  self._funcMainTimer()
end
 
function ObjCarrier:createCarrier(posX, posY, posZ, rot)
  local gX, gY, gZ = 0, 0, 0
  local oX, oY, oZ = 0, 0, 0
  table.insert(self._carriers,
      {
        ["id"] = "carrier" .. (#self._carriers + 1),
        ["parent"] = false,
        ["objects"] = self._objects,
        ["samgroups"] = {},
        ["panelgroups"] = {},
        ["mover"] = 1,
        ["target"] =
          {
            ["sidepanel"] = 1,
            ["rearpanel"] = 1,
            ["backdoor"] = 1
          },
        ["count"] = 1,
        ["teamplayers"] = {}
      }
    )
  oX, oY, oZ = self._carriers[#self._carriers].objects[1].posX, self._carriers[#self._carriers].objects[1].posY, self._carriers[#self._carriers].objects[1].posZ
  for _, object in ipairs(self._carriers[#self._carriers].objects) do
    gX = math.abs(posX - oX)
    gY = math.abs(posY - oY)
    if (object.posX > posX) then
      gX = object.posX - gX
    else
      gX = object.posX + gX
    end
    if (object.posY > posY) then
      gY = object.posY - gY
    else
      gY = object.posY + gY
    end
    object.posX = gX
    object.posY = gY
    object.object = createObject(
        object.model,
        object.posX,
        object.posY,
        object.posZ,
        object.rotX,
        object.rotY,
        object.rotZ
      )
    for groupName, group in pairs(self._samgroups) do
      if (object.name == groupName) then
        setElementID(object.object, self._carriers[#self._carriers].id .. "." .. groupName)
        self._carriers[#self._carriers][groupName .. "clone"] = cloneElement(object.object, 0, 0, -100, false)
        setElementID(self._carriers[#self._carriers][groupName .. "clone"], self._carriers[#self._carriers].id .. "." .. groupName .. "clone")
      end
    end
    for groupName, group in pairs(self._panelgroups) do
      if (object.name == groupName) then
        setElementID(object.object, self._carriers[#self._carriers].id .. "." .. groupName)
        self._carriers[#self._carriers][groupName .. "clone"] = cloneElement(object.object, 0, 0, -100, false)
        setElementID(self._carriers[#self._carriers][groupName .. "clone"], self._carriers[#self._carriers].id .. "." .. groupName .. "clone")
      end
    end
  end
  self._carriers[#self._carriers].parent = createVehicle(453, posX, posY, posZ, 0, 0, 0)
  setElementID(self._carriers[#self._carriers].parent, self._carriers[#self._carriers].id)
  setElementAlpha(self._carriers[#self._carriers].parent, 0)
  setVehicleDamageProof(self._carriers[#self._carriers].parent, true)
  toggleVehicleRespawn(self._carriers[#self._carriers].parent, false)
  for _, object in ipairs(self._carriers[#self._carriers].objects) do
    setElementParent(object.object, self._carriers[#self._carriers].parent)
    gX = math.abs(posX - object.posX)
    gY = math.abs(posY - object.posY)
    gZ = object.posZ + self._centerToBase
    if (object.posX < posX) then
      gX = -(gX)
    end
    if (object.posY < posY) then
      gY = -(gY)
    end
    object.xPosOffset = gX
    object.yPosOffset = gY
    object.zPosOffset = gZ
    if (object.name == "hull" or object.name == "hangar") then
      setElementID(object.object, "carrier." .. object.name)
    end
    for groupName, group in pairs(self._samgroups) do
      if (object.name == groupName) then
        self._carriers[#self._carriers].samgroups[groupName] =
          {
            ["xPosOffset"] = object.xPosOffset,
            ["yPosOffset"] = object.yPosOffset,
            ["zPosOffset"] = object.zPosOffset,
            ["targetPending"] = false,
            ["timer"] = false,
            ["maxPlayers"] = 8,
            ["totalLaunched"] = 0,
            ["support"] =
              {
                ["barrage"] =
                  {
                    ["timer"] = false,
                    ["maxPlayers"] = 1,
                    ["totalLaunched"] = 0
                  }
              },
            ["creatorPlayers"] = {}
          }
      end
    end
    for groupName, group in pairs(self._panelgroups) do
      if (object.name == groupName) then
        self._carriers[#self._carriers].panelgroups[groupName] =
          {
            ["xPosOffset"] = object.xPosOffset,
            ["yPosOffset"] = object.yPosOffset,
            ["zPosOffset"] = object.zPosOffset,
            ["rotX"] = object.rotX,
            ["rotY"] = object.rotY,
            ["rotZ"] = object.rotZ
          }
      end
    end
    attachElements(object.object, self._carriers[#self._carriers].parent, object.xPosOffset, object.yPosOffset, object.zPosOffset, object.rotX, object.rotY, object.rotZ)
  end
  setVehicleRotation(self._carriers[#self._carriers].parent, 0, 0, -(rot))
  return {["parent"] = self._carriers[#self._carriers].parent, ["id"] = self._carriers[#self._carriers].id}
end
 
function ObjCarrier:getCarriers()
  local carriers = {}
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...