JeViCo Posted October 12, 2017 Share Posted October 12, 2017 Could somebody give me an example of skin changing with triggering server event? I found only with command\\ Link to comment
WorthlessCynomys Posted October 12, 2017 Share Posted October 12, 2017 Well you can use dxFunctions to make a button in that case you have to use the onClientClick event or you can create a gui button and then you have to use the onClientGUIClick event. button = guiCreateButton() addEventHandler("onClientGUIClick", button, function() -- do something end ) 1 Link to comment
Ahmed Ly Posted October 12, 2017 Share Posted October 12, 2017 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 ) 1 1 Link to comment
WorthlessCynomys Posted October 13, 2017 Share Posted October 13, 2017 Exactly. If you fill in the buttons arguments too then you'll have a clickable button. Have you made GUIs before? Do you need help? 1 Link to comment
JeViCo Posted October 13, 2017 Author Share Posted October 13, 2017 tnx u both so much, i just needed some functions at least . 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
WorthlessCynomys Posted October 13, 2017 Share Posted October 13, 2017 3 minutes ago, JeViCo said: tnx u both so much, i just needed some functions at least . 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 1 Link to comment
Scripting Moderators thisdp Posted October 14, 2017 Scripting Moderators Share Posted October 14, 2017 Maybe you will like it. 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