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
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)
Kérlek segítsetek! Teljes bezavarodtam már ebbe a pár sorba. Egy olyan skin rendszernek az alapját akarom megcsinálni, amit lehet egyidejüleg, egyszerre több fegyveren is használni 1 localplayernek. Ezzel a scriptel az a baj, hogyha több fegyverre állítok be skint akkor a szinkronizálást nem tudja végrehajtani csak 1 fegyveren.