General > Developers Corner
Utime - XGUI - Error- Help plz :/
Bite That Apple:
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: ---bad key to string index (number expected, got string)
--- End code ---
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: ---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()
--- End code ---
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 :/
Megiddo:
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.
JamminR:
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?
Bite That Apple:
--- Quote from: Megiddo 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.
--- End quote ---
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: ---xgui.sendDataTable( {}, "UM_SendData" )
--- End code ---
--- Quote from: JamminR 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?
--- End quote ---
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 :/
JamminR:
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)
Navigation
[0] Message Index
[#] Next page
Go to full version