Jump to content

Help with error!


Tycka

Recommended Posts

Code:

function getSkinIDFromName(name) 
  for i, skin in ipairs(skinTable) do 
    if name == skin[1] then 
      return skin[2] 
    end 
  end 
end 
function getSkinNameFromID(id) 
  for i, skin in ipairs(skinTable) do 
    if id == skin[2] then 
      return skin[1] 
    end 
  end 
end 
function addPlayerSkin(skin) 
  local current = getElementData(source, "skin") 
  local name = getSkinNameFromID(current) 
  setElementData(source, name, getElementData(source, name) + 1) 
  setElementData(source, skin, getElementData(source, skin) - 1) 
  local id = getSkinIDFromName(skin) 
  setElementData(source, "skin", id) 
  setElementModel(source, id) 
  triggerClientEvent(source, "refreshInventoryManual", source) 
end 
addEvent("onPlayerChangeSkin", true) 
addEventHandler("onPlayerChangeSkin", getRootElement(), addPlayerSkin) 

Error:

[2014-10-07 22:58:46] WARNING: [DayZ-MTA]\DayZ\survivorSystem.lua:892: Bad argument @ 'getElementData' [Expected string at argument 2, got nil] 
[2014-10-07 22:58:46] ERROR: [DayZ-MTA]\DayZ\survivorSystem.lua:892: attempt to perform arithmetic on a boolean value 
[2014-10-07 22:58:46] WARNING: [DayZ-MTA]\DayZ\survivorSystem.lua:892: Bad argument @ 'getElementData' [Expected string at argument 2, got nil] 
[2014-10-07 22:58:46] ERROR: [DayZ-MTA]\DayZ\survivorSystem.lua:892: attempt to perform arithmetic on a boolean value 
  

Link to comment

That should Work:

function getSkinIDFromName(name) 
  for i, skin in ipairs(skinTable) do 
    if name == skin[1] then 
      return skin[2] 
    end 
  end 
end 
function getSkinNameFromID(id) 
  for i, skin in ipairs(skinTable) do 
    if id == skin[2] then 
      return skin[1] 
    end 
  end 
end 
  
function addPlayerSkin(skin) 
  local current = getElementData(source, "skin") 
  local name = getSkinNameFromID(current) 
  setElementData(source, "name", getElementData(source, "name") + 1) 
  setElementData(source, "skin", getElementData(source, "skin") - 1) 
  local id = getSkinIDFromName(skin) 
  setElementData(source, "skin", id) 
  setElementModel(source, id) 
  triggerClientEvent(source, "refreshInventoryManual", source) 
end 
addEvent("onPlayerChangeSkin", true) 
addEventHandler("onPlayerChangeSkin", getRootElement(), addPlayerSkin) 

Link to comment

Don't get it risky for players!

Always use client at triggers!

  
function getSkinIDFromName(name) 
  for i, skin in ipairs(skinTable) do 
    if name == skin[1] then 
      return skin[2] 
    end 
  end 
end 
function getSkinNameFromID(id) 
  for i, skin in ipairs(skinTable) do 
    if id == skin[2] then 
      return skin[1] 
    end 
  end 
end 
function addPlayerSkin(skin) 
  local current = getElementData(client, "skin") or 0 
  local name = getSkinNameFromID(current) or "CJSkin" 
  setElementData(source, name, getElementData(client, name) + 1) 
  setElementData(source, skin, getElementData(client, skin) - 1) 
  local id = getSkinIDFromName(skin) 
  setElementData(client, "skin", id) 
  setElementModel(client, id) 
  triggerClientEvent(source, "refreshInventoryManual", source) 
end 
addEvent("onPlayerChangeSkin", true) 
addEventHandler("onPlayerChangeSkin", getRootElement(), addPlayerSkin) 
  

Link to comment
What is the error? and in which line of the code?

Error line: setElementData(source, "name", getElementData(source, "name") + 1)

Error: ERROR: [DayZ-MTA]\DayZ\survivorSystem.lua:893: attempt to perform arithmetic on a boolean value

FIXED.

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