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

leandroluck

New Member
Joined
Dec 24, 2010
Messages
104
Reaction score
1
global events
Code:
l
local config = {
p_time = 1, -- Tempo em segundos para receber os pontos( 3600 = 1hora )
p_points = 1 -- Quantidade de pontos recebida a cada "p_time"
}

local function givePoints(cid, quant)
if os.time() - player:getStorageValue(974859) >= config.p_time then
doPlayerSendTextMessage(cid, 19, "Congratulations, you recieved ".. config.p_points .." p points. Now you have ".. config.p_points .." p points in your account. Your timer was reseted.")
--db.query("UPDATE `accounts` SET `coins` = `coins` + '" .. p_points .. "' WHERE `id` = '" .. player:getAccountId() .. "';")
player:setStorageValue(974859, 0)
player:setStorageValue(974859, os.time())
end
return true
end

function onThink(interval)
for i, v in pairs(Game.getPlayers()) do
givePoints(v, config.p_points)
end
return true
end

creaturescripts
Code:
function onLogin(cid)
doCreatureSetStorage(cid, 974859, os.time())
return true
end

function onLogout(cid)
doCreatureSetStorage(cid, 974859, 0)
return true
end

Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/points.lua:eek:nThink
data/globalevents/scripts/points.lua:7: attempt to index global 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/globalevents/scripts/points.lua:7: in function 'givePoints'
data/globalevents/scripts/points.lua:18: in function <data/globalevents/scripts/points.lua:16>
[Error - GlobalEvents::think] Failed to execute event: pointss
 
Last edited:
Back
Top