• Print

Author Topic: Fixing a chat command  (Read 4279 times)

0 Members and 1 Guest are viewing this topic.

Offline CrazyCallum113

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Fixing a chat command
« on: October 01, 2013, 04:24:46 am »
Okay so I created a chat command to link to a url however when someone types it it opens the browser for everyone! How can I fix this?

Here's my code:
Code: [Select]
function ulx.fixerrors( calling_ply )
    for _, pl in ipairs( player.GetAll() ) do pl:SendLua([[gui.OpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=179287953")]]) end
end
local fixerrors = ulx.command( CATEGORY_NAME, "ulx fixerrors", ulx.fixerrors, "!fixerrors", true )
fixerrors:defaultAccess( ULib.ACCESS_ADMIN )
fixerrors:help( "Brings up the workshop collection of content to fix any errors on the server." )

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Fixing a chat command
« Reply #1 on: October 01, 2013, 07:29:04 pm »
Code: Lua
  1. calling_ply:SendLua([[gui.OpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=179287953")]])
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Fixing a chat command
« Reply #2 on: October 01, 2013, 07:49:38 pm »
As megiddo shows but doesn't exactly state, you don't need to do the for loop to grab all players.
You simply have the calling player run the command. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print