Bence2004 Posted December 23, 2019 Share Posted December 23, 2019 (edited) local weaponsWithSkin = {} function applyWeaponSkin (itemid) local shaderName = premiumItems[itemid][3] local shaderID = itemid setElementData(localPlayer, "weaponShaderID", shaderID) setElementData(localPlayer, "weaponShaderName", shaderName) setWeaponStickerC(localPlayer, shaderName, shaderID) end addEvent("applySkin", true) addEventHandler("applySkin", root, applyWeaponSkin) addEventHandler("onClientResourceStart", resourceRoot, function() for k, v in ipairs(getElementsByType("player")) do local weaponShaderName = getElementData(v, "weaponShaderName") or 0 local weaponShaderID = getElementData(v, "weaponShaderID") or 0 if (weaponShaderName ~= 0 and weaponShaderID ~= 0) then setWeaponStickerC(v, weaponShaderName, weaponShaderID) end end end) addEventHandler("onClientElementStreamIn", root, function() if getElementType(source) == "player" then local weaponShaderName = getElementData(localPlayer, "weaponShaderName") or 0 local weaponShaderID = getElementData(localPlayer, "weaponShaderID") or 0 if (weaponShaderName ~= 0 and weaponShaderID ~= 0) then setWeaponStickerC(source, isVehicleHavePaintjob) end end end) addEventHandler("onClientElementStreamOut", root, function() if getElementType(source) == "player" then local weaponShaderName = getElementData(localPlayer, "weaponShaderName") or 0 local weaponShaderID = getElementData(localPlayer, "weaponShaderID") or 0 if (weaponShaderName ~= 0 and weaponShaderID ~= 0) then removeWeaponStickerC(source) end end end) addEventHandler("onClientElementDestroy", root, function() if getElementType(source) == "player" then local weaponShaderName = getElementData(localPlayer, "weaponShaderName") or 0 local weaponShaderID = getElementData(localPlayer, "weaponShaderID") or 0 if (weaponShaderName ~= 0 and weaponShaderID ~= 0) then removeWeaponStickerC(source) end end end) function setWeaponStickerC(localPlayer, shaderName, shaderID) if shaderName and shaderID then removeWeaponStickerC(localPlayer) weaponsWithSkin[localPlayer] = {} weaponsWithSkin[localPlayer][1] = dxCreateShader("shaders/texturechanger.fx", 0, 100, false, "ped") weaponsWithSkin[localPlayer][2] = dxCreateTexture("textures/" .. shaderID .. ".png") if (weaponsWithSkin[localPlayer][1] and weaponsWithSkin[localPlayer][2]) then dxSetShaderValue(weaponsWithSkin[localPlayer][1], "TEXTURE", weaponsWithSkin[localPlayer][2]) engineApplyShaderToWorldTexture(weaponsWithSkin[localPlayer][1], "*" .. shaderName .. "*", localPlayer) else outputDebugString("Fegyverskinek: Hiba történt!", 3) end end end addEvent("setWeaponStickerC",true) addEventHandler("setWeaponStickerC", root, setWeaponStickerC) function removeWeaponStickerC(localPlayer) if localPlayer then if (weaponsWithSkin[localPlayer]) then destroyElement(weaponsWithSkin[localPlayer][1]) destroyElement(weaponsWithSkin[localPlayer][2]) weaponsWithSkin[localPlayer] = nil end end end addEvent("removeWeaponStickerC",true) addEventHandler("removeWeaponStickerC", root, removeWeaponStickerC) I want more weapons to display that texture at x times. I can't do it alone because I'm a little confused. Edited December 23, 2019 by Bence2004 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