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

'unexpected symbol near 'ÿ'' Error

watkins577

As3, lua, xml scripter
Joined
Sep 20, 2008
Messages
130
Reaction score
0
I get this error for my script
Code:
[27/09/2009 23:16:07] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/beginitems.lua)
[27/09/2009 23:16:07] data/movements/scripts/beginitems.lua:1: unexpected symbol near 'ÿ'
[27/09/2009 23:16:07] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/beginitems.lua)
[27/09/2009 23:16:07] data/movements/scripts/beginitems.lua:1: unexpected symbol near 'ÿ'
This is my script (notice it has no weird y in it).
Code:
local config = {
	items = {
		itemss = {8820, 2661, 1988, 8819, 2190, 2175, 2468, 2643},
		itemsd = {8820, 2661, 1988, 8819, 2182, 2175, 2468, 2643},
		itemsp = {2480, 2661, 1988, 2660, 2456, 8923, 2544, 2643},
		itemsk = {2481, 2661, 1988, 2465, 8602, 2509, 2478, 2643, 2439, 8601}
	},
	storage = {3000, 3001, 3002, 3003}
}

function onStepIn(cid, item, pos, frompos)
	if item.actionid == config.storage[0] then
		if getPlayerStorageValue(cid, config.storage[0]) == 0 then
			if getPlayerVocation == 1 then
				setPlayerStorageValue(cid, config.storage[0], 1)
				for _, id in ipairs(config.items.itemss) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Sorcerer!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else if item.actionid == config.storage[1] then
		if getPlayerStorageValue(cid, config.storage[1]) == 0 then
			if getPlayerVocation == 2 then
				setPlayerStorageValue(cid, config.storage[1], 1)
				for _, id in ipairs(config.items.itemsd) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Druid!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else if item.actionid == config.storage[2] then
		if getPlayerStorageValue(cid, config.storage[2]) == 0 then
			if getPlayerVocation == 3 then
				setPlayerStorageValue(cid, config.storage[2], 1)
				for _, id in ipairs(config.items.itemsp) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Paladin!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else if item.actionid == config.storage[3] then
		if getPlayerStorageValue(cid, config.storage[3]) == 0 then
			if getPlayerVocation == 4 then
				setPlayerStorageValue(cid, config.storage[3], 1)
				for _, id in ipairs(config.items.itemsk) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Knight!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else
		doPlayerSendCancel(cid, "This is broken :(")
		return FALSE
	end
end

Thanks for any help :p.
 
Hmm.. in what program do you edit/save LUA files? Maybe it's bugged program and has problem with coding.

Download Notepad++:
Browse Notepad++ Files on SourceForge.net

windows .exe installator:
Download Notepad++ installator for Windows from SourceForge.net

open your LUA script file and try:
Format -> Code in ANSI
or:
Format -> Convert to format ANSI
or same, but with UTF-8 code

I use Notepad+ for PHP/LUA/XML files and I think it's really good program. No problems with format and many edit options (mass edit files in folder XX, search in folder [and sub-folders] XX).
Maybe remove first line and write again:
local config = {
--------------------------
About script, think about it:
PHP:
now_storage = config.storage[item.actionid]
in place of 4 checks
in items array dont use any 'names':
PHP:
	items = {{8820, 2661, 1988, 8819, 2190, 2175, 2468, 2643},
		{8820, 2661, 1988, 8819, 2182, 2175, 2468, 2643},
		{2480, 2661, 1988, 2660, 2456, 8923, 2544, 2643},
		{2481, 2661, 1988, 2465, 8602, 2509, 2478, 2643, 2439, 8601}
	}
then you can use:
PHP:
for _, id in ipairs(config.items[item.actionid - 2999]) do -- first item in LUA table has id 1, first storage 3000
 
Last edited:
Ok, first I use wordpad to write lua because and it usually works in notepad so I thought Id use it because its better. I just opened it in notepad++ and I got something. The new error is [27/09/2009 23:44:23]
Code:
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/beginitems.lua)
[27/09/2009 23:44:23] data/movements/scripts/beginitems.lua:77: 'end' expected (to close 'if' at line 25) near '<eof>'
 
Did you edit anything in code from first post? I show in error:
'end' expected (to close 'if' at line 25) near '<eof>'
but there is no 'if' in line 25, Notepad+ sometimes count +-1 line in code, but not 3 lines.
 
Ok Ive changed the code now to this:
Code:
items = {
		itemss = {8820, 2661, 1988, 8819, 2190, 2175, 2468, 2643},
		itemsd = {8820, 2661, 1988, 8819, 2182, 2175, 2468, 2643},
		itemsp = {2480, 2661, 1988, 2660, 2456, 8923, 2544, 2643},
		itemsk = {2481, 2661, 1988, 2465, 8602, 2509, 2478, 2643, 2439, 8601}
}
storage = {3000, 3001, 3002, 3003}
function onStepIn(cid, item, pos, frompos)
	if item.actionid == storage[0] then
		if getPlayerStorageValue(cid, storage[0]) == -1 then
			if getPlayerVocation == 1 then
				setPlayerStorageValue(cid, storage[0], 1)
				for _, id in ipairs(items.itemss) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Sorcerer!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[1] then
		if getPlayerStorageValue(cid, storage[1]) == -1 then
			if getPlayerVocation == 2 then
				setPlayerStorageValue(cid, storage[1], 1)
				for _, id in ipairs(items.itemsd) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Druid!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[2] then
		if getPlayerStorageValue(cid, storage[2]) == -1 then
			if getPlayerVocation == 3 then
				setPlayerStorageValue(cid, storage[2], 1)
				for _, id in ipairs(items.itemsp) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Paladin!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[3] then
		if getPlayerStorageValue(cid, storage[3]) == -1 then
			if getPlayerVocation == 4 then
				setPlayerStorageValue(cid, storage[3], 1)
				for _, id in ipairs(items.itemsk) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Knight!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else
		doPlayerSendCancel(cid, "This is broken :(")
		return FALSE
	end
end

Atm I think it should work, but Im just testing it out now
 
Ok I just tested and editted it slightly, but theres a problem... it doesnt give the right items (e.g. druid tile gives paladin stuff, sorcere gives druid stuff, paladin gives knight stuff, and knight gives the 'This is broken' As if everything is one part ahead.)

Heres the code
Code:
items = {
		itemss = {8820, 2661, 1988, 8819, 2190, 2175, 2468, 2643},
		itemsd = {8820, 2661, 1988, 8819, 2182, 2175, 2468, 2643},
		itemsp = {2480, 2661, 1988, 2660, 2456, 8923, 2544, 2643},
		itemsk = {2481, 2661, 1988, 2465, 8602, 2509, 2478, 2643, 2439, 8601}
}
storage = {3000, 3001, 3002, 3003}
function onStepIn(cid, item, pos, frompos)
	if item.actionid == storage[0] then
		if getPlayerStorageValue(cid, storage[0]) == -1 then
			if getPlayerVocation(cid) == 1 then
				setPlayerStorageValue(cid, storage[0], 1)
				for _, id in ipairs(items.itemss) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Sorcerer!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[1] then
		if getPlayerStorageValue(cid, storage[1]) == -1 then
			if getPlayerVocation(cid) == 2 then
				setPlayerStorageValue(cid, storage[1], 1)
				for _, id in ipairs(items.itemsd) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Druid!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[2] then
		if getPlayerStorageValue(cid, storage[2]) == -1 then
			if getPlayerVocation(cid) == 3 then
				setPlayerStorageValue(cid, storage[2], 1)
				for _, id in ipairs(items.itemsp) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Paladin!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[3] then
		if getPlayerStorageValue(cid, storage[3]) == -1 then
			if getPlayerVocation(cid) == 4 then
				setPlayerStorageValue(cid, storage[3], 1)
				for _, id in ipairs(items.itemsk) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Knight!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else
		doPlayerSendCancel(cid, "This is broken :(")
		return FALSE
	end
end
 
Ok I just tested and editted it slightly, but theres a problem... it doesnt give the right items (e.g. druid tile gives paladin stuff, sorcere gives druid stuff, paladin gives knight stuff, and knight gives the 'This is broken' As if everything is one part ahead.)

Heres the code
Code:
items = {
		itemss = {8820, 2661, 1988, 8819, 2190, 2175, 2468, 2643},
		itemsd = {8820, 2661, 1988, 8819, 2182, 2175, 2468, 2643},
		itemsp = {2480, 2661, 1988, 2660, 2456, 8923, 2544, 2643},
		itemsk = {2481, 2661, 1988, 2465, 8602, 2509, 2478, 2643, 2439, 8601}
}
storage = {3000, 3001, 3002, 3003}
function onStepIn(cid, item, pos, frompos)
	if item.actionid == storage[0] then
		if getPlayerStorageValue(cid, storage[0]) == -1 then
			if getPlayerVocation(cid) == 1 then
				setPlayerStorageValue(cid, storage[0], 1)
				for _, id in ipairs(items.itemss) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Sorcerer!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[1] then
		if getPlayerStorageValue(cid, storage[1]) == -1 then
			if getPlayerVocation(cid) == 2 then
				setPlayerStorageValue(cid, storage[1], 1)
				for _, id in ipairs(items.itemsd) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Druid!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[2] then
		if getPlayerStorageValue(cid, storage[2]) == -1 then
			if getPlayerVocation(cid) == 3 then
				setPlayerStorageValue(cid, storage[2], 1)
				for _, id in ipairs(items.itemsp) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Paladin!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	end
	if item.actionid == storage[3] then
		if getPlayerStorageValue(cid, storage[3]) == -1 then
			if getPlayerVocation(cid) == 4 then
				setPlayerStorageValue(cid, storage[3], 1)
				for _, id in ipairs(items.itemsk) do
					doPlayerAddItem(cid, id, 1)
				end
				return TRUE
			else
				doPlayerSendCancel(cid, "You are not a Knight!")
				return FALSE
			end
		else
			doPlayerSendCancel(cid, "You have already got these items!")
			return FALSE
		end
	else
		doPlayerSendCancel(cid, "This is broken :(")
		return FALSE
	end
end
if item.actionid == storage[0] then
FIRST value is LUA table (in PHP called array) has ID (key) 1 (in PHP it has ID/key 0)
so:
storage[0]
is EMPTY
storage[1]
has value 3000
change (all occures) storage[3] to storage[4], storage[2] to storage[3] ......
 
I hate how that happens, Im so used to writing in php, flash, and other stuff which uses the first element as [0]
 
Back
Top