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

Help me with this script

StreamSide

Joseluis Gonzalez
Staff member
Support Team
Joined
Aug 31, 2007
Messages
3,608
Solutions
51
Reaction score
1,223
Location
Arica - Chile
Well, iam very noob in scripts and i really need this script:
Code:
function onLogin(cid)
    if(InitHistory == 0) then
        local historyPage = addEvent(historyPage, 60000, {})
        InitHistory = historyPage
	end
end

function historyPage(parameters)
	dofile("./config.lua")
	env = assert(luasql.mysql())
		con = assert(env:connect(sqlDatabase, sqlUser, sqlPass, sqlHost, sqlPort))
	local historyPage = addEvent(historyPage, 60000, {})
	if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
		setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
		assert(con:execute("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;"))
		assert(con:execute("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;"))
	end
	assert(con:execute("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;"))
	con:close()
	env:close()
end

Error message:
Code:
[18/12/2008 19:26:37] Lua Script Error: [CreatureScript Interface] 
[18/12/2008 19:26:37] in a timer event called from: 
[18/12/2008 19:26:37] data/creaturescripts/scripts/login2.lua:onLogin

[18/12/2008 19:26:37] data/creaturescripts/scripts/login2.lua:10: attempt to index global 'luasql' (a nil value)
[18/12/2008 19:26:37] stack traceback:
[18/12/2008 19:26:37] 	data/creaturescripts/scripts/login2.lua:10: in function <data/creaturescripts/scripts/login2.lua:8>

What is wrong with this?
Empty say: luasql isn't used in 0.3 - I haven't worked with either lusql or the new system

So? i need help :D
Thanks...


P.S.: Sorry for my english
 
I want to sleep and maybe I maked many errors, but try this:

function onLogin(cid)
if(InitHistory == 0) then
local historyPage = addEvent(historyPage, 60000, {})
InitHistory = historyPage
end
end

function historyPage(parameters)
local historyPage = addEvent(historyPage, 60000, {})
if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
end
db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
con:close()
env:close()
end
 
I want to sleep and maybe I maked many errors, but try this:

Error D:
Code:
[18/12/2008 21:18:30] Lua Script Error: [CreatureScript Interface] 
[18/12/2008 21:18:30] in a timer event called from: 
[18/12/2008 21:18:30] data/creaturescripts/scripts/login2.lua:onLogin

[18/12/2008 21:18:30] data/creaturescripts/scripts/login2.lua:16: attempt to index global 'con' (a nil value)
[18/12/2008 21:18:30] stack traceback:
[18/12/2008 21:18:30] 	data/creaturescripts/scripts/login2.lua:16: in function <data/creaturescripts/scripts/login2.lua:8>
 
now?

PHP:
function onLogin(cid)
if(InitHistory == 0) then
local historyPage = addEvent(historyPage, 60000, {})
InitHistory = historyPage
end
end

function historyPage(parameters)
local historyPage = addEvent(historyPage, 60000, {})
	if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
	setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
	db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
	db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
	end
db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
end
 
now?

PHP:
function onLogin(cid)
if(InitHistory == 0) then
local historyPage = addEvent(historyPage, 60000, {})
InitHistory = historyPage
end
end

function historyPage(parameters)
local historyPage = addEvent(historyPage, 60000, {})
	if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
	setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
	db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
	db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
	end
db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
end

No errors for now (testing)
Thanks man :D
 
Back
Top