• Print

Author Topic: Custom Command to Open a Specific URL  (Read 7071 times)

0 Members and 1 Guest are viewing this topic.

Offline [DP] ISR Mafia

  • Newbie
  • *
  • Posts: 7
  • Karma: -1
Custom Command to Open a Specific URL
« on: June 03, 2015, 11:17:30 pm »
Hey Everyone !

Code: [Select]
function urlCommand( pl, text, teamonly )
    if (text == "!site") then
    pl:SendLua([[gui.OpenURL("http://dudeperfectgmodcommunity.weebly.com")]]) -- Change ADDRESS to your chosen page.
    for k, v in pairs(player.GetAll()) do v:ChatPrint( " " .. pl:Nick() .. " has Entered DP's Site & Checks What's New via !site" )

end
end
end
hook.Add( "PlayerSay", "Chat", urlCommand

i tried this code to open that url for everyone who says !site in chat (my server's site) but i cant get it to work can anyone help me make one that will actually work?

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
Re: Custom Command to Open a Specific URL
« Reply #1 on: June 04, 2015, 12:49:01 am »
You did good for a first, you just made one simple error, on the last line you didn't close it
Code: [Select]
hook.Add( "PlayerSay", "Chat", urlCommandJust change it to
Code: [Select]
hook.Add( "PlayerSay", "Chat", urlCommand ) and it will work fine.

FULL:
Code: Lua
  1. function urlCommand( pl, text, teamonly )
  2.                     if (text == "!site") then
  3.                             pl:SendLua([[gui.OpenURL("http://dudeperfectgmodcommunity.weebly.com")]]) -- Change ADDRESS to your chosen page.
  4.                             for k, v in pairs(player.GetAll()) do v:ChatPrint( " " .. pl:Nick() .. " has entered DP's site & checked what's new via !site" )
  5.  
  6.                 end
  7.         end
  8. end
  9. hook.Add( "PlayerSay", "Chat", urlCommand )
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

Offline [DP] ISR Mafia

  • Newbie
  • *
  • Posts: 7
  • Karma: -1
Re: Custom Command to Open a Specific URL
« Reply #2 on: June 04, 2015, 03:47:06 am »
ah thank you very much for answering ! :D i have another question tho hahah can i have couple of these same functions in my lua/autorun or just 1 ?

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Custom Command to Open a Specific URL
« Reply #3 on: June 04, 2015, 05:23:08 am »
If you're going to make multiple, PLEASE change the second parameter to hook.Add.
That is a unique hook identifier for a reason. Keep it unique.
bw81@ulysses-forums ~ % whoami
Homepage

Offline [DP] ISR Mafia

  • Newbie
  • *
  • Posts: 7
  • Karma: -1
Re: Custom Command to Open a Specific URL
« Reply #4 on: June 04, 2015, 06:11:12 am »
If you're going to make multiple, PLEASE change the second parameter to hook.Add.
That is a unique hook identifier for a reason. Keep it unique.
 

can u script it for me or show me i kinda didnt understand what second parameter refers to..... Thx  !

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Custom Command to Open a Specific URL
« Reply #5 on: June 04, 2015, 06:16:15 am »
 

can u script it for me or show me i kinda didnt understand what second parameter refers to..... Thx  !
It is what it sounds like, really.

Code: [Select]
hook.Add(string event, string identifier, function callback)You'll want to change your hook.Add calls to look like this:
Code: Lua
  1. hook.Add("PlayerSay", "myURLcommand1", callback)
bw81@ulysses-forums ~ % whoami
Homepage

Offline [DP] ISR Mafia

  • Newbie
  • *
  • Posts: 7
  • Karma: -1
Re: Custom Command to Open a Specific URL
« Reply #6 on: June 04, 2015, 06:29:58 am »
Code: [Select]
    function urlCommand( pl, text, teamonly )
        if (text == "!site") then
        pl:SendLua([[gui.OpenURL("http://dudeperfectgmodcommunity.weebly.com")]]) -- Change ADDRESS to your chosen page.
        for k, v in pairs(player.GetAll()) do v:ChatPrint( "" .. pl:Nick() .. " Has Entered Our Site & Checking What Is New via !site" )
     
    end
    end
    end
    hook.Add( "PlayerSay", "myURLCommand1", callback )






Its Not Working For Me :(
« Last Edit: June 04, 2015, 09:36:53 am by [DP] ISR Mafia »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom Command to Open a Specific URL
« Reply #7 on: June 04, 2015, 03:59:58 pm »
There's a release in our releases section that allows for multiple html windows.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aharon Tager

  • Newbie
  • *
  • Posts: 37
  • Karma: 0
    • Barely Legal Gaming
Re: Custom Command to Open a Specific URL
« Reply #8 on: June 07, 2015, 07:39:06 am »
Code: [Select]
    function urlCommand( pl, text, teamonly )
        if (text == "!site") then
        pl:SendLua([[gui.OpenURL("http://dudeperfectgmodcommunity.weebly.com")]]) -- Change ADDRESS to your chosen page.
        for k, v in pairs(player.GetAll()) do v:ChatPrint( "" .. pl:Nick() .. " Has Entered Our Site & Checking What Is New via !site" )
     
    end
    end
    end
    hook.Add( "PlayerSay", "myURLCommand1", callback )






Its Not Working For Me :(

Change
Code: [Select]
hook.Add( "PlayerSay", "myURLCommand1", callback )To this:
Code: [Select]
hook.Add( "PlayerSay", "myURLCommand1", urlCommand )

Offline [DP] ISR Mafia

  • Newbie
  • *
  • Posts: 7
  • Karma: -1
Re: Custom Command to Open a Specific URL
« Reply #9 on: June 09, 2015, 07:38:45 am »
Thank you so much its working !!! :3

  • Print