NastaseValy

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

Share this post


Link to post

First error simply says that there is no table named weaponSkinTable and the second one tells you to add an end after loaded = false.

Share this post


Link to post

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

Share this post


Link to post

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)  

Share this post


Link to post

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'

Share this post


Link to post
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) 

Share this post


Link to post
Thanks a lot, no error, but why do I load the weapon skins?

I don't know. Try using outputDebugString to see what the problem is.

Share this post


Link to post

I have added some new weapons and SVD DMR. We solved all their bugs, but when I load a weapon skin (CZ, DMR, SVD) put the same skin on all three weapons. What is the problem?

Share this post


Link to post

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.