VenomOG Posted September 18, 2019 Share Posted September 18, 2019 Hey im trying to get keys that are binded to a function basically im gonna get bounded keys from a function lets say a test function ("use") im trying to get those bounded keys and use them in a client side i found a function getBoundKeys ( ) i was wondering if i can do it like keys = {} local zz = 0 local keys = getBoundKeys ( "use" ) -- get the keys bound to this control if not keys then -- make sure the control name is valid and any keys are bound to it removeEventHandler("onClientRender",root,SOMETHING) return end if keys then addEventHandler("onClientRender",root,function() for keyName, state in pairs(keys) do zz = zz+50 dxDrawText(keyName, 1083, 190+zz, 1149, 206, tocolor(255, 255, 255, 255), 0.9, "default-bold", "center", "top", false, false, true, false, false) end end end) end something like this, its just something off the bat of my head or example but basically i will draw couple texts and its like diffrent variables in a row Link to comment
VenomOG Posted September 18, 2019 Author Share Posted September 18, 2019 update . Im also looking for if specific Binds example ["Tires"] ["Mask"] ["Gas"] ["Title"] players usually do Bind key use Itemname Link to comment
Moderators IIYAMA Posted September 18, 2019 Moderators Share Posted September 18, 2019 2 hours ago, Network said: something like this, its just something off the bat of my head or example but basically i will draw couple texts and its like diffrent variables in a row For debugging or for your players? In case of debugging you can do just this: dxDrawText(inspect(keys), 1083, 190+zz, 1149, 206, tocolor(255, 255, 255, 255), 0.9, "default-bold") Not recommended for showing it to your players. Link to comment
VenomOG Posted September 18, 2019 Author Share Posted September 18, 2019 3 hours ago, IIYAMA said: For debugging or for your players? In case of debugging you can do just this: dxDrawText(inspect(keys), 1083, 190+zz, 1149, 206, tocolor(255, 255, 255, 255), 0.9, "default-bold") Not recommended for showing it to your players. What does inspect to, thanks tho read my second reply does it do that? ------------------------------ -- Authors: IIYAMA and Kenix -- ------------------------------ local addEventHandler = addEventHandler; local removeEventHandler = removeEventHandler; local table_remove = table.remove; local unpack = unpack; local len = table.getn; local root = root; local renderEvents = { "onClientRender", "onClientPreRender", "onClientHUDRender" } local allTargetFunctions = {} -- All attached functions will be stored in this table. local acceptedRenderEventTypes = {} -- Is type in use? See: renderEvents. local renderEventTypeStatus = {} -- Is the event in use? (so it doesn't have to be attached again) do -- prepare the data for i=1, len( renderEvents ) do local event = renderEvents[i] allTargetFunctions[event] = {} acceptedRenderEventTypes[event] = true renderEventTypeStatus[event] = false end end -- render all events here local processTargetFunction = function ( timeSlice ) local targetFunctions = allTargetFunctions[ eventName ] local i = 1 local itemCount = len(targetFunctions) repeat if targetFunctions[ i ] == true then -- remove = true table_remove( targetFunctions, i ) itemCount = itemCount - 1 else local targetFunctionData = targetFunctions[i] local arguments = targetFunctionData[2] if not arguments then targetFunctionData[ 1 ]( timeSlice ) else if timeSlice then targetFunctionData[ 1 ]( timeSlice, unpack( arguments ) ) else targetFunctionData[ 1 ]( unpack( arguments ) ) end end i = i + 1 end until i > itemCount end -- check if a function is already attached function isRenderEventAdded (theFunction, event) if not event or not acceptedRenderEventTypes[event] then event = "onClientRender" end local targetFunctions = allTargetFunctions[event] for i = 1, len( targetFunctions ) do if targetFunctions[i] and targetFunctions[i] ~= true and targetFunctions[i][1] == theFunction then return true end end return false end local isRenderEventAdded = isRenderEventAdded -- add render event, default type is onClientRender function addRenderEvent(theFunction, event, ...) if not event or not acceptedRenderEventTypes[event] then event = "onClientRender" end if not isRenderEventAdded(theFunction) then local targetFunctions = allTargetFunctions[event] -- Don't pass an arguments if it not needed. local aArgs = { ... }; local mArgs = len( aArgs ) > 0 and aArgs or nil; targetFunctions[ len( targetFunctions ) + 1 ] = { theFunction, mArgs } -- attach an event if not renderEventTypeStatus[event] then addEventHandler (event, root, processTargetFunction, false, "high") renderEventTypeStatus[event] = true end return true end return false end -- remove a render event function removeRenderEvent(theFunction, event) if not event or not acceptedRenderEventTypes[event] then event = "onClientRender" end local targetFunctions = allTargetFunctions[event] for i = 1, len( targetFunctions ) do if targetFunctions[i] and targetFunctions[i] ~= true and targetFunctions[i][1] == theFunction then targetFunctions[i] = true -- true = remove if len( targetFunctions ) == 0 then if renderEventTypeStatus[event] then removeEventHandler (event, root, processTargetFunction) renderEventTypeStatus[event] = false end end return true end end return false end ----------------- function dxDrawRelativeText( text,posX,posY,right,bottom,color,scale,mixed_font,alignX,alignY,clip,wordBreak,postGUI ) local resolutionX = 1366 local resolutionY = 768 local sWidth,sHeight = guiGetScreenSize( ) return dxDrawText( tostring( text ), ( posX/resolutionX )*sWidth, ( posY/resolutionY )*sHeight, ( right/resolutionX )*sWidth, ( bottom/resolutionY)*sHeight, color, ( sWidth/resolutionX )*scale, mixed_font, alignX, alignY, clip, wordBreak, postGUI ) end function dxDrawRelativeRectangle( posX, posY, width, height,color,postGUI ) local resolutionX = 1366 local resolutionY = 768 local sWidth,sHeight = guiGetScreenSize( ) return dxDrawRectangle( ( posX/resolutionX )*sWidth, ( posY/resolutionY )*sHeight, ( width/resolutionX )*sWidth, ( height/resolutionY )*sHeight, color, postGUI ) end function dxDrawRelativeImage( posX, posY, width, height,link,r1,r2,r3,color,postGUI ) local resolutionX = 1366 local resolutionY = 768 local sWidth,sHeight = guiGetScreenSize( ) return dxDrawImage( ( posX/resolutionX )*sWidth, ( posY/resolutionY )*sHeight, ( width/resolutionX )*sWidth, ( height/resolutionY )*sHeight, ""..link, r1, r2, r3, color, postGUI ) end function dxDrawRelativeLine( posX, posY, width, height,color, size, postGUI ) local resolutionX = 1366 local resolutionY = 768 local sWidth,sHeight = guiGetScreenSize( ) return dxDrawLine( ( posX/resolutionX )*sWidth, ( posY/resolutionY )*sHeight, ( width/resolutionX )*sWidth, ( height/resolutionY )*sHeight, color, size, postGUI ) end function drawkeys(keys,key) local z1 = 0 for keyName, state in pairs(keys) do z1 = z1+90 dxDrawRelativeText(keyName, 0+z1, 455, 109, 469, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false) end dxDrawRelativeLine(86 - 1, 411 - 1, 86 - 1, 450, tocolor(254, 254, 254, 132), 1, false) dxDrawRelativeLine(303, 411 - 1, 86 - 1, 411 - 1, tocolor(254, 254, 254, 132), 1, false) dxDrawRelativeLine(86 - 1, 450, 303, 450, tocolor(254, 254, 254, 132), 1, false) dxDrawRelativeLine(303, 450, 303, 411 - 1, tocolor(254, 254, 254, 132), 1, false) dxDrawRelativeRectangle(86, 411, 217, 39, tocolor(0, 0, 0, 132), false) dxDrawRelativeImage(90, 411, 45, 39, ":SAEGTradeSystem/images/dmt.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRelativeImage(145, 411, 45, 39, ":SAEGTradeSystem/images/pcp.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRelativeImage(200, 411, 45, 39, ":SAEGTradeSystem/images/cocaine.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRelativeImage(252, 411, 45, 39, ":SAEGTradeSystem/images/morphine.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end addEvent("triggerKeys",true) addEventHandler("triggerKeys",root,function() controlName = "use" local keys = getBoundKeys ( controlName ) -- get the keys bound to this control if not keys then -- make sure the control name is valid and any keys are bound to it removeEventHandler("onClientRender",root,drawkeys) return end addRenderEvent(drawkeys,"onClientRender",keys,keys) end) I used your functions - they worked for rendering but its showing all keys binded to "use" command i just wanna find ["Tires"]["Mask"]["Gas"]["Title"] 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