• 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!

War System Problems

Spratt

New Member
Joined
Jun 26, 2011
Messages
106
Reaction score
1
I added all the War System stuff to my server, I start up the Server and get this error for one of the war commands. This error is in the Console

HTML:
[18/09/2012 16:38:58] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/balance.lua:1: '=' expected near 'function'
[18/09/2012 16:38:58] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/balance.lua)
[18/09/2012 16:38:58] data/talkactions/scripts/balance.lua:1: '=' expected near 'function'
[18/09/2012 16:38:58] [Error - LuaScriptInterface::loadFile] data/talkactions/scripts/balance.lua:1: '=' expected near 'function'
[18/09/2012 16:38:58] [Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/balance.lua)
[18/09/2012 16:38:58] data/talkactions/scripts/balance.lua:1: '=' expected near 'function'

What can I do to fix this and get the War System up and running properly :(
 
Im using TFS 0.3.6

Code:
ocal function isValidMoney(value)
	if(value == nil) then
		return false
	end
 
	return (value > 0 and value <= 99999999999999)
end
 
function onSay(cid, words, param, channel)
	local guild = getPlayerGuildId(cid)
	if(guild == 0) then
		return false
	end
 
	local t = string.explode(param, ' ', 1)
	if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
		if(t[1] == 'pick') then
			local money = { tonumber(t[2]) }
			if(not isValidMoney(money[1])) then
				doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
				return true
			end
 
			local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
			if(result:getID() == -1) then
				return false
			end
 
			money[2] = result:getDataLong('balance')
			result:free()
 
			if(money[1] > money[2]) then
				doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
				return true
			end
 
			if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
				return false
			end
 
			doPlayerAddMoney(cid, money[1])
			doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
		else
			doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
		end
	elseif(t[1] == 'donate') then
		local money = tonumber(t[2])
		if(not isValidMoney(money)) then
			doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
			return true
		end
 
		if(getPlayerMoney(cid) < money) then
			doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
			return true
		end
 
		if(not doPlayerRemoveMoney(cid, money)) then
			return false
		end
 
		db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
		doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
	else
		local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
		if(result:getID() == -1) then
			return false
		end
 
		doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
		result:free()
	end
 
	return true
end
 
Lua:
local function isValidMoney(value)
	if(value == nil) then
		return false
	end

	return (value > 0 and value <= 99999999999999)
end

function onSay(cid, words, param, channel)
	if(not checkExhausted(cid, 666, 10)) then
		return false
	end

	local guild = getPlayerGuildId(cid)
	if(guild == 0) then
		return false
	end

	local t = string.explode(param, ' ', 1)
	if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
		if(t[1] == 'pick') then
			local money = { tonumber(t[2]) }
			if(not isValidMoney(money[1])) then
				doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
				return true
			end

			local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
			if(result:getID() == -1) then
				return false
			end

			money[2] = result:getDataLong('balance')
			result:free()

			if(money[1] > money[2]) then
				doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
				return true
			end

			if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
				return false
			end

			doPlayerAddMoney(cid, money[1])
			doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
		else
			doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
		end
	elseif(t[1] == 'donate') then
		local money = tonumber(t[2])
		if(not isValidMoney(money)) then
			doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
			return true
		end

		if(getPlayerMoney(cid) < money) then
			doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
			return true
		end

		if(not doPlayerRemoveMoney(cid, money)) then
			return false
		end

		db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
		doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
	else
		local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
		if(result:getID() == -1) then
			return false
		end

		doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
		result:free()
	end

	return true
end

Try this
 
Thank you, no errors in console, hopefully i can start a war in game, umm what would the command be ti start one? would it be /war *enter guild name here*?
 
Thank you, no errors in console, hopefully i can start a war in game, umm what would the command be ti start one? would it be /war *enter guild name here*?

/war invite, nameguild, numbersoffrags
/war accept, nameguild
/war end, nameguild
/war reject, nameguild

(NOTICE: EVERY SPACE AND ","IS NEEDED)

repp me if i helped u
 
I went to test out invite to war and i got this error in console :S

HTML:
[18/09/2012 17:03:57] [Error - TalkAction Interface] 
[18/09/2012 17:03:57] data/talkactions/scripts/war.lua:onSay
[18/09/2012 17:03:57] Description: 
[18/09/2012 17:03:57] data/talkactions/scripts/war.lua:133: attempt to call field 'executeQuery' (a nil value)
[18/09/2012 17:03:57] stack traceback:
[18/09/2012 17:03:57] 	data/talkactions/scripts/war.lua:133: in function <data/talkactions/scripts/war.lua:1>
 
Oh okay, how do i do that then? Sorry for all these Noob questions and problems xD

Well i think the best option u can do is get Premium on Otland and download the latest rev = already compiled with war system.
And ur done.

But there might be some other way's (free), i don't know any of them maby someone will reply one.
 
Oh okay, how do i do that then? Sorry for all these Noob questions and problems xD
1)download source for ur tfs (if u dont have it alrdy)
2)download theforgoten dev-cpp (if u dont have it alrdy)
3)open theforgotten dev-cpp
4)open theforgottenserver.dev file from your source in the forgotten dev-cpp
5)hit alt+p
6)go to 'parameters' tab
7)in c++ compiler tab/section add
Code:
-D__WAR_SYSTEM__
8)click ok
9)hit ctrl+f9
10)wait for it to compile
 
1)download source for ur tfs (if u dont have it alrdy)
2)download theforgoten dev-cpp (if u dont have it alrdy)
3)open theforgotten dev-cpp
4)open theforgottenserver.dev file from your source in the forgotten dev-cpp
5)hit alt+p
6)go to 'parameters' tab
7)in c++ compiler tab/section add
Code:
-D__WAR_SYSTEM__
8)click ok
9)hit ctrl+f9
10)wait for it to compile

Im sorry, I dont understand ANY of that :$ I am totally confused, Im sorry i am a noob at this and i just want it to work :(

- - - Updated - - -

Okay so I have the dev-cpp and source files, now what program do i open the file with?

- - - Updated - - -

Okay so I compiled it all and now i get this error in console what did i do wrong :(

HTML:
[18/09/2012 18:49:22] [Error - TalkAction Interface] 
[18/09/2012 18:49:22] data/talkactions/scripts/war.lua:onSay
[18/09/2012 18:49:22] Description: 
[18/09/2012 18:49:22] data/talkactions/scripts/war.lua:133: attempt to call field 'executeQuery' (a nil value)
[18/09/2012 18:49:22] stack traceback:
[18/09/2012 18:49:22] 	data/talkactions/scripts/war.lua:133: in function <data/talkactions/scripts/war.lua:1>
 
Lua:
local function isValidMoney(value)
	if(value == nil) then
		return false
	end
 
	return (value > 0 and value <= 99999999999999)
end
 
function onSay(cid, words, param, channel)
	if(not checkExhausted(cid, 666, 10)) then
		return false
	end
 
	local guild = getPlayerGuildId(cid)
	if(guild == 0) then
		return false
	end
 
	local t = string.explode(param, ' ', 1)
	if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
		if(t[1] == 'pick') then
			local money = { tonumber(t[2]) }
			if(not isValidMoney(money[1])) then
				doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
				return true
			end
 
			local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
			if(result:getID() == -1) then
				return false
			end
 
			money[2] = result:getDataLong('balance')
			result:free()
 
			if(money[1] > money[2]) then
				doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
				return true
			end
 
			if(not db.query('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
				return false
			end
 
			doPlayerAddMoney(cid, money[1])
			doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
		else
			doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
		end
	elseif(t[1] == 'donate') then
		local money = tonumber(t[2])
		if(not isValidMoney(money)) then
			doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
			return true
		end
 
		if(getPlayerMoney(cid) < money) then
			doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
			return true
		end
 
		if(not doPlayerRemoveMoney(cid, money)) then
			return false
		end
 
		db.query('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
		doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
	else
		local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
		if(result:getID() == -1) then
			return false
		end
 
		doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
		result:free()
	end
 
	return true
end
 
Back
Top