• Print

Author Topic: Simple Question  (Read 6416 times)

0 Members and 1 Guest are viewing this topic.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Simple Question
« on: July 15, 2015, 10:08:24 am »
If I were to make a command called !donate and takes you to https://google.com for example, and I want it to say in chat:
 "You can blablablabla" ect, how would I do this?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Simple Question
« Reply #2 on: July 16, 2015, 05:20:03 am »
And if I were to make only for the client, so only he/she sees the message when typing !donate in the chat box, how would I be doing that?

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Simple Question
« Reply #3 on: July 16, 2015, 08:46:41 am »

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Simple Question
« Reply #4 on: July 17, 2015, 03:45:44 pm »
Use it's cousin
http://wiki.garrysmod.com/page/Player/PrintMessage

I can't be bothered testing this as I have loads of other stuff to do, but would this work out?
Code: Lua
  1. function ulx.donate( calling_ply )
  2.  
  3.         calling_ply:SendLua([[gui.OpenURL( "]] .. GetConVarString("donate_url") .. [[" )]])
  4.         Player:PrintMessage( HUD_PRINTTALK, "You can view our custom donation page by typing !customdonation in the chat box!" )
  5.        
  6. end
  7.  
  8. local donate = ulx.command( "Menus", "ulx donate", ulx.donate, "!donate" )
  9. donate:defaultAccess( ULib.ACCESS_ALL )
  10. donate:help( "Donate to the server!" )
  11.  

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Simple Question
« Reply #5 on: July 17, 2015, 04:11:25 pm »
No, it would not.  I'll let you figure out why, it's a simple mistake.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Simple Question
« Reply #6 on: July 17, 2015, 08:14:36 pm »
I can't be bothered testing this as I have loads of other stuff to do, but would this work out?

I read this as: "I would rather just have you guys do this for me"
If you "can't be bothered" to help yourself, then you're probably not going to find much help here.


Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Simple Question
« Reply #7 on: July 18, 2015, 02:57:27 am »
I read this as: "I would rather just have you guys do this for me"
If you "can't be bothered" to help yourself, then you're probably not going to find much help here.
I'm sorry, but I really am really busy, and have already spend time browsing the internet for an answer, and tryed it on my own, but I'm just not that good at lua yet and don't know what would fix my problem, I'm sorry if I came over to you like that.  :(

No, it would not.  I'll let you figure out why, it's a simple mistake.
I haven't really got a clue how to fix this, is it possibly because I'm calling the entity Player, but it should be something else, or did I just put it on the wrong line?
I'm sorry, I might be stupid probably :/

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Simple Question
« Reply #8 on: July 18, 2015, 08:35:00 am »
is it possibly because I'm calling the entity Player, but it should be something else
Yes.
Player doesn't exist in your example.
Your error that you've not posted from console probably even tells you Player is nul.
Become used to understanding GMod lua errors.

I'm sorry, I might be stupid probably :/
Now don't go getting all pitiful. It's not becoming of anyone.
Not once did we even indicate we thought you were, and you are intelligent enough to post and pick up on where your code might be going wrong.
« Last Edit: July 18, 2015, 08:37:38 am by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Simple Question
« Reply #9 on: July 18, 2015, 08:36:14 pm »
in your code, you are passing calling_ply through the function. This is going to be your player entity.

So instead of Player you would use calling_ply.
I hope that makes sense?

Notice the line right above the line you added is calling_ply:SendLua
You would need to use the same player entity for your PrintMessage function.

Offline Janjakob2000

  • Jr. Member
  • **
  • Posts: 65
  • Karma: 0
Re: Simple Question
« Reply #10 on: July 19, 2015, 03:01:38 am »
in your code, you are passing calling_ply through the function. This is going to be your player entity.

So instead of Player you would use calling_ply.
I hope that makes sense?

Notice the line right above the line you added is calling_ply:SendLua
You would need to use the same player entity for your PrintMessage function.
Thank you, it's really hard to start of learning to code if you don't even know parts of the language yet or don't know where to begin, I'm just a beginner trying to learn lua.

  • Print