<event type="login" name="itemLogin" event="script" value="*****.lua"/>
<event type="logout" name="itemLogout" event="script" value="*****.lua"/>
registerCreatureEvent(cid, "itemLogin")
registerCreatureEvent(cid, "itemLogout")
local items = {
[1] = {
itemid = 2160,
count = 1,
},
[2] = {
itemid = 2160,
count = 2
}
}
local events = {}
local function addReward(cid, rewardId)
if not isPlayer(cid) then
return
end
local item = items[rewardId or #items]
doPlayerAddItem(cid, item.itemid, item.count)
events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1)
end
function onLogin(cid)
events[cid] = addEvent(addReward, 60...
<event type="login" name="itemLogin" event="script" value="*****.lua"/>
<event type="logout" name="itemLogout" event="script" value="*****.lua"/>
registerCreatureEvent(cid, "itemLogin")
registerCreatureEvent(cid, "itemLogout")
local items = {
[1] = {
itemid = 2160,
count = 1,
},
[2] = {
itemid = 2160,
count = 2
}
}
local events = {}
local function addReward(cid, rewardId)
if not isPlayer(cid) then
return
end
local item = items[rewardId or #items]
doPlayerAddItem(cid, item.itemid, item.count)
events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1)
end
function onLogin(cid)
events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, 1)
return true
end
function onLogout(cid)
if events[cid] then
stopEvent(events[cid])
events[cid] = nil
end
return true
end
in login.luaXML:<event type="login" name="itemLogin" event="script" value="*****.lua"/> <event type="logout" name="itemLogout" event="script" value="*****.lua"/>
Lua:registerCreatureEvent(cid, "itemLogin") registerCreatureEvent(cid, "itemLogout")
*****.lua
Lua:local items = { [1] = { itemid = 2160, count = 1, }, [2] = { itemid = 2160, count = 2 } } local events = {} local function addReward(cid, rewardId) if not isPlayer(cid) then return end local item = items[rewardId or #items] doPlayerAddItem(cid, item.itemid, item.count) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1) end function onLogin(cid) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, 1) return true end function onLogout(cid) if events[cid] then stopEvent(events[cid]) events[cid] = nil end return true end
in login.luaXML:<event type="login" name="itemLogin" event="script" value="*****.lua"/> <event type="logout" name="itemLogout" event="script" value="*****.lua"/>
Lua:registerCreatureEvent(cid, "itemLogin") registerCreatureEvent(cid, "itemLogout")
*****.lua
Lua:local items = { [1] = { itemid = 2160, count = 1, }, [2] = { itemid = 2160, count = 2 } } local events = {} local function addReward(cid, rewardId) if not isPlayer(cid) then return end local item = items[rewardId or #items] doPlayerAddItem(cid, item.itemid, item.count) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, rewardId + 1) end function onLogin(cid) events[cid] = addEvent(addReward, 60 * 60 * 1000, cid, 1) return true end function onLogout(cid) if events[cid] then stopEvent(events[cid]) events[cid] = nil end return true end
Event onAdvance not found. data/creaturescripts/scripts/rewards.lua
try this globalevent, not testedI need the exact same script but for TFS 1.3
5cc every hour you are online
<globalevent name="OnlinePoints" interval="1800000" script="others/online_points.lua" />
local config = {
storageTime = 25230, -- storage time online
timeMax = (20000), -- 1 hour
pointsPerTime = 1, -- 1 point per hour
itemPoint = 2160 -- item per hour
}
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local playerIp = player:getIp()
if (playerIp ~= 0) then
local time = player:getStorageValue(config.storageTime)
if (time < 0) then time = 0 end
if (time >= config.timeMax) then
player:setStorageValue(config.storageTime, 0)
player:addItem(config.itemPoint, config.pointsPerTime)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'You recieved ' .. config.pointsPerTime .. ' ' .. ItemType(config.itemPoint):getName() .. ' because 30 minutes of gameplay has passed in Greed.')
else
player:setStorageValue(config.storageTime, (time + interval))
end end end
return true
end
Thx! This worked perfectly!try this globalevent, not tested
XML:<globalevent name="OnlinePoints" interval="1800000" script="others/online_points.lua" />
Lua:local config = { storageTime = 25230, -- storage time online timeMax = (20000), -- 1 hour pointsPerTime = 1, -- 1 point per hour itemPoint = 2160 -- item per hour } function onThink(interval) for _, player in ipairs(Game.getPlayers()) do local playerIp = player:getIp() if (playerIp ~= 0) then local time = player:getStorageValue(config.storageTime) if (time < 0) then time = 0 end if (time >= config.timeMax) then player:setStorageValue(config.storageTime, 0) player:addItem(config.itemPoint, config.pointsPerTime) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, 'You recieved ' .. config.pointsPerTime .. ' ' .. ItemType(config.itemPoint):getName() .. ' because 30 minutes of gameplay has passed in Greed.') else player:setStorageValue(config.storageTime, (time + interval)) end end end return true end
change line 19 tosorry for bumping this, i'm having this error with the 0.4 script I know it is caused by a loop on the tables, I was looking this post but couldn't get it, can someone fix this so I can get the example, please, thanks in advance!
View attachment 46695
local item = items[rewardId <= #items and rewardId or #items]
Just adapt the function above and use player:getIp() to create a limitCan make it for tfs 1.3 and add coins on your account but only 1 for ipadress? ?
Just adapt the function above and use player:getIp() to create a limit
did you get the script for 1.3?i mean tibia coins to your account
did you get the script for 1.3?
local item = player:addItem(config.pointItemId, config.pointsPerHour)
player:addTibiaCoins(amount)