Author Topic: ULX - SteamID to clipboard  (Read 3600 times)

0 Members and 1 Guest are viewing this topic.

Offline Snell

  • Newbie
  • *
  • Posts: 11
  • Karma: 2
ULX - SteamID to clipboard
« on: March 13, 2014, 11:49:52 PM »
This is my code
http://pastebin.com/1BviDHau
or
Code: [Select]
function ulx.floop ( calling_ply, target_ply )

calling_ply:SetClipboardText ( target_ply:SteamID()  )
ulx.fancyLogAdmin( calling_ply, true, "#A copied the SteamID of #T", target_ply )

end
local floop = ulx.command ( CATEGORY_NAME, "ulx id", ulx.floop, "!id" )
floop:addParam{ type=ULib.cmds.PlayersArg }
floop:defaultAccess ( ULib.ACCESS_ALL )
floop:help ( "Copies target's SteamID" )

I have tried a lot, with no success. The recurring error re guards the method "SteamID" being a Nil Value.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX - SteamID to clipboard
« Reply #1 on: March 14, 2014, 09:12:55 AM »
I believe I had a similar issue, just with a different code: http://forums.ulyssesmod.net/index.php/topic,6722.msg32743.html#msg32743

Try changing "PlayersArg" to "PlayerArg" on line 8 (according to the Pastebin).

Edit: I forgot to CTRL+V the post I was referring to...
« Last Edit: March 14, 2014, 02:41:17 PM by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX - SteamID to clipboard
« Reply #2 on: March 14, 2014, 01:55:19 PM »
ULib.cmds.PlayersArg returns a table of player objects, even if the table only has one object.
You'd have to cycle through it using for loop.
ULib.cmds.PlayerArg will only be one player object.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Snell

  • Newbie
  • *
  • Posts: 11
  • Karma: 2
Re: ULX - SteamID to clipboard
« Reply #3 on: March 14, 2014, 05:55:56 PM »
This is what happened when I tested the Altered Code, I really have no idea what happened
http://i.imgur.com/04TsWMN.jpg

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: ULX - SteamID to clipboard
« Reply #4 on: March 14, 2014, 07:56:14 PM »
SetClipboardText is a clientside function.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULX - SteamID to clipboard
« Reply #5 on: March 14, 2014, 09:37:05 PM »
So try..

calling_ply:SendLua("LocalPlayer():SetClipboardText( target_ply:SteamID() )")

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: ULX - SteamID to clipboard
« Reply #6 on: March 15, 2014, 09:14:04 AM »
So try..

calling_ply:SendLua("LocalPlayer():SetClipboardText( target_ply:SteamID() )")
You don't need LocalPlayer() for that.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULX - SteamID to clipboard
« Reply #7 on: March 15, 2014, 10:16:21 AM »
Ahh, yeah. Indeed you don't. I just took his 'server side' code and made it 'client side' verbatim.

You would need this:

Code: [Select]
calling_ply:SendLua("SetClipboardText( target_ply:SteamID() )")

Offline Snell

  • Newbie
  • *
  • Posts: 11
  • Karma: 2
Re: ULX - SteamID to clipboard
« Reply #8 on: March 15, 2014, 10:51:41 PM »
Firstly, Thank you MrPresident for the SendLua (I tested it and worked with a basic string)

This is my current code, and apparently the Universe Explodes if these 2 functions a put together. (I tested the 2 seperately)
http://pastebin.com/hdcCe4C0

Code: [Select]
-- Copies Target's SteamID to Clipboard
function ulx.steam_id ( calling_ply, target_ply )

local steamid = tostring ( target_ply:SteamID() )

calling_ply:SendLua( " SetClipboardText ( " .. steamid .. " ) " )

-- calling_ply:SendLua( " SetClipboardText ( 'taco' ) " ) -- Sets Clipboard to Taco, works and tested

-- Prints targets SteamID to console (works and tested)
Msg ( steamid )
ulx.fancyLogAdmin ( calling_ply, true, "#A's clipboard consist of #T's SteamID", target_ply )

end

local steam_id = ulx.command ( CATEGORY_NAME, "ulx id", ulx.steam_id, "!id" )
steam_id:addParam { type = ULib.cmds.PlayerArg }
steam_id:defaultAccess ( ULib.ACCESS_ALL )
steam_id:help ( "Copies the Target's SteamID to Clipboard." )

Console and Server Error
Code: [Select]
[ERROR] LuaCmd:1: '<name>' expected near '0'
  1. unknown - LuaCmd:0

I fixed (with a friend) this to my knowledge and it works, so thank you for you help.
« Last Edit: March 16, 2014, 12:20:04 AM by Snell »