Author Topic: I need someone to troubleshoot  (Read 2190 times)

0 Members and 2 Guests are viewing this topic.

Offline Government Official

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
I need someone to troubleshoot
« on: April 10, 2016, 12:33:34 PM »
I am Learning LUA and How to Make Custom ULX Commands and stuff

and I tried to make my own !fmotd command but for some reason it wont work There is no errors its just nothing happens

Code: [Select]
function ulx.fmotd( calling_ply, target_plys )
do target_plys:ConCommand( "ulx motd" )
ulx.fancyLogAdmin( calling_ply, true, "#A Forced #T to look at the Motd!", target_ply )
end
end

local fmotd = ulx.command( CATEGORY_NAME, "fmotd", ulx.respawn, "!fmotd", false )
fmotd:addParam{ type=ULib.cmds.PlayerArg }
fmotd:defaultAccess( ULib.ACCESS_ADMIN )
fmotd:help( "Forces a Player to look at the Motd." )

If you know the fix please help me


EDIT - JamminR - edited code tags from <> to []
« Last Edit: April 10, 2016, 02:03:11 PM by JamminR »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: I need someone to troubleshoot
« Reply #1 on: April 10, 2016, 02:01:29 PM »
Trust me, you're getting errors.
Likely at server startup.
'do' is not a valid command by itself.
You have an extra "end", and from the looks of it, you've modified a while/do statement that "end" used to finish.
Unless there's more code you've not shown us, "CATEGORY_NAME" isn't defined.
You're also calling one of our commands (ulx.respawn) once you get the command working. You'll want to call ulx.fmotd.

Once you get those sported out, you may want to edit your variable names for simplicity.
In ULX, we use 'target_plys' as a table, plural, more than one, of players.
Though you've used the proper setup in the command object to only send a single player, (ULib.cmds.PlayerArg), it would be easier on you if you don't use a variable that looks plural unless you plan to change it later to accept plural.


« Last Edit: April 10, 2016, 02:09:20 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Government Official

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: I need someone to troubleshoot
« Reply #2 on: April 11, 2016, 11:48:48 AM »
CATEGORY_NAME is Defined
I forgot to change it from ulx.respawn to ulx.fmotd when I Copied and pasted it

I tried just doing
target_plys:ConCommand( "ulx motd")
ulx.fancyLogAdmin( calling_ply, true, "#A Forced #T to look at the Motd!", target_ply )

But Nothing happened so I tried puting a Do there

When I was first testing this I was testing it on TTT at first and it was saying something about target_plys but i will change it to target_ply
I will check for a error closely once I restart it

Is the first or second error an extra?

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: I need someone to troubleshoot
« Reply #3 on: April 11, 2016, 04:33:22 PM »
I'm not sure about others, but I don't understand exactly what you're having trouble with right now. I suggest you post the full error(s) so we can help you better.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Government Official

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: I need someone to troubleshoot
« Reply #4 on: April 11, 2016, 04:50:11 PM »
I just checked and there is no errors showing up at Start
Ok well I got rid of Do and the extra end and changed it too target_ply

The Motd wont show up but the Log works fine
« Last Edit: April 11, 2016, 04:59:01 PM by Government Official »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: I need someone to troubleshoot
« Reply #5 on: April 11, 2016, 07:29:07 PM »
The server, or the player this is running on, should get errors somewhere.
Either at server startup, or when the command is run.
I don't normally blatantly do this.
But here is what I think should work. Compare it to whatever code you've already got.

Code: [Select]
CATEGORY_NAME = "homemade stuff"
function ulx.fmotd( calling_ply, target_ply )
target_ply:ConCommand( "ulx motd" )
ulx.fancyLogAdmin( calling_ply, true, "#A Forced #T to look at the Motd!", target_ply )
end

local fmotd = ulx.command( CATEGORY_NAME, "ulx fmotd", ulx.fmotd, "!fmotd", false )
fmotd:addParam{ type=ULib.cmds.PlayerArg }
fmotd:defaultAccess( ULib.ACCESS_ADMIN )
fmotd:help( "Forces a Player to look at the Motd." )
That's untested, but should work as far as my memory goes.
I wasn't sure if you wanted it as a "ulx fmotd" or just "fmotd" from the command line.
I went ahead and made it ulx fmotd
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Government Official

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: I need someone to troubleshoot
« Reply #6 on: April 12, 2016, 05:01:59 AM »
Thanks it works fine

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: I need someone to troubleshoot
« Reply #7 on: April 12, 2016, 03:24:32 PM »
Welcome.
But the question is, can you see, compared to your last try, where some changes were made that might have broken yours?
Learning from what you have presented is best method for most.
Just taking it and putting it into your own file without knowing why it worked doesn't teach.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Government Official

  • Newbie
  • *
  • Posts: 8
  • Karma: -1
Re: I need someone to troubleshoot
« Reply #8 on: April 12, 2016, 06:04:52 PM »
Yea i checked with the one I tried to edit with the changes u Suggested and I didn't see a difference except for the ulx fmotd thing Ill compare to the one I showed u guys