Jump to content

small question about copy


AnDReJ98

Recommended Posts

hi guys

i have a question how to make the button to copy memo's data?

client.lua

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
  
GUIEditor_Window[1] = guiCreateWindow(188,173,427,273,"",false) 
GUIEditor_Memo[1] = guiCreateMemo(34,18,366,140,"funnction scriptCreateTank ( commandName ) 
\n      local luckyBugger = getLocalPlayer() -- get the local player 
\n      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position 
\n      createVehicle ( 432, x, y, z + 10 ) -- create te tank 10 units above them 
\n      outputChatBox ( \"You got Tank'd!\", 255, 0, 0) 
\nend 
\n addCommandHandle( \"tank\", scriptCreateTank )",false,GUIEditor_Window[1]) 
GUIEditor_Button[1] = guiCreateButton(71,182,266,59,"copy all ",false,GUIEditor_Window[1]) 

Edited by Guest
Link to comment
guiGetText 

If you meant to copy data to clipboard, well, I don't know if that can be done via scripting.

But the user can apply Ctrl + C.

It is possible, never seen this function: setClipboard?

Wiki quote:

This function sets the players clipboard text (what appears when you paste with CTRL + V) Note that there is no getClipBoard function for safety reasons.

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
  
GUIEditor_Window[1] = guiCreateWindow(188,173,427,273,"",false) 
GUIEditor_Memo[1] = guiCreateMemo(34,18,366,140,"funnction scriptCreateTank ( commandName ) 
\n      local luckyBugger = getLocalPlayer() -- get the local player 
\n      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position 
\n      createVehicle ( 432, x, y, z + 10 ) -- create te tank 10 units above them 
\n      outputChatBox ( \"You got Tank'd!\", 255, 0, 0) 
\nend 
\n addCommandHandle( \"tank\", scriptCreateTank )",false,GUIEditor_Window[1]) 
GUIEditor_Button[1] = guiCreateButton(71,182,266,59,"copy all ",false,GUIEditor_Window[1]) 
  
addEventHandler("onClientGUIClick",GUIEditor_Button[1], 
function () 
     setClipboard(tostring(guiGetText(GUIEditor_Memo[1]))) 
     outputChatBox("Data copied to clipboard.",0,255,0) 
end, false) 

Should work.

Link to comment
Into MTA you could, but outside, no.
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
  
GUIEditor_Window[1] = guiCreateWindow(188,173,427,273,"",false) 
GUIEditor_Memo[1] = guiCreateMemo(34,18,366,140,"funnction scriptCreateTank ( commandName ) 
\n      local luckyBugger = getLocalPlayer() -- get the local player 
\n      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position 
\n      createVehicle ( 432, x, y, z + 10 ) -- create te tank 10 units above them 
\n      outputChatBox ( \"You got Tank'd!\", 255, 0, 0) 
\nend 
\n addCommandHandle( \"tank\", scriptCreateTank )",false,GUIEditor_Window[1]) 
GUIEditor_Button[1] = guiCreateButton(71,182,266,59,"copy",false,GUIEditor_Window[1]) 
  
addEventHandler("onClientGUIClick",GUIEditor_Button[1], 
function () 
     setClipboard(tostring(guiGetText(GUIEditor_Memo[1]))) 
     outputChatBox("Data copied.",0,255,0) 
end, false) 
  
-----2----- 
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
  
GUIEditor_Window[1] = guiCreateWindow(188,173,427,273,"",false) 
data = guiCreateMemo(34,18,366,140,"",false,GUIEditor_Window[1]) 
paste = guiCreateButton(71,182,266,59,"paste",false,GUIEditor_Window[1]) 

i need make another gui (2)

when i click the butoon paste

its paste tha data

how to make this?

Link to comment

You can't, for this you must use element data, when click "Copy" use:

setElementData(localPlayer,"text",guiGetText(GUIEditor_Memo[1])) 

When you click "Paste" do:

local text = getElementData(localPlayer,"text") 
if (text and text ~= "") then 
     guiSetText(data, tostring(text)) 
end 
  

Link to comment
You can't, for this you must use element data, when click "Copy" use:
setElementData(localPlayer,"text",guiGetText(GUIEditor_Memo[1])) 

When you click "Paste" do:

local text = getElementData(localPlayer,"text") 
if (text and text ~= "") then 
     guiSetText(data, tostring(text)) 
end 
  

thanks you so much

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...