Hey
Seen a lot of Gmod DarkRP server where you can ride !workshop in the chat and the workshop pops up. but how do i make that happen? can't find anything about it
Look at the PlayerSay page on the Gmod wiki, then use ply:SendLua and gui.OpenURL
can you be a little more specific? some example. i don't understand what to do
[QUOTE=meanbeandk;49374777]can you be a little more specific? some example. i don't understand what to do[/QUOTE]
Niandra is saying you should use the PlayerSay hook. A hook is an event that triggers something to be run, in this case, something is ran when a payer says something in the chat. There are parameters available to code being ran by a hook, specific to the hook being called. In this case, you can know who the player is who is chatting, and what he wrote. If what he wrote is equal to "!workshop", then you call the metafunction SendLua, which basically sends lua code to that player. The code you want to be ran on that player is a function called gui.OpenURL, this opens a URL in a pop up.
[lua]
hook.Add("PlayerSay", "WorkshopExample", function( pl, text )
if ( string.lower( string.sub( text, 1, 9 ) ) == "!workshop" ) then
pl:SendLua( "gui.OpenURL('workshop url here')" )
end
end)
[/lua]
Wrote this in the browser and didn't check it, so use it as an example only.
Thaks. Struggling with this for about 10 hours now
Here is my working code.
[CODE]
hook.Add( "PlayerSay", "workshop", function( pl, text)
if ( string.lower( string.sub( text, 1, 9 ) ) == "!workshop" ) then
pl:SendLua( "gui.OpenURL( 'http://www.google.com' )" )
return ""
end
end )
[/CODE]
While it's nice that james gave you an example he essentially did everything for you. All you did was add the url where he told you. This isn't that complicated and if you where struggling for 10hrs then you weren't that serious about creating this since niandra basically told you what you needed. You should look into some basic tutorial because creating a chat command is usually a first project.
im total new to this lua SORRY. I was just asking for some help. It will never happen again
[QUOTE=meanbeandk;49381272]im total new to this lua SORRY. I was just asking for some help. It will never happen again[/QUOTE]
Honestly, that is the wrong attitude to have towards anything. No one cares that you asked for help, we all need it at one point or another. The problem arose when you claim to have spent 10 hours struggling with something that is a very basic concept, and Niandra not only pointed at what you would need to research, but also gave you some code to see how it was done.
Sorry, you need to Log In to post a reply to this thread.