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

Solved Problem with my login.lua file

mijnoma

Learning to build ot
Joined
Feb 7, 2009
Messages
19
Reaction score
0
I'm fighting with my account manager for several days allready.
Now when I started the server and read the log, it tells me there is an end expected in the lua code (line 6)

Can any1 tell me where an end is missing since I can't manage to find it

Code:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)

	if (getConfigValue("accountManager") == FALSE and getCreatureName(cid) == "Account Manager") then
		return false
	end

	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")
	registerCreatureEvent(cid,'SpellUp')


	registerCreatureEvent(cid, "Idle")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	return true
		local mposx = getConfigInfo('newPlayerSpawnPosX') 
		local mposy = getConfigInfo('newPlayerSpawnPosY') 
		local mposz = getConfigInfo('newPlayerSpawnPosZ') 
		local mtid = getConfigInfo('newPlayerTownId') 

		function onLogin(cid, pos) 
		db.executeQuery("SELECT `id` , `posx` , `posy` , `posz` `town_id` FROM `players` WHERE id >0 AND posx =0 AND posy =0 AND posz =0 AND town_id=0;") 
		db.executeQuery("UPDATE players SET posx="..mposx..", posy="..mposy..", posz="..mposz..", town_id="..mtid.." WHERE id>0 AND posx =0 AND posy =0 AND posz =0 AND town_id=0;")             
		registerCreatureEvent(cid, "PlayerDeath") 
		return TRUE 
		end 
end


I don't know how you guys get the colours in the script so it could be a bit unclear now :S I'm new with this forum :p
The missing end is about "function" but in my opinion it's ended in the very end of the script
 
Why do you have this piece of code o.o?

Lua:
	if (getConfigValue("accountManager") == FALSE and getCreatureName(cid) == "Account Manager") then
		return false
	end

And try to post a Screenshot of the error :p
 
I downloaded this server which allready had all those codes programmed. That piece of code allready was programmed inside. I don't really know what it's doing. There is an "if" but no "then". Well it actually is there but "then"doesn't describe anything.

The only reason I didn't remove it yet is that I'm not sure if it's a part of an unfinished script :p

Code:
[19/04/2013 02:02:42] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/login.lua:55: 'end' expected (to close 'function' at line 6) near 'local'
[19/04/2013 02:02:42] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)
[19/04/2013 02:02:42] data/creaturescripts/scripts/login.lua:55: 'end' expected (to close 'function' at line 6) near 'local'

BTW logging in with the GOD account that allready was inside works fine. The account manager doesn't work. Wrong temple position but I think this problem might be linked to the code faillure.
 
Wrong temple position is another problem... Change the position of the Account Manager in the BD and on the Config.lua
 
Allready changed it in config.lua and map editor. Didn't setup Uniserver yet since I'm working from my home computer atm and it will be on another ip and directory later.
But did you find any troubles in the code? Except from that weird part of code that doesn't really have a function.

- - - Updated - - -

I copied another login.lua file wich i found in google and now i don't get the error anymore. Now just check if it doesn't bug or anything (i saved the old file as a backup so don't worry)
 
Well, the problem was you had there two "return true" lines :)

Code:
registerCreatureEvent(cid, "AdvanceSave")
	return true -- you should had removed this line
		local mposx = getConfigInfo('newPlayerSpawnPosX')
Btw. why did you have there two onLogin functions?
 
Well, the problem was you had there two "return true" lines :)

Code:
registerCreatureEvent(cid, "AdvanceSave")
	return true -- you should had removed this line
		local mposx = getConfigInfo('newPlayerSpawnPosX')
Btw. why did you have there two onLogin functions?

Copy/Paste maybe, I downloaded the server to check the problem but was clean with no errors...
 
hmm.. kinda weird then.
Mine gave the error without changing the login.lua
Well the server doesn't give an error with the new script.
It only doesn't say it loaded login.lua while it does with other .lua files so i'm not sure if it's ok.
I can try to download it again and import my new map in it. Possibly my acc manager bug is gone then too.
Only have to setup all new scripts and stuff :/
 
Back
Top