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

Haate

John Ever Stone
Joined
Apr 2, 2010
Messages
113
Reaction score
1
Location
Ełk
Bug:
Code:
[16/06/2010 16:06:16] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/playtime.lua:2: ')' expected near '.'
[16/06/2010 16:06:16] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/playtime.lua)
[16/06/2010 16:06:16] data/creaturescripts/scripts/playtime.lua:2: ')' expected near '.'
Script:
Code:
local function playmessage(i)
doPlayerSendTextMessage(i.cid, 19, 'Grasz juz '.i.playtime.' godzin bez przerwy, odpocznij, bo sie uzaleznisz!')
i.cid = cid
i.playtime = (i.playtime+1)
return addEvent(1000*3600, playmessage, i)
end

function onLogIn(cid)
i.cid = cid
i.playtime = 1
addEvent(1000*3600, playmessage, i)
end
 
try now

Code:
function playmessage()
local i.cid = cid
local i.playtime = (i.playtime+1)
	doPlayerSendtextMessage(i.cid,19,'Grasz juz '..i.playtime..' godzin bez przerwy, odpocznij, bo sie uzaleznisz!')
	return addEvent(playmessage,1000*60*60)
end

function onLogin(cid)
local i.cid = cid
local i.playtime = 1
	return addEvent(playmessage,1000*60*60)
end
 
and:
Code:
[16/06/2010 16:41:08] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/playtime.lua:2: unexpected symbol near '.'
[16/06/2010 16:41:08] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/playtime.lua)
[16/06/2010 16:41:08] data/creaturescripts/scripts/playtime.lua:2: unexpected symbol near '.'
 
Lua:
function playmessage()
local i.cid = cid
local i.playtime = (i.playtime+1)
	doPlayerSendtextMessage(i.cid,19,Grasz juz '..i.playtime..' godzin bez przerwy, odpocznij, bo sie uzaleznisz!)
	return addEvent(playmessage,1000*60*60)
end

function onLogin(cid)
local i.cid = cid
local i.playtime = 1
	return addEvent(playmessage,1000*60*60)
end
 
and:
Code:
[16/06/2010 16:50:25] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/playtime.lua:2: unexpected symbol near '.'
[16/06/2010 16:50:25] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/playtime.lua)
[16/06/2010 16:50:25] data/creaturescripts/scripts/playtime.lua:2: unexpected symbol near '.'
 
Code:
local function playMessage(cid, hours)
	if(isPlayer(cid)) then
		doPlayerSendTextMessage(cid, 19, 'Grasz juz ' .. hours .. ' godzin bez przerwy, odpocznij, bo sie uzaleznisz!')
		addEvent(60 * 60 * 1000, playMessage, cid, hours + 1)
	end
end

function onLogin(cid)
	addEvent(60 * 60 * 1000, playMessage, cid, 1)
	return true
end
 
Code:
[18/06/2010 23:21:40] [Error - CreatureScript Interface] 
[18/06/2010 23:21:41] data/creaturescripts/scripts/playtime.lua:onLogin
[18/06/2010 23:21:41] Description: 
[18/06/2010 23:21:41] (luaAddEvent) Callback parameter should be a function.

When script must say to player TFS show this bug, later I don't have server online 1 hour.
 
Code:
[18/06/2010 23:21:40] [Error - CreatureScript Interface] 
[18/06/2010 23:21:41] data/creaturescripts/scripts/playtime.lua:onLogin
[18/06/2010 23:21:41] Description: 
[18/06/2010 23:21:41] (luaAddEvent) Callback parameter should be a function.

When script must say to player TFS show this bug, later I don't have server online 1 hour.

Try to remove "local" before playMessage function.
 
parameters = function, delay not delay, function, so:
addEvent(60 * 60 * 1000, playMessage, cid, 1)
to
addEvent(playMessage, 60 * 60 * 1000, cid, 1)


and
addEvent(60 * 60 * 1000, playMessage, cid, hours + 1)
to
addEvent(playMessage, 60 * 60 * 1000, cid, hours + 1)
 
Code:
[21/06/2010 13:39:24] [Error - CreatureScript Interface] 
[21/06/2010 13:39:24] data/creaturescripts/scripts/playtime.lua:onLogin
[21/06/2010 13:39:24] Description: 
[21/06/2010 13:39:24] data/creaturescripts/scripts/playtime.lua:9: attempt to perform arithmetic on global 'hours' (a nil value)
[21/06/2010 13:39:24] stack traceback:
[21/06/2010 13:39:24] 	data/creaturescripts/scripts/playtime.lua:9: in function <data/creaturescripts/scripts/playtime.lua:8>

When I enter the game it pops up and throws me.
 
You copied something wrong, it should work if you did what @Rhux said.

Code:
local function playMessage(cid, hours)
	if(isPlayer(cid)) then
		doPlayerSendTextMessage(cid, 19, 'Grasz juz ' .. hours .. ' godzin bez przerwy, odpocznij, bo sie uzaleznisz!')
		addEvent(playMessage, 60 * 60 * 1000, cid, hours + 1)
	end
end

function onLogin(cid)
	addEvent(playMessage, 60 * 60 * 1000, cid, 1)
	return true
end
 
Back
Top