Ulysses
General => Developers Corner => Topic started by: Snell on March 13, 2014, 11:49:52 PM
-
This is my code
http://pastebin.com/1BviDHau (http://pastebin.com/1BviDHau)
or
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.
-
I believe I had a similar issue, just with a different code: http://forums.ulyssesmod.net/index.php/topic,6722.msg32743.html#msg32743 (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...
-
ULib.cmds.PlayersArg (http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html#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 (http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html#cmds.PlayerArg) will only be one player object.
-
This is what happened when I tested the Altered Code, I really have no idea what happened
http://i.imgur.com/04TsWMN.jpg (http://i.imgur.com/04TsWMN.jpg)
-
SetClipboardText is a clientside function.
-
So try..
calling_ply:SendLua("LocalPlayer():SetClipboardText( target_ply:SteamID() )")
-
So try..
calling_ply:SendLua("LocalPlayer():SetClipboardText( target_ply:SteamID() )")
You don't need LocalPlayer() for that.
-
Ahh, yeah. Indeed you don't. I just took his 'server side' code and made it 'client side' verbatim.
You would need this:
calling_ply:SendLua("SetClipboardText( target_ply:SteamID() )")
-
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 (http://pastebin.com/hdcCe4C0)
-- 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
[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.