Jump to content

[HELP]Avatar shader


Looney;3

Recommended Posts

server

local Avatars = {}

function onPlayLogin (_, playeraccount )
	if isPlayerLogged(source) then
		Avatars[source] = createElement("dxAvatar")
		callClientFunction(root,"dxCreateAvatarlist",getAccountName(playeraccount), Avatars[source],source)
	end
end
addEventHandler ( "onPlayerLogin", getRootElement(), onPlayLogin )

Create Avatar

function dxCreateAvatarlist(player,elementAvatar,playerid)
if not getElementData(elementAvatar,"dxAvatarCreate") then
		setElementData(elementAvatar,"dxAvatarCreate",true)
		setElementData(elementAvatar,"dxAvatarPlayer",player)
		local shader = dxCreateShader("hud_mask.fx")
		setElementData(elementAvatar,"dxAvatarShader",shader)
		local avatar = dxCreateTexture("files/img/guest.png","dxt3")
		setElementData(elementAvatar,"dxAvatarImage",avatar)
		local mask = dxCreateTexture("files/img/circle_mask.png","dxt3")
		setElementData(elementAvatar,"dxAvatarMask",mask)
		local path = ":avatars/avatars/"..getElementData(elementAvatar,"dxAvatarPlayer")..".png"
		if fileExists(path) then
		setElementData(elementAvatar,"dxAvatarImage",path)
		end
		dxSetShaderValue( getElementData(elementAvatar,"dxAvatarShader"), "sPicTexture",  getElementData(elementAvatar,"dxAvatarImage"))
		dxSetShaderValue( getElementData(elementAvatar,"dxAvatarShader"), "sMaskTexture", getElementData(elementAvatar,"dxAvatarMask"))
		dxSetShaderValue( getElementData(elementAvatar,"dxAvatarShader"), "gUVPosition", 0,0 )
		dxSetShaderValue( getElementData(elementAvatar,"dxAvatarShader"), "gUVScale", 0.0005*sX, 0.0005*sX)
		dxSetShaderValue( getElementData(elementAvatar,"dxAvatarShader"), "gUVRotAngle", math.rad(0) )
		if getElementData(elementAvatar,"dxAvatarShader") then
		print("Shader Avatar:"..getElementData(elementAvatar,"dxAvatarPlayer"))
		end
	end
end

Draw

function render()
   for id,dxAvatar in pairs(getElementsByType("dxAvatar")) do
      if getElementData(dxAvatar,"dxAvatarPlayer") == account and getElementData(dxAvatar,"dxAvatarShader") then
      dxDrawImage(0.15*sX+(sizeX-0.17*sX)/2-(rowSize-0.01*sY)-(long/2),rowSize*(id-1)-scrollPosition+0.005*sY,rowSize-0.01*sY,rowSize-0.01*sY, getElementData(dxAvatar,"dxAvatarShader"), 0,0,0, tocolor(255,255,255,255))
      end
   end
end
addEventHandler("onClientRender",root,render)

 

Why dont work?? help
porque verga no anda? me ayudan porfis

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...