• Print

Author Topic: [ERROR] Need help debugging!  (Read 6770 times)

0 Members and 1 Guest are viewing this topic.

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
[ERROR] Need help debugging!
« on: December 24, 2014, 03:59:01 pm »
I'm new to lua coding and I've been looking and trying for days to figure out this error.

[ERROR] addons/ulx/lua/ulx/modules/sh/sourcebans2.lua:5: function arguments expected near 'calling_ply'
  1. unknown - addons/ulx/lua/ulx/modules/sh/sourcebans2.lua:0

I have function arguments at line 5 where the error is but I keep getting this.

Code: [Select]
local CATEGORY_NAME = "sourcebans"

function ulx.bancheck( calling_ply, target_ply )
local sID = target_ply:SteamID
calling_ply:SendLua([[gui.OpenURL("http://gflclan.com/gmodbans/index.php?p=banlist&advSearch=" .. sID .. "&advType=steamid")]])

end


local bancheck = ulx.command(CATEGORY_NAME, "bancheck", ulx.bancheck, "!bancheck", true)
bancheck:addParam{ type=ULib.cmds.PlayerArg }
bancheck:defaultAccess(ULib.ACCESS_ALL)
bancheck:help( "Opens SourceBans to check a player's bans" );

Any ideas or suggestions? I've gotten the link to open before but I'm not sure what I've broken.

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: [ERROR] Need help debugging!
« Reply #1 on: December 24, 2014, 04:07:34 pm »
copy/paste


Code: Lua
  1. local CATEGORY_NAME = "sourcebans"
  2.  
  3. function ulx.bancheck( calling_ply, target_ply )
  4. local sID = target_ply:SteamID
  5.    calling_ply:SendLua("gui.OpenURL('[url]http://gflclan.com/gmodbans/index.php?p=banlist&advSearch='[/url] .. sID .. '&advType=steamid')")  
  6. end
  7.    
  8. local bancheck = ulx.command(CATEGORY_NAME, "bancheck", ulx.bancheck, "!bancheck", true)
  9. bancheck:addParam{ type=ULib.cmds.PlayerArg }
  10. bancheck:defaultAccess(ULib.ACCESS_ALL)
  11. bancheck:help( "Opens SourceBans to check a player's bans" );
  12.  

Just so you know what was broken, your URL had [[ ]] and incorrect parenthesis.
Also, remove the (url) (/url) tags, it won't let me delete them. Stupid auto tagging..
« Last Edit: December 24, 2014, 04:16:34 pm by syst3M4TiK »
Once you get to know me, you'll find you'll have never met me at all.

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: [ERROR] Need help debugging!
« Reply #2 on: December 24, 2014, 04:14:23 pm »
I tried using that code that you edited but I still get the same error.

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: [ERROR] Need help debugging!
« Reply #3 on: December 24, 2014, 04:17:19 pm »
Yeah, cause the forum auto put tags into the code. Remove the (url) tags
Once you get to know me, you'll find you'll have never met me at all.

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: [ERROR] Need help debugging!
« Reply #4 on: December 24, 2014, 04:18:21 pm »
I've already done that as I noticed it but the same error happens and the command won't even register in the menu
And thank you I did not realize that URL was broken there
« Last Edit: December 24, 2014, 04:22:01 pm by SinkingV »

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: [ERROR] Need help debugging!
« Reply #5 on: December 24, 2014, 04:22:24 pm »
try changing Line 4 to
Code: Lua
  1. local sID = target_ply:SteamID()

it might be getting nul for the sID
Once you get to know me, you'll find you'll have never met me at all.

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: [ERROR] Need help debugging!
« Reply #6 on: December 24, 2014, 04:26:56 pm »
That fixed it!
Now I'm getting this error, so yes it's nil right now.

[ERROR] LuaCmd:1: attempt to concatenate global 'sID' (a nil value)
  1. unknown - LuaCmd:1

I had this earlier before I broke it completely I'm not sure if it's because the URL should just be a variable outside the SendLua
Code: [Select]
local CATEGORY_NAME = "sourcebans"
 
function ulx.bancheck( calling_ply, target_ply )
local sID = target_ply:SteamID()
calling_ply:SendLua("gui.OpenURL('http://gflclan.com/gmodbans/index.php?p=banlist&advSearch=' .. sID .. '&advType=steamid')")
end
 
local bancheck = ulx.command(CATEGORY_NAME, "bancheck", ulx.bancheck, "!bancheck", true)
bancheck:addParam{ type=ULib.cmds.PlayerArg }
bancheck:defaultAccess(ULib.ACCESS_ALL)
bancheck:help( "Opens SourceBans to check a player's bans" );

Here's the updated code from those changes
« Last Edit: December 24, 2014, 04:32:18 pm by SinkingV »

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: [ERROR] Need help debugging!
« Reply #7 on: December 24, 2014, 04:34:28 pm »
Made the URL a variable outside of it and put the variable in
Worked and now I'm just at an end of file error



[ERROR] LuaCmd:1: ')' expected near '<eof>'
  1. unknown - LuaCmd:0

I have the ) there

Code: [Select]
local CATEGORY_NAME = "sourcebans"
 
function ulx.bancheck2( calling_ply, target_ply )
local sID = target_ply:SteamID()
local URLA = "'http://gflclan.com/gmodbans/index.php?p=banlist&advSearch=' .. sID .. '&advType=steamid'"

calling_ply:SendLua("gui.OpenURL('URLA'")
end
 
local bancheck = ulx.command(CATEGORY_NAME, "bancheck2", ulx.bancheck2, "!bancheck2", true)
bancheck:addParam{ type=ULib.cmds.PlayerArg }
bancheck:defaultAccess(ULib.ACCESS_ALL)
bancheck:help( "Opens SourceBans to check a player's bans" );

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: [ERROR] Need help debugging!
« Reply #8 on: December 24, 2014, 04:39:50 pm »
calling_ply:SendLua("gui.OpenURL('URLA')")

URLs should work with variables, so I don't think that's the problem. It might be how the variable is set. Humour me (I'm not positive) and try putting brackets around target_ply:SteamID()
Once you get to know me, you'll find you'll have never met me at all.

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: [ERROR] Need help debugging!
« Reply #9 on: December 24, 2014, 04:54:00 pm »
Putting brackets there gives me the error


[ERROR] addons/ulx/lua/ulx/modules/sh/bancheck2.lua:4: unexpected symbol near '['
  1. unknown - addons/ulx/lua/ulx/modules/sh/bancheck2.lua:0


Using the code with the variable outside of the URL so just trying to figure out this eof error
« Last Edit: December 24, 2014, 05:12:41 pm by SinkingV »

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: [ERROR] Need help debugging!
« Reply #10 on: December 24, 2014, 05:52:08 pm »
Code: [Select]
local CATEGORY_NAME = "sourcebans"
 
function ulx.bancheck( calling_ply, target_ply )
calling_ply:SendLua([[gui.OpenURL('http://gflclan.com/gmodbans/index.php?p=banlist&advSearch=]]..target_ply:SteamID()..[[&advType=steamid')]])
end
 
local bancheck = ulx.command(CATEGORY_NAME, "bancheck", ulx.bancheck, "!bancheck", true)
bancheck:addParam{ type=ULib.cmds.PlayerArg }
bancheck:defaultAccess(ULib.ACCESS_ALL)
bancheck:help( "Opens SourceBans to check a player's bans" );

This is your final product. I've tested and debugged myself, apparently I have no bans, which is good. Have fun!

To sum up what was changed:
The local variable was removed
URL was modified to deliver needs
target_ply:SteamID was changed to target_ply:SteamID() and was placed in the URL rather than a variable.
« Last Edit: December 24, 2014, 05:59:12 pm by syst3M4TiK »
Once you get to know me, you'll find you'll have never met me at all.

Offline SinkingV

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
Re: [ERROR] Need help debugging!
« Reply #11 on: December 24, 2014, 06:32:23 pm »
Thank you for your help, maybe I can reverse debug this to help me in future projects

  • Print