Hello.
How do I tmsql.query in gmod 13.
This is the code: [CODE]local function sendOnline ( )
if (GAMEMODE.ServerIdentifier == 0) then return end
tmysql.query("UPDATE perp_system SET value='" .. os.time() .. "' WHERE key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
end
timer.Create("sendOnline", 10, 0, sendOnline);[/CODE]
Is the timer.Create broken?
When I join I get this error in server console: [CODE]Timer 'sendOnline' Error. attempt to call field 'query' <a nil value>
1. lua/includes/modules/timer.lua/172 <unknown>
2. [C]:-1 <pcall>
3. lua/includes/modules/hook.lua:80 <unknown>[/CODE]
Anyone know whats wrong. I have been searching around on Google, but no luck?
You should probably take a look at [URL="https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit"]this page[/URL]. The timer changes are on page 3.
[QUOTE=kuzimoto;37883250]You should probably take a look at [URL="https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit"]this page[/URL]. The timer changes are on page 3.[/QUOTE]
Thanks it's fixed now...
No problem mate.
That's.. not how you fix it.
You have to create a database object and run :query on it.
I'm sorry, I'm new to lua scripting, I remember encountering a timer error before. Thought it might help.
[QUOTE=Map in a box;37884738]That's.. not how you fix it.
You have to create a database object and run :query on it.[/QUOTE]
I just found out. It just disabled the code...
How do you do that?
I got my database running. And the tmysql module is loaded.
Well as it seems you're trying to convert an entire gamemode, it will be somewhat difficult.
Use tmysql.Connect as you would with tmysql.initialize, it will return a database object which you then :query with
Will I be the first to straight out say that he's editing a leaked gamemode?
I don't think anyone really cares about PERP anymore in terms of "leaks"
wait is tmysql working for gmod13 now?
i checked the svn and its still broken.
[QUOTE=G4MB!T;37888583]wait is tmysql working for gmod13 now?
i checked the svn and its still broken.[/QUOTE]
Yes it is.
Download : [url]http://code.google.com/p/blackawps-glua-modules/source/browse/trunk/?r=73#trunk%2Fgm_tmysql4%2FReleasel[/url]
[QUOTE=EvilSystem;37883184]Hello.
How do I tmsql.query in gmod 13.
This is the code: [CODE]local function sendOnline ( )
if (GAMEMODE.ServerIdentifier == 0) then return end
tmysql.query("UPDATE perp_system SET value='" .. os.time() .. "' WHERE key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
end
timer.Create("sendOnline", 10, 0, sendOnline);[/CODE]
Is the timer.Create broken?
When I join I get this error in server console: [CODE]Timer 'sendOnline' Error. attempt to call field 'query' <a nil value>
1. lua/includes/modules/timer.lua/172 <unknown>
2. [C]:-1 <pcall>
3. lua/includes/modules/hook.lua:80 <unknown>[/CODE]
Anyone know whats wrong. I have been searching around on Google, but no luck?[/QUOTE]
Here let me fix this for you :3
You had something like this ....
[lua]
tmysql.initialize("host", "user", "pass", "db name", 3306);
[/lua]
Thats tmysql3 tmysql4 is much different as seen below...
[lua]
function GM:Initialize ( )
Msg("Loading tmysql module...\n");
require("tmysql4");
if (tmysql) then
Msg("Loaded tmysql module... \n");
else
Msg("Failed to load tmysql module... \n");
end
local db, err = tmysql.initialize("host", "user", "pass", "db name", 3306);
if db then
print("[MySQL] Connected to SV_DATABASE!\n")
SV_DATABASE = db
else
print("[MySQL] Error connecting to SV_DATABASE:\n")
print(err)
end
db = nil
err = nil
end
[/lua]
Ok now thats done now lets fix your function.
[lua]
local function sendOnline ( )
if (GAMEMODE.ServerIdentifier == 0) then return end
tmysql.query("UPDATE perp_system SET value='" .. os.time() .. "' WHERE key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
end
timer.Create("sendOnline", 10, 0, sendOnline);
[/lua]
Now with tmysql4 ...
[lua]
local function sendOnline ( )
if (GAMEMODE.ServerIdentifier == 0) then return end
SV_DATABASE:Query("UPDATE perp_system SET value='" .. os.time() .. "' WHERE key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
end
timer.Create("sendOnline", 10, 0, sendOnline);
[/lua]
Just do CTRL+F and find tmysql.query and replace with SV_DATABASE:Query and you should be good to go! :D
no i mean tmysql3 the one that azuisleet did and is now broken.
honestly as much as i would like to use tmysql4 (because it works) im not changing my entire gamemode because of a temporary change, although i have no idea is azuisleet is actually fixing tmysql3
Stop being lazy. Azuisleet stopped support for tmysql3, and tmysql4 runs faster and has support of multi-databases. I believe DrakeHawk has taken up the project. As I said stop being lazy and do find and replace.
[URL="http://www.facepunch.com/showthread.php?t=1211281&p=37625087&viewfull=1#post37625087"]iirc azuisleet is waiting for GM13 to be released before he updates tmysql.[/URL]
What's wrong with BlackAwps' updated(and imho improved) version
I've had issues with inserting values into a database. I had to specify every field in order to get it to work. It worked fine with the same query in GM12.
Show the code.
[QUOTE=Valkyrie_;37889251]Yes it is.
Download : [url]http://www.bit-block.net/gmsv_tmysql4.dll[/url]
Here let me fix this for you :3
You had something like this ....
[lua]
tmysql.initialize("host", "user", "pass", "db name", 3306);
[/lua]
Thats tmysql3 tmysql4 is much different as seen below...
[lua]
function GM:Initialize ( )
Msg("Loading tmysql module...\n");
require("tmysql4");
if (tmysql) then
Msg("Loaded tmysql module... \n");
else
Msg("Failed to load tmysql module... \n");
end
local db, err = tmysql.initialize("host", "user", "pass", "db name", 3306);
if db then
print("[MySQL] Connected to SV_DATABASE!\n")
SV_DATABASE = db
else
print("[MySQL] Error connecting to SV_DATABASE:\n")
print(err)
end
db = nil
err = nil
end
[/lua]
Ok now thats done now lets fix your function.
[lua]
local function sendOnline ( )
if (GAMEMODE.ServerIdentifier == 0) then return end
tmysql.query("UPDATE perp_system SET value='" .. os.time() .. "' WHERE key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
end
timer.Create("sendOnline", 10, 0, sendOnline);
[/lua]
Now with tmysql4 ...
[lua]
local function sendOnline ( )
if (GAMEMODE.ServerIdentifier == 0) then return end
SV_DATABASE:Query("UPDATE perp_system SET value='" .. os.time() .. "' WHERE key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
end
timer.Create("sendOnline", 10, 0, sendOnline);
[/lua]
Just do CTRL+F and find tmysql.query and replace with SV_DATABASE:Query and you should be good to go! :D[/QUOTE]
Waow. Thanks man. I haven't coded in a long time :3
[QUOTE=Chessnut;37890508]I've had issues with inserting values into a database. I had to specify every field in order to get it to work. It worked fine with the same query in GM12.[/QUOTE]
That and it wasn't very stable, kept getting "Over Popped!" crash errors.
[QUOTE=A Lost Sandwich;37894177]That and it wasn't very stable, kept getting "Over Popped!" crash errors.[/QUOTE]
I wish people would send me the crash logs so I could refine my backwards headers. Most if not all of the problems originate there, and I'm not the only one who uses it. ;)
I have ironed out most of the problems in tmysql4 and update it almost every week. If you're crashing or it's not working right, try updating.
[QUOTE=G4MB!T;37889365]no i mean tmysql3 the one that azuisleet did and is now broken.
honestly as much as i would like to use tmysql4 (because it works) im not changing my entire gamemode because of a temporary change, although i have no idea is azuisleet is actually fixing tmysql3[/QUOTE]
Developing for a server, running a pretty large RP gamemode (no, not perp), which uses MySQL for everything. We've used the very old tmysql module for ages now, and it took me about 5 minutes to replace it with TMySQL4 when i knew how it worked. You can pretty much use the "replace all" function on notepad++ for all open files and replace tmysql.query with databasename:Query. Unless you're using the MySQL module. You will have to change the code "manually" there.
We've even used both because we had both server and forum database running (and the old tmysql module didn't support multi connections). It's not really that much work.
TMySQL 4 is stable at the current build, and you should switch over to that.
Sorry, you need to Log In to post a reply to this thread.