SetClipboard: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (moved SetClipBoard to SetClipboard: Case was wrong)
m (Corrections)
Line 5: Line 5:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setClipBoard ( string theText )
bool setClipboard ( string theText )
</syntaxhighlight>  
</syntaxhighlight>  


Line 20: Line 20:
   function( command, ... )
   function( command, ... )
       local text = table.concat({...}, " ") -- if the text has spaces this will turn it into a string
       local text = table.concat({...}, " ") -- if the text has spaces this will turn it into a string
       local success = setClipBoard( text ) -- check whether changing password worked
       local success = setClipboard( text ) -- set the clipboard and find out if it worked
       if success then
       if success then
         outputChatBox( "Clipboard text set to: " .. text, 0, 255, 0 ) -- if it did, tell the player
         outputChatBox( "Clipboard text set to: " .. text, 0, 255, 0 ) -- if it did, tell the player

Revision as of 12:22, 24 August 2011

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.

Syntax

bool setClipboard ( string theText )

Required Arguments

  • theText: The new text to be in the players clipboard when the player pastes with CTRL + V.

Returns

Returns true if the text in the clip board was set correctly.

Example

This example adds a command called clipboard which lets you set your clipboard text.

addCommandHandler( "clipboard", -- add a command handler for the command
   function( command, ... )
      local text = table.concat({...}, " ") -- if the text has spaces this will turn it into a string
      local success = setClipboard( text ) -- set the clipboard and find out if it worked
      if success then
         outputChatBox( "Clipboard text set to: " .. text, 0, 255, 0 ) -- if it did, tell the player
      else
         outputChatBox( "Failed to set the clipboards text", 255, 0, 0 ) -- if it didn't, tell the player
      end
   end
)

See Also