DanHR Posted November 15, 2018 Share Posted November 15, 2018 Can I set the texture part to a custom one using AddPedClothes? If so... how? What format does the texture need to be? Link to comment
Geteco Posted November 16, 2018 Share Posted November 16, 2018 (edited) Maybe should use shader? local shader = dxCreateShader("shader.fx", 0, 0, true, "ped") local texture = dxCreateTexture("texture.png") addEventHandler("onClientResourceStart", resourceRoot, function() engineApplyShaderToWorldTexture(shader, "cj_ped_torso") dxSetShaderValue(shader, "Tex0", texture) end) shader.fx Spoiler //-- Declare the texture. These are set using dxSetShaderValue( shader, "Tex0", texture ) texture Tex0; technique simple { pass P0 { Texture[0] = Tex0; } } Edited November 16, 2018 by Geteco 1 Link to comment
DanHR Posted November 16, 2018 Author Share Posted November 16, 2018 14 hours ago, Geteco said: Maybe should use shader? local shader = dxCreateShader("shader.fx", 0, 0, true, "ped") local texture = dxCreateTexture("texture.png") addEventHandler("onClientResourceStart", resourceRoot, function() engineApplyShaderToWorldTexture(shader, "cj_ped_torso") dxSetShaderValue(shader, "Tex0", texture) end) shader.fx Reveal hidden contents //-- Declare the texture. These are set using dxSetShaderValue( shader, "Tex0", texture ) texture Tex0; technique simple { pass P0 { Texture[0] = Tex0; } } This will only work for replacement right? I wanna have more textures than the default ones in order to add more clothes Link to comment
Geteco Posted November 16, 2018 Share Posted November 16, 2018 3 hours ago, Threule said: This will only work for replacement right? I wanna have more textures than the default ones in order to add more clothes local shader = dxCreateShader("shader.fx", 0, 0, true, "ped") local avaliableClothes = { {"cj_ped_torso", "1.png"}, {"cj_ped_torso", "2.png"}, {"cj_ped_torso", "3.png"}, {"cj_ped_torso", "4.png"} -- vector 1 = tex name, vector 2 = tex file } function createClothes(id) local clothes = getAvaliableClothes() local texture = dxCreateTexture(clothes[id][2]) if (id) then if (clothes[id]) then engineApplyShaderToWorldTexture(shader, clothes[id][1]) dxSetShaderValue(shader, "Tex0", texture) outputChatBox("creating shader") else outputChatBox("invalid id") end else outputChatBox("please provied an id") end end Link to comment
DanHR Posted November 16, 2018 Author Share Posted November 16, 2018 8 minutes ago, Geteco said: local shader = dxCreateShader("shader.fx", 0, 0, true, "ped") local avaliableClothes = { {"cj_ped_torso", "1.png"}, {"cj_ped_torso", "2.png"}, {"cj_ped_torso", "3.png"}, {"cj_ped_torso", "4.png"} -- vector 1 = tex name, vector 2 = tex file } function createClothes(id) local clothes = getAvaliableClothes() local texture = dxCreateTexture(clothes[id][2]) if (id) then if (clothes[id]) then engineApplyShaderToWorldTexture(shader, clothes[id][1]) dxSetShaderValue(shader, "Tex0", texture) outputChatBox("creating shader") else outputChatBox("invalid id") end else outputChatBox("please provied an id") end end With this I can play with 1.png and my friend with 2.png? Link to comment
Geteco Posted November 16, 2018 Share Posted November 16, 2018 (edited) 1 hour ago, Threule said: With this I can play with 1.png and my friend with 2.png? I don't know, if does not work, test code from below. client-side Spoiler local shader = dxCreateShader("fx/base.fx", 0, 0, true, "ped") local playersWithTex = {} local avaliableClothes = { {"cj_ped_torso", "1.png"}, {"cj_ped_torso", "3.png"}, {"cj_ped_torso", "4.png"}, -- vector 1 = tex name, vector 2 = tex file } function createClothes(thePlayer, id) if (thePlayer and id) then playersWithTex[thePlayer] = {} playersWithTex[thePlayer][1] = dxCreateTexture(avaliableClothes[id][2]) if (avaliableClothes[id]) then engineApplyShaderToWorldTexture(shader, avaliableClothes[id][1], thePlayer) dxSetShaderValue(shader, "Tex0", playersWithTex[thePlayer][1]) outputChatBox("creating shader") else outputChatBox("invalid id") end else outputChatBox("provied an id") end end addEvent("onClientCreateClothes", true) addEventHandler("onClientCreateClothes", root, createClothes) server-side Spoiler addCommandHandler("newc", function(player, cmd, id) triggerClientEvent("onClientCreateClothes", player, player, tonumber(id)) outputChatBox("generating clothes to player: " ..getPlayerName(player), root, 255, 255, 255, true) end) OBS: The first version of this code ins't work. use this one. Edited November 16, 2018 by Geteco 1 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