Author Topic: Utime - XGUI - Error- Help plz :/  (Read 3723 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Utime - XGUI - Error- Help plz :/
« on: March 15, 2013, 11:23:18 PM »
Okay, I can't fix this for the love of my life. I've tried every day for the past week now, trying different ways to get this to work. All I want is to be able to change someones hours while in game, and I keep getting this error saying:

Code: [Select]
bad key to string index (number expected, got string)
and I pretty much know what that means, but I don't understand why it's doing that.

This is the code I'm using to change someone's time..

Code: [Select]
concommand.Add("UMGroup", function( ply, cmd, args )
if (ply:query( "utime_m_settings" )) then
Msg( "Player " ..args[1].. " time was changed to " ..args[2].. " hours\n" )
xgui.sendDataTable( {}, "UM_SendData" )
end



  pl = args[1]
  amt = args[2]
  --pl:PrintMessage(HUD_PRINTTALK,decoded[2])
  sql.Query( "UPDATE utime SET totaltime = " .. math.floor( pl:amt() ) .. " WHERE player = " .. pl:UniqueID() .. ";" )
  updateAll()


If ANYONE see's anything wrong with this please tell me, or if you need more of the code for any reason, I'll give it, but I really just want help on this... or I'll just unfortunally have to message Sticky Man or Megiddo on this, which I hope I don't have to bother them :/
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Utime - XGUI - Error- Help plz :/
« Reply #1 on: March 16, 2013, 09:23:50 AM »
Is the error client side or serverside? What is the full error? And why are you trying to send an XGUI data table? I suspect that might be the problem.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Utime - XGUI - Error- Help plz :/
« Reply #2 on: March 16, 2013, 09:52:35 AM »
Besides what ever Megiddo says, I see an oddity too.
math.floor( pl:amt()
You have a string and a interger, and then try to pass it as a player object and function.
Basically if you typed UMGroup Bob 123
math.floor would get Bob:123() (or something like that)
No?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Utime - XGUI - Error- Help plz :/
« Reply #3 on: March 16, 2013, 10:49:56 AM »
Is the error client side or serverside? What is the full error? And why are you trying to send an XGUI data table? I suspect that might be the problem.

The error is serverside.

The full error:


I don't remember why I have this here. I remember it being important for some reason, so I haven't messed with it for about a week now.
Code: [Select]
xgui.sendDataTable( {}, "UM_SendData" )





Besides what ever Megiddo says, I see an oddity too.
math.floor( pl:amt()
You have a string and a interger, and then try to pass it as a player object and function.
Basically if you typed UMGroup Bob 123
math.floor would get Bob:123() (or something like that)
No?

Okay, I removed ply: and () from amt. Still got the same error.











Seeing as the information I seemed to have given may have not been enough. I'll explain just a tiny bit more.


That there is my script that will allow administrators to change a player's time for w/e reason they have. Works like any permission in ULX, so it can be given to a specific rank. So now my problem is that I whenever I change someones time using this script, (doesn't matter if I use xgui to do it, or console) I get the same stupid error every time. It doesn't make sense to me anymore. I've been trying for about a week or so, just trying to get it to work and I've basically have no clue what my problem is now so I've come here for help/advise/ect.

I hope the info I gave helps :/
« Last Edit: March 16, 2013, 10:55:24 AM by chaos13125 »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Utime - XGUI - Error- Help plz :/
« Reply #4 on: March 16, 2013, 11:27:01 AM »
Well, for me, from the code example you've given, I've gone as far as I can (and due to some other life work I have this weekend, am willing to) go.

I'd start looking into any code you have that goes into/gets passed to a for loop or table insertions.
key, index are usually for loop/table related.
Could be something as simply using ipairs when you should be using pairs.
(Or, passing info to our/other person's code that is expected to be in one format bet getting passed another)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Utime - XGUI - Error- Help plz :/
« Reply #5 on: March 17, 2013, 02:01:38 AM »
Okay, I removed ply: and () from amt. Still got the same error.


My guess is that the value you're getting from the slider clientside is being returned as a string to begin with. Since you haven't posted your full code, I can't say for sure-- but you should try calling tonumber() where you get the value from the sldier, which then gets sent to the concommand. Alternately you can do it serverside, probably at this line of code like so:
Code: [Select]
sql.Query( "UPDATE utime SET totaltime = " .. math.floor( tonumber( pl:amt() ) ) .. " WHERE player = " .. pl:UniqueID() .. ";" )
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Utime - XGUI - Error- Help plz :/
« Reply #6 on: March 17, 2013, 03:36:48 AM »
Well because I completely stopped caring about "copyright" for my utime script I'm just going to post my new completely remade code. I only remade it for two reasons: First, for myself, Secondly to make it easier to share.

 
Xgui/Clientside/whatever xgui is because I can't determine it(shared maybe?):

Code: [Select]
fixed



Then sv_utime.lua script thing:
Code: [Select]
fixed


Oh wait, I can't forgot my error can I?:



So as you can see, everything works fine with xgui thingy, but it gets to serverside and just explodes..

I don't know of any way of ulx or let alone garry's mod being able to go to send client side information to server side, it just doesn't seem to exist. Also, if you suggest "datastream", I couldn't get that thing to work either... so here I am stuck completely with a whole new re-written code of my modded utime. If anyone has advice, I would really love that, because I've been stuck on this for weeks now.. please help.

<3
« Last Edit: March 17, 2013, 02:56:09 PM by chaos13125 »
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Utime - XGUI - Error- Help plz :/
« Reply #7 on: March 17, 2013, 02:56:35 PM »
This has been fixed. I'll have an officially release of this in a week. Thank you all.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Utime - XGUI - Error- Help plz :/
« Reply #8 on: March 17, 2013, 07:42:26 PM »
And the root cause analysis was ...?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming