Jump to content

The problem to change skin


Recommended Posts

Load skin:

weaponTXD = {} 
weaponDFF = {} 
  
function loadTheSkins() 
    for i, skin in ipairs(weaponSkinTable) do 
        weaponTXD[i] = engineLoadTXD(":DayZ/models/weapons/txd/"..skin[1]..".txd") 
        weaponDFF[i] = engineLoadDFF(":DayZ/models/weapons/dff/"..skin[1]..".dff", 0) 
    end 
end  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loadTheSkins) 

ERROR: [DayZ-Mod]/dayz/loadskin.lua:5: bad argument #1 to 'ipairs' (table expected, got nil)

Replace model:

local loaded = false 
  
function onClientPlayerSkinChange(prevSlot,newSlot) 
local getSlot = getPedWeaponSlot(localPlayer) 
    if newSlot == 0 then 
        loaded = false 
    elseif newSlot == 3 then 
        if getElementData(localPlayer,"currentweapon_1") == "DMR" then 
            if not loaded then 
                engineImportTXD(weaponTXD[1], 358) 
                engineReplaceModel(weaponDFF[1],358) 
                loaded = true 
            else 
                return 
            end 
    elseif getElementData(localPlayer,"currentweapon_1") == "SVD Camo" then 
            if not loaded then 
                engineImportTXD(weaponTXD[2], 358) 
                engineReplaceModel(weaponDFF[2],358) 
                loaded = true 
            else 
                 return 
            end 
        else 
            engineRestoreModel(358) 
            loaded = false 
addEventHandler("onClientPlayerWeaponSwitch",localPlayer,onClientPlayerSkinChange)   

ERROR: Loading script falied: [DayZ-Mod]/dayz/replacemodel.lua:27: 'end' expected (to close 'if' at line 8) near ''

Link to comment

Thank you for Loadskin.

but I still give me error replacemodel, i also added an end as you said

local loaded = false 
  
function onClientPlayerSkinChange(prevSlot,newSlot) 
local getSlot = getPedWeaponSlot(localPlayer) 
    if newSlot == 0 then 
        loaded = false 
    elseif newSlot == 3 then 
        if getElementData(localPlayer,"currentweapon_1") == "DMR" then 
            if not loaded then 
                engineImportTXD(weaponTXD[1], 358) 
                engineReplaceModel(weaponDFF[1],358) 
                loaded = true 
            else 
                return 
            end 
    elseif getElementData(localPlayer,"currentweapon_1") == "SVD Camo" then 
            if not loaded then 
                engineImportTXD(weaponTXD[2], 358) 
                engineReplaceModel(weaponDFF[2],358) 
                loaded = true 
            else 
                 return 
            end 
        else 
            engineRestoreModel(358) 
            loaded = false 
            end 
addEventHandler("onClientPlayerWeaponSwitch",localPlayer,onClientPlayerSkinChange)   

ERROR: Loading script falied: [DayZ-Mod]/dayz/replacemodel.lua:28: 'end' expected (to close 'if' at line 5) near ''

Link to comment

Try this one :

local loaded = false 
  
function onClientPlayerSkinChange(prevSlot,newSlot) 
local getSlot = getPedWeaponSlot(localPlayer) 
    if newSlot == 0 then 
        loaded = false 
    elseif newSlot == 3 then 
        if getElementData(localPlayer,"currentweapon_1") == "DMR" then 
            if not loaded then 
                engineImportTXD(weaponTXD[1], 358) 
                engineReplaceModel(weaponDFF[1],358) 
                loaded = true 
            else 
                return 
            end 
        elseif getElementData(localPlayer,"currentweapon_1") == "SVD Camo" then 
            if not loaded then 
                engineImportTXD(weaponTXD[2], 358) 
                engineReplaceModel(weaponDFF[2],358) 
                loaded = true 
            else 
                 return 
            end 
        else 
            engineRestoreModel(358) 
            loaded = false 
        end 
    end  
end  
addEventHandler("onClientPlayerWeaponSwitch",localPlayer,onClientPlayerSkinChange)  

Link to comment

THX! And here?

weaponSkinTable = { 
{"dmr",1,"DMR"}, 
{"svdcamo",1,"SVD Camo"}, 
} 
  
weaponTXD = {} 
weaponDFF = {} 
  
function loadTheSkins() 
    for i, skin in ipairs(weaponSkinTable) do 
        weaponTXD[i] = engineLoadTXD(":DayZ/models/weapons/txd/"..skin[1]..".txd") 
        weaponDFF[i] = engineLoadDFF(":DayZ/models/weapons/dff/"..skin[1]..".dff", 0) 
        end 
    end 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loadTheSkins) 

ERROR: Loading script failed: [DayZ-Mod]/dayz/loadskin.lua:15: '' expected near 'end'

Link to comment
ERROR: Loading script failed: [DayZ-Mod]/dayz/loadskin.lua:15: '' expected near 'end'
local weaponSkinTable = { 
    {"dmr",1,"DMR"}, 
    {"svdcamo",1,"SVD Camo"}, 
} 
  
local weaponTXD = {} 
local weaponDFF = {} 
  
function loadTheSkins() 
    for i, skin in pairs(weaponSkinTable) do 
        weaponTXD[i] = engineLoadTXD(":DayZ/models/weapons/txd/"..skin[1]..".txd") 
        weaponDFF[i] = engineLoadDFF(":DayZ/models/weapons/dff/"..skin[1]..".dff", 0) 
    end 
end  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loadTheSkins) 

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