Hello, I am new to scripting and I´m trying to open my own server, everything has gone good, but I have a problem I have not been able to solve, i need to have for example different type of M4´s with different skins and different damage with also different sound, what I currently have is this:
Weapon Skin:
engineReplaceModel(dff, 358)
txd = engineLoadTXD("awp.txd", 358 )
engineImportTXD(txd, 358)
dff = engineLoadDFF("awp.dff", 358 )
engineReplaceModel(dff, 358)
Weapon Audio:
addEventHandler("onClientPlayerWeaponFire", getRootElement(),
function ( weapon, ammo, ammoInClip )
local x,y,z = getElementPosition(source)
if weapon == 34 then
local sound = playSound3D("awp.mp3", x,y,z)
setSoundMaxDistance(sound,75)
end
end
)
I have tried to use objects as weapons, but I have had no success, i heard for the weapon skin it is possible to put a shader over it, but I dont have idea on how to do so, I know it is possible since i saw this code for a DayZ Script:
function loadModels()
weapontxd1 = engineLoadTXD ("models/weap/ak47.txd");
weapondff1 = engineLoadDFF ("models/weap/ak47.dff");
end
addEventHandler("onClientResourceStart",root,loadModels)
function onClientPlayerSkinChange()
if getElementData(localPlayer,"currentweapon_1") == "FNFAL" then
if getElementData(localPlayer,"done") == true then return end
engineImportTXD (weapontxd1, 355);
engineReplaceModel (weapondff1, 355);
setElementData( localPlayer, "done", true)
elseif getElementData(localPlayer,"currentweapon_1") == "AK-47" then
engineRestoreModel(355)
setElementData( localPlayer, "done", false)
else
engineRestoreModel(355)
setElementData( localPlayer, "done", false)
end
end
addEventHandler("onClientPlayerWeaponSwitch",localPlayer,onClientPlayerSkinChange)
I don´t want the code, i just would like to know what functions to use, thank you.