Tycka Posted October 8, 2014 Share Posted October 8, 2014 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
n3wage Posted October 8, 2014 Share Posted October 8, 2014 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
Tycka Posted October 8, 2014 Author Share Posted October 8, 2014 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 Link to comment
Anubhav Posted October 8, 2014 Share Posted October 8, 2014 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
Castillo Posted October 9, 2014 Share Posted October 9, 2014 What is the error? and in which line of the code? Link to comment
Tycka Posted October 10, 2014 Author Share Posted October 10, 2014 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
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