Jump to content

Skin change with window


JeViCo

Recommended Posts

button = guiCreateButton()

addEventHandler("onClientGUIClick",root,
function () 
if source == button then 
triggerServerEvent("ChangeSkin",localPlayer,46,"Change Skin to id")
end
end
)




addEvent("ChangeSkin",true) 
addEventHandler("ChangeSkin",root,
function (id,text) 
setElementModel(source,id) 
outputChatBox(""..text.." ["..id.."]",source,255,0,0,true)
end
)

 

  • Like 1
  • Thanks 1
Link to comment

tnx u both so much, i just needed some functions at least xD. By the way i have a problem with creating dx gui. Dx gui shows after pressed binded key(two times pressed) after that enough to press key 1 time to show/hide gui. What makes it do like that? (sry for poor english knowledge :$)

full code

local screenW, screenH = guiGetScreenSize()
local x,y,z = getElementPosition ( getLocalPlayer ( ) )

function isMouseInPosition ( x, y, width, height )
	if ( not isCursorShowing( ) ) then
		return false
	end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

function togglePanel()
  if (dxVisible == false) then
    dxVisible = true
	showCursor ( true )
  else
    dxVisible = false
	showCursor ( false )
  end
end
bindKey("i","down",togglePanel)

addEventHandler("onClientRender", root,
  function ()
    if (dxVisible == true) then
		-- rectagle + img drawing code
	 end
  end
)

function onClick(button, state)
	if (dxVisible == true) and (button == "left") and (state == "up") then
		-- check if dx-rectangle is showing here
		if isMouseInPosition( 490, 284, 116, 47 ) then --button1
		-- change player skin
		elseif isMouseInPosition( 737, 284, 116, 47 ) then --button2
		-- creating vehicle here
		end
	end
end
addEventHandler( "onClientClick", root, onClick )

 

Link to comment
3 minutes ago, JeViCo said:

tnx u both so much, i just needed some functions at least xD. By the way i have a problem with creating dx gui. Dx gui shows after pressed binded key(two times pressed) after that enough to press key 1 time to show/hide gui. What makes it do like that? (sry for poor english knowledge :$)

full code


local screenW, screenH = guiGetScreenSize()
local x,y,z = getElementPosition ( getLocalPlayer ( ) )

function isMouseInPosition ( x, y, width, height )
	if ( not isCursorShowing( ) ) then
		return false
	end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

function togglePanel()
  if (dxVisible == false) then
    dxVisible = true
	showCursor ( true )
  else
    dxVisible = false
	showCursor ( false )
  end
end
bindKey("i","down",togglePanel)

addEventHandler("onClientRender", root,
  function ()
    if (dxVisible == true) then
		-- rectagle + img drawing code
	 end
  end
)

function onClick(button, state)
	if (dxVisible == true) and (button == "left") and (state == "up") then
		-- check if dx-rectangle is showing here
		if isMouseInPosition( 490, 284, 116, 47 ) then --button1
		-- change player skin
		elseif isMouseInPosition( 737, 284, 116, 47 ) then --button2
		-- creating vehicle here
		end
	end
end
addEventHandler( "onClientClick", root, onClick )

 

You have to declare dxVisible.

Your problem is that dxVisible is nil, so when you press the key it is set to false. When you press the key again it is set to true.

So at the beginning if the code, put dxVisible = false

  • Thanks 1
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...