knightscript Posted January 11, 2016 Share Posted January 11, 2016 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. Link to comment
#RooTs Posted January 11, 2016 Share Posted January 11, 2016 Look Weapon Sound https://community.multitheftauto.com/in ... ls&id=2702 DownLoad pack Weapon Skin click here Link to comment
#RooTs Posted January 11, 2016 Share Posted January 11, 2016 Example Weapon Skin in client side --------------AK 47--------------------- txd = engineLoadTXD("armas/ak47.txd") engineImportTXD(txd, 355) dff = engineLoadDFF("armas/ak47.dff", 355) engineReplaceModel(dff, 355) ------------Desert eagle----------------------- txd = engineLoadTXD("armas/desert_eagle.txd") engineImportTXD(txd, 348) dff = engineLoadDFF("armas/desert_eagle.dff", 348) engineReplaceModel(dff, 348) --------------M4---------------------- txd = engineLoadTXD("armas/m4.txd") engineImportTXD(txd, 356) dff = engineLoadDFF("armas/m4.dff", 356) engineReplaceModel(dff, 356) -------------MP5----------------------- txd = engineLoadTXD("armas/mp5.txd") engineImportTXD(txd, 353) dff = engineLoadDFF("armas/mp5.dff", 353) engineReplaceModel(dff, 353) --------------shotgun---------------------- txd = engineLoadTXD("armas/chromegun.txd") engineImportTXD(txd, 349) dff = engineLoadDFF("armas/chromegun.dff", 349) engineReplaceModel(dff, 349) ---------------Sniper--------------------- txd = engineLoadTXD("armas/sniper.txd") engineImportTXD(txd, 358) dff = engineLoadDFF("armas/sniper.dff", 358) engineReplaceModel(dff, 358) ---------------shotgspa12--------------------- txd = engineLoadTXD("armas/shotgspa.txd") engineImportTXD(txd, 351) dff = engineLoadDFF("armas/shotgspa.dff", 351) engineReplaceModel(dff, 351) Example Weapon Sound in client side local function playGunfireSound(weaponID) local source = getLocalPlayer() local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition(source) local px, py, pz = getElementPosition ( source ) if weaponID == 22 then --colt45 local sound = playSound3D("sounds/weap/Colt45.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 23 then local sound = playSound3D("sounds/weap/Silenced.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 24 then--deagle local sound = playSound3D("sounds/weap/Deagle.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 25 then--shotgun local sound = playSound3D("sounds/weap/Shotgun.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 26 then--sawn-off local sound = playSound3D("sounds/weap/Sawed-Off.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 27 then--combat shotgun local sound = playSound3D("sounds/weap/Combat Shotgun.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 28 then--uzi local sound = playSound3D("sounds/weap/UZI.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 32 then--tec-9 local sound = playSound3D("sounds/weap/tec9.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 29 then--mp5 local sound = playSound3D("sounds/weap/MP5.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 30 then--ak47 local sound = playSound3D("sounds/weap/AK-47.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 31 then--m4 local sound = playSound3D("sounds/weap/M4.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 33 then--rifle local sound = playSound3D("sounds/weap/Rifle.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 34 then--sniper local sound = playSound3D("sounds/weap/Sniper.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) elseif weaponID == 16 then--grenade local sound = playSound3D("sounds/weap/Bomba.mp3", muzzleX, muzzleY, muzzleZ, false) setSoundMaxDistance(sound, 40) end end addEventHandler("onClientPlayerWeaponFire", root, playGunfireSound) Link to comment
knightscript Posted January 12, 2016 Author Share Posted January 12, 2016 Thanks for your reply, i know how to add weapons, but what I want to do is add different models and sounds for 1 weapon id, lets say 2 M4´s -M4A1 -M4A3 Link to comment
#RooTs Posted January 12, 2016 Share Posted January 12, 2016 Thanks for your reply, i know how to add weapons, but what I want to do is add different models and sounds for 1 weapon id, lets say 2 M4´s-M4A1 -M4A3 I think it's not possible Link to comment
killeryoyo Posted January 12, 2016 Share Posted January 12, 2016 Thanks for your reply, i know how to add weapons, but what I want to do is add different models and sounds for 1 weapon id, lets say 2 M4´s-M4A1 -M4A3 I think it's not possible it's possible i think, because they did it with the skins once in a server. Link to comment
Addlibs Posted January 12, 2016 Share Posted January 12, 2016 No, it's not possible. Unless they had changed all weapon models' textures to full transparency and then attached MTA objects through bone_attach. Default MTA weapons aren't elements, and therefore you cannot target them with dxSetShaderTexture (however, you can target all weapons of a particular weapon, or rather, a specific texture from all models) Link to comment
knightscript Posted January 13, 2016 Author Share Posted January 13, 2016 Then how does the DayZ gamemode for MTA does it? Link to comment
Addlibs Posted January 14, 2016 Share Posted January 14, 2016 DayZ doesn't care about other players' weapons — It replaces the weapon model on your client, every weapon model. This means if you look at another player, he might be wielding a Makarov PM while, on his end, it is actually a flashlight — this is because you may be wielding a Makarov PM as well. https://github.com/mtadayz/MTADayZ/blob ... switch.lua Link to comment
knightscript Posted January 14, 2016 Author Share Posted January 14, 2016 And how can I add this to a non-dayz gamemode? Link to comment
Incama Posted January 17, 2016 Share Posted January 17, 2016 Just make all the weapon textures (usually only 1) 100% transparent and then attach an object which is a weapon, that is the only way it is possible to do this. Link to comment
knightscript Posted January 22, 2016 Author Share Posted January 22, 2016 What functions should I use for this? Link to comment
Evan Posted September 5, 2017 Share Posted September 5, 2017 add invisible for ur sniper 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