• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Lua/MySQL Error in Server when Loading and Logging in

pierroth

Mar Co.
Joined
Sep 11, 2008
Messages
343
Reaction score
10
Location
Mexico - California
Hey everyone! I know I know.. I'm a pain in the butt :oops:

I decided to play around and bam! I got this error when I started the server.

Code:
[11/10/2015 17:58:34] mysql_real_query(): SELECT `id`, `ownerid`, `creationdata`, `checkdata` FROM `guilds` WHERE `world_id` = 0; - MYSQL ERROR: Unknown column 'checkdata' in 'field list' (1054)
[11/10/2015 17:58:34] mysql_real_query(): DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < 1444431514; - MYSQL ERROR: Table 'thunderia.guild_wars' doesn't exist (1146)

And also this one when I try to log in:

Code:
[11/10/2015 18:02:53] Thunder has logged in.

[11/10/2015 18:02:53] [Error - CreatureScript Interface]
[11/10/2015 18:02:53] data/creaturescripts/scripts/login.lua:onLogin
[11/10/2015 18:02:53] Description:
[11/10/2015 18:02:53] data/creaturescripts/scripts/login.lua:10: attempt to call global 'getOnlinePlayers' (a nil value)
[11/10/2015 18:02:53] stack traceback:
[11/10/2015 18:02:53]     data/creaturescripts/scripts/login.lua:10: in function <data/creaturescripts/scripts/login.lua:6>
[11/10/2015 18:02:53] mysql_real_query(): UPDATE `players` SET `broadcasting` = 0, `viewers` = 0 WHERE `id` = 2 LIMIT 1 - MYSQL ERROR: Unknown column 'broadcasting' in 'field list' (1054)
[11/10/2015 18:02:53] Thunder has logged out.

Could anyone please give me a hand with this please.

Thank you!
 
Unknown column 'broadcasting' in 'field list' (1054)

Code:
ALTER TABLE `players` ADD `broadcasting` INT(11) DEFAULT 0;

Unknown column 'checkdata' in 'field list' (1054)

Code:
ALTER TABLE `guilds` ADD `checkdata` INT(11)

Table 'thunderia.guild_wars' doesn't exist (1146)

Code:
CREATE TABLE IF NOT EXISTS `guild_wars` (
`id` INT NOT NULL AUTO_INCREMENT,
`guild_id` INT NOT NULL,
`enemy_id` INT NOT NULL,
`begin` BIGINT NOT NULL DEFAULT '0',
`end` BIGINT NOT NULL DEFAULT '0',
`frags` INT UNSIGNED NOT NULL DEFAULT '0',
`payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',
`guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',
`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `guild_id` (`guild_id`),
KEY `enemy_id` (`enemy_id`)
) ENGINE=InnoDB;
ALTER TABLE `guild_wars`
ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;
ALTER TABLE `guilds` ADD `balance` BIGINT UNSIGNED NOT NULL AFTER `motd`;
CREATE TABLE IF NOT EXISTS `guild_kills` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`guild_id` INT NOT NULL,
`war_id` INT NOT NULL,
`death_id` INT NOT NULL
) ENGINE = InnoDB;
ALTER TABLE `guild_kills`
ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;
ALTER TABLE `killers` ADD `war` INT NOT NULL DEFAULT 0;

Your database is missing alot of crap, you've missed a lot of steps in setting up your OT.
You're also missing compat.lua in your LIB folder which is the reason for this:

attempt to call global 'getOnlinePlayers' (a nil value)

Dirty fix is adding this to global.lua:
Code:
function getOnlinePlayers()
local result = {}
for _, player in ipairs(Game.getPlayers()) do
result[#result + 1] = player:getName()
end
return result
end

Little too much going on here for me to help with everything....
 
Last edited:
To fix login:
To fix SQL error, run it on the reference date:
Code:
ALTER TABLE `players` ADD `broadcasting` INT(11) DEFAULT 0;

And function getOnlinePlayers does not exist.
 
Leo, I would like to thank you for helping me with this. I understand it is a lot of stuff :/
but I do appreciate your help!

Unknown column 'broadcasting' in 'field list' (1054)

Code:
ALTER TABLE `field list` ADD `broadcasting` INT(11)

Unknown column 'checkdata' in 'field list' (1054)


The above didn't work, when I sql it says:
Code:
#1146 - Table 'thunderia.field list' doesn't exist

Code:
ALTER TABLE `guild` ADD `checkdata` INT(11)

Table 'thunderia.guild_wars' doesn't exist (1146)


Top part didn't work, I'm guessing it is because I have "guilds", instead of "guild". So I went ahead and input guild, instead of guilds.

Your database is missing alot of crap, you've missed a lot of steps in setting up your OT.
You're also missing compat.lua in your LIB folder:


I do have it, although it is called 100-compat.lua... What should I do?

attempt to call global 'getOnlinePlayers' (a nil value)
https://otland.net/threads/tfs-1-0-lua-functions.197202/#post-1974496

Dirty fix is adding this to global.lua
Code:
function getOnlinePlayers()
local result = {}
for _, player in ipairs(Game.getPlayers()) do
result[#result + 1] = player:getName()
end
return result
end

Little too much going on here for me to help with everything....

I created a global.lua in my data/lib folder because I didn't have it... and I pasted the code above. Is that right?
I am sorry, I know it was a lot but I am glad you came in and helped this noob.

Thanks a lot, I appreciate the assistance.
 
Leo, I would like to thank you for helping me with this. I understand it is a lot of stuff :/
but I do appreciate your help!



The above didn't work, when I sql it says:
Code:
#1146 - Table 'thunderia.field list' doesn't exist



Top part didn't work, I'm guessing it is because I have "guilds", instead of "guild". So I went ahead and input guild, instead of guilds.



I do have it, although it is called 100-compat.lua... What should I do?



I created a global.lua in my data/lib folder because I didn't have it... and I pasted the code above. Is that right?
I am sorry, I know it was a lot but I am glad you came in and helped this noob.

Thanks a lot, I appreciate the assistance.

Add

Code:
function getOnlinePlayers()
local result = {}
for _, player in ipairs(Game.getPlayers()) do
result[#result + 1] = player:getName()
end
return result
end

into your 100-compat.lua file instead.
delete the dodgey global.lua file you created.

The correct fix for the first one was this:

Unknown column 'broadcasting' in 'field list' (1054)

Code:
ALTER TABLE `players` ADD `broadcasting` INT(11) DEFAULT 0;

my bad.
 
Back
Top