What's new

Mods Nagroda za bycie online

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Autor: Vodkart
Opis: System nagr?d, w kt?rym gracz otrzymuje nagrod? za sp?dzony czas online na serwerze.
UWAGA: Blokada MC (Konfiguracja).
Dodatkowe: Dzi?ki komendzie !mytime mo?emy zobaczy?, ile czasu potrzeba, aby otrzyma? nagrod?.

reward_time_system.xml
[xml]<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Reward Time System" version="1.0" author="vodkart" contact="none" enabled="yes">
<config name="rewardtime_lib"><![CDATA[

config_won_hours = {
need_hour = 5,
storages = {789140, 789141, 789142, 789143} -- caso precise adicionar mais storages p/ fzr altera?ões
}

rewards = {items = {2160,5}, points = 0, p_days = 0} -- defina a premia?ão

function getAmountSameIp(cid)
local t = {}
for _, pid in pairs(getPlayersOnline()) do
if getPlayerIp(cid) == getPlayerIp(pid) then
t[#t+1] = pid
end
end
return t
end
function getPlayerHours(cid)
return timeString((os.time() - getPlayerStorageValue(cid, config_won_hours.storages[1])))[2]
return query:getDataInt("premium_points") <= 0 and 0 or query:getDataInt("premium_points")
end
function setPremiumPoints(cid, amount)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = "..amount.." WHERE `id` = "..getPlayerAccountId(cid))
end
function startRewardTime(cid)
if getPlayerStorageValue(cid, config_won_hours.storages[4]) == -1 then -- when die
if getPlayerStorageValue(cid, config_won_hours.storages[2]) <= 0 then -- first login
setPlayerStorageValue(cid, config_won_hours.storages[1], os.time())
setPlayerStorageValue(cid, config_won_hours.storages[2], 1)
else

table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' and ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
end
end
local ret = table.concat(out)
if ret:len() < 16 and ret:find("second") then
local a, b = ret:find(" and ")
ret = ret:sub(b+1)
end
function dorewardHours(cid)
if rewards.points > 0 then setPremiumPoints(cid, getPremiumPoints(cid)+rewards.points) rst = rst.."".. (rst == "" and "" or ", ") .." "..rewards.points.." premium points." end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Rewards Time System] Obrigado por ficar online durante "..config_won_hours.need_hour.." hours Recompensas: "..(rst == "" and "nenhuma" or rst))
setPlayerStorageValue(cid, config_won_hours.storages[1], os.time())
end
]]></config>
<globalevent name="Salve-PlayerTime" interval="60" event="script">
function onThink(interval, lastExecution, thinkInterval)
if #getPlayersOnline() > 0 then
for _, cid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, config_won_hours.storages[3]) <= 0 and getPlayerHours(cid) >= config_won_hours.need_hour then -- check hours
dorewardHours(cid)
end
end
end
return true
end]]></globalevent>
<talkaction words="/mytime;!mytime" event="buffer"><![CDATA[
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your Reward Time is blocked because you are using MC.") return true
end
local count = (os.time() - getPlayerStorageValue(cid, config_won_hours.storages[1]))
local _ = -(count-config_won_hours.need_hour*3600)
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerHours(cid) >= config_won_hours.need_hour and "Wait a few moments to receive the reward" or "[Reward Time System] Remaining time to receive a reward: "..timeString(_)[1])
]]></talkaction>
<event type="login" name="RewardTimeLogin" event="script"
domodlib('rewardtime_lib')
function onLogin(cid)
registerCreatureEvent(cid, "RewardTimeDeath")
setPlayerStorageValue(cid, config_won_hours.storages[3], 0)
startRewardTime(cid)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Reward Time System] Your Reward Time is blocked because you are using MC.")
setPlayerStorageValue(cid, config_won_hours.storages[3], 1)
end
return true
end]]></event>
<event type="logout" name="RewardTimeLogout" event="script">
function onLogout(cid)
if getPlayerStorageValue(cid, config_won_hours.storages[3]) > 0 then -- if not is MC
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Reward Time System] Your time has begun to be counted, avoid MC.")
setPlayerStorageValue(pid, config_won_hours.storages[3], 0)
break
end
end
end
end
return true
end]]></event>
<event type="preparedeath" name="RewardTimeDeath" event="script"><![CDATA[
domodlib('rewardtime_lib')
function onPrepareDeath(cid, corpse)
setPlayerStorageValue(cid, config_won_hours.storages[1], getPlayerStorageValue(cid, config_won_hours.storages[1]) - os.time())
setPlayerStorageValue(cid, config_won_hours.storages[4], getPlayerStorageValue(cid, config_won_hours.storages[1])) -- when die no bug hours
setPlayerStorageValue(cid, config_won_hours.storages[1], getPlayerStorageValue(cid, config_won_hours.storages[1]) + os.time())
if config_won_hours.block_mc[1] and #getAmountSameIp(cid) > config_won_hours.block_mc[2] then -- block mc time
for _, pid in ipairs(getAmountSameIp(cid)) do
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_ORANGE,"[Reward Time System] Your time has begun to be counted, avoid MC.")
setPlayerStorageValue(pid, config_won_hours.storages[3], 0)
break
end
end
end
end
end
return true
end]]></event>
</mod>[/xml]
 

Avemajor

Advanced User
Joined
Feb 6, 2012
Messages
346
Reaction score
12
Odp: Nagroda za bycie online

na jakim silniku dzia?a ?
 
Top