• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Script Mistakes

Nokturno

Not a human
Joined
Aug 7, 2009
Messages
606
Solutions
2
Reaction score
422
Hello Otlanders.
Well i hope someone can help me with this one.

can someone fix this scripts cuz it have some Mistakes.
Cuz i edited And now is not working LOL



Console ERROR
Code:
Warning: [Event::checkScript] Can not load script. /scripts/SetRank.lua
[27/08/2011 12:05:38] data/creaturescripts/scripts/SetRank.lua:104: 'end' expected (to close 'function' at line 86) near '<eof>'




RankName Script

Code:
local config = {
	storage = 7500,
	mailbox = {
		{x = 95, y = 112, z = 7}
	}
}
 
local ranks = {
	[" The Scout"] = {
		c = {
			level = 20,
			prize = {2160, 1}
		}
	},
 
	["Grunt"] = {
		c = {
			level = 30,
			prize = {2160, 2}
		}
	},
 
	["Sergeant"] = {
		c = {
			level = 40,
			prize = {2160, 4}
		}
	},
 
	["Senior Sergeant"] = {
		c = {
			level = 50,
			prize = {2160, 5}
		}
	},
 
	["Master Sergeant"] = {
		c = {
			level = 55,
			prize = {2160, 6}
		}
	},
 
	["Legionnaire"] = {
		c = {
			level = 60,
			prize = {2160, 7}
		}
	},
 
	["Lieutenant General"] = {
		c = {
			level = 70,
			prize = {2160, 8}
		}
	},
 
	["General"] = {
		c = {
			level = 80,
			prize = {2160, 9}
		}
	},
 
	["War Lord"] = {
		c = {
			level = 85,
			prize = {2160, 10}
		}
	},
}
 
local function doPlayerAddDepotItems(cid, pos, town, items, notify) -- credits to Chojy for idea.
	local parcel = doCreateItemEx(2595)
	local label = doAddContainerItem(parcel, 2599)
	doSetItemText(label, getCreatureName(cid) .."\n".. town)
	doAddContainerItemEx(parcel, items)
	doTeleportThing(parcel, pos)
	if(notify == true) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your reward has been sent to your depot because you were unable to carry it.")
	end
 
	return true
end
 
function onAdvance(cid, skill, oldLevel, newLevel)
	for desc, i in pairs(ranks) do
		if skill == SKILL__LEVEL then
			if newLevel >= i.c.level then
				if getCreatureStorage(cid, config.storage) < newLevel then
 
					local id = doCreateItemEx(i.c.prize[1], i.c.prize[2] or 1)
					if(doPlayerAddItemEx(cid, id, false) ~= RETURNVALUE_NOERROR) then
						doPlayerAddDepotItems(cid, config.mailbox[1], getTownName(getPlayerTown(cid)), id, true)
					end
 
					doCreatureSetStorage(cid, config.storage, newLevel)
					doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
					doCreatureSay(cid, "Congratulations! You are now a ' ... desc .. '.", TALKTYPE_MONSTER)
					break
				end
			end
		end
	end
 
Last edited:
LUA:
local config = {
	storage = 7500,
	mailbox = {
		{x = 95, y = 112, z = 7}
	}
}
 
local ranks = {
	[" The Scout"] = {
		c = {
			level = 20,
			prize = {2160, 1}
		}
	},
 
	["Grunt"] = {
		c = {
			level = 30,
			prize = {2160, 2}
		}
	},
 
	["Sergeant"] = {
		c = {
			level = 40,
			prize = {2160, 4}
		}
	},
 
	["Senior Sergeant"] = {
		c = {
			level = 50,
			prize = {2160, 5}
		}
	},
 
	["Master Sergeant"] = {
		c = {
			level = 55,
			prize = {2160, 6}
		}
	},
 
	["Legionnaire"] = {
		c = {
			level = 60,
			prize = {2160, 7}
		}
	},
 
	["Lieutenant General"] = {
		c = {
			level = 70,
			prize = {2160, 8}
		}
	},
 
	["General"] = {
		c = {
			level = 80,
			prize = {2160, 9}
		}
	},
 
	["War Lord"] = {
		c = {
			level = 85,
			prize = {2160, 10}
		}
	},
}
 
local function doPlayerAddDepotItems(cid, pos, town, items, notify) -- credits to Chojy for idea.
	local parcel = doCreateItemEx(2595)
	local label = doAddContainerItem(parcel, 2599)
	doSetItemText(label, getCreatureName(cid) .."\n".. town)
	doAddContainerItemEx(parcel, items)
	doTeleportThing(parcel, pos)
	if(notify == true) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your reward has been sent to your depot because you were unable to carry it.")
	end
 
	return true
end
 
function onAdvance(cid, skill, oldLevel, newLevel)
	for desc, i in pairs(ranks) do
		if skill == SKILL__LEVEL then
			if newLevel >= i.c.level then
				if getCreatureStorage(cid, config.storage) < newLevel then
 
					local id = doCreateItemEx(i.c.prize[1], i.c.prize[2] or 1)
					if(doPlayerAddItemEx(cid, id, false) ~= RETURNVALUE_NOERROR) then
						doPlayerAddDepotItems(cid, config.mailbox[1], getTownName(getPlayerTown(cid)), id, true)
					end
 
					doCreatureSetStorage(cid, config.storage, newLevel)
					doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
					doCreatureSay(cid, "Congratulations! You are now a ' ... desc .. '.", TALKTYPE_MONSTER)
					break
				end
			end
		end
 
What you experienced is a syntax error. IF you simply can't find it (even though you are given the line)
a more detailed error sometimes appears when you try it here:
Lua: demo

This is how you breakdown your error:

Full error: input:104: 'end' expected (to close 'function' at line 86) near '<eof>'

Bolded below is the line number the error occurs on:
input:104: 'end' expected (to close 'function' at line 86) near '<eof>'

Bolded below is what needs to be added to the script:
input:104: 'end' expected (to close 'function' at line 86) near '<eof>'

Bolded below is the function & line number that needs to be closed by the 'end' to the script:
input:104: 'end' expected (to close 'function' at line 86) near '<eof>'

Bolded below is simply a clue to where to look (the error will be on line 104 as stated + it will be near a 'else/if statement'):
input:104: 'end' expected (to close 'function' at line 86) near '<eof>'
 
Last edited:
Seems he tried to edit my script I released in the actions section and couldn't quite do so properly...

BTW OP, I'll be updating that script release soon - you might want to take a look.
 
j.DRE:


Yeah, its Yours, I tried to add more Tittle but Now doesnt work. LOL




Sorry about Otfans,

Edited :)

,

@ Cronoxs

script you post Doesnt work, Same ERROR
 
You forgot to put an "end" at the bottom of the script and... why do you have a "break" if it's not inside a loop? That's kind of non-sense in my opinion :o
 
All you did was miss an end.

LUA:
local config = {
	storage = 7500,
	mailbox = {
		{x = 95, y = 112, z = 7}
	}
}
 
local ranks = {
	[" The Scout"] = {
		c = {
			level = 20,
			prize = {2160, 1}
		}
	},
 
	["Grunt"] = {
		c = {
			level = 30,
			prize = {2160, 2}
		}
	},
 
	["Sergeant"] = {
		c = {
			level = 40,
			prize = {2160, 4}
		}
	},
 
	["Senior Sergeant"] = {
		c = {
			level = 50,
			prize = {2160, 5}
		}
	},
 
	["Master Sergeant"] = {
		c = {
			level = 55,
			prize = {2160, 6}
		}
	},
 
	["Legionnaire"] = {
		c = {
			level = 60,
			prize = {2160, 7}
		}
	},
 
	["Lieutenant General"] = {
		c = {
			level = 70,
			prize = {2160, 8}
		}
	},
 
	["General"] = {
		c = {
			level = 80,
			prize = {2160, 9}
		}
	},
 
	["War Lord"] = {
		c = {
			level = 85,
			prize = {2160, 10}
		}
	},
}
 
local function doPlayerAddDepotItems(cid, pos, town, items, notify) -- credits to Chojy for idea.
	local parcel = doCreateItemEx(2595)
	local label = doAddContainerItem(parcel, 2599)
	doSetItemText(label, getCreatureName(cid) .."\n".. town)
	doAddContainerItemEx(parcel, items)
	doTeleportThing(parcel, pos)
	if(notify == true) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your reward has been sent to your depot because you were unable to carry it.")
	end
 
	return true
end
 
function onAdvance(cid, skill, oldLevel, newLevel)
	for desc, i in pairs(ranks) do
		if skill == SKILL__LEVEL then
			if newLevel >= i.c.level then
				if getCreatureStorage(cid, config.storage) < newLevel then
 
					local id = doCreateItemEx(i.c.prize[1], i.c.prize[2] or 1)
					if(doPlayerAddItemEx(cid, id, false) ~= RETURNVALUE_NOERROR) then
						doPlayerAddDepotItems(cid, config.mailbox[1], getTownName(getPlayerTown(cid)), id, true)
					end
 
					doCreatureSetStorage(cid, config.storage, newLevel)
					doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
					doCreatureSay(cid, "Congratulations! You are now a ' ... desc .. '.", TALKTYPE_MONSTER)
					break
				end
			end
		end
	end
end
Also i'll have to agree with Magich, why break something that isn't in a loop? xD.
 
Thanks Korrex
So Noob i am, Just a stupid End. LOL


let me try without Break too

That's what my post said, it also told you where to put it, if you can't help yourself you will never learn how to do this own your own.
Noone should be asking people to fix their Syntax errors... maybe how to interpret one yes, but not to fix the script.
 
Last edited:
Back
Top