gameover99097
Banned User
- Joined
- Nov 19, 2010
- Messages
- 270
- Reaction score
- 4
Mam tu pare nie pewnych plików , chce tylko znać znaczenie i czy nie na robi syfu .
Folder actions
addon.lua
globalevents
noDDos.lua
lottery.lua
Folder actions
addon.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if (getPlayerStorageValue(cid, 4767) == EMPTY_STORAGE) then
doCreatureSay(cid, "You have gained your new outfit and may leave the reward room now!", TALKTYPE_ORANGE_1)
doPlayerAddOutfit(cid, 336, 0)
doPlayerAddOutfit(cid, 335, 0)
setPlayerStorageValue(cid, 4767, 1)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
else
doPlayerSendTextMessage(cid,22,"You have already gained your new outfit. You may leave the room now.")
end
return true
end
globalevents
noDDos.lua
Code:
------ DDoS protection
------ By Mock
------ Require Lua socket
local conf = {
check_website1 = 'http://www.google.com/', ---- First website
check_website2 = 'http://pt.wikipedia.org/', ---- Second website
ifoff = { --- If this 2 websites was offline
kickall = true, --- Kick all players?
save = true, --- Save server?
closeserver = true, --- Exit server?
}
}
--[[
This script every X seconds will check if google is online,
if google is off it will check wikipedia, if wikipedia is
off too is because your net is verry overloaded (DDoS attack)
or your connection is down. If all this is off this script
will kick all players, save server and close server.
]]
function onThink(interval, lastExecution)
assert(socket,'Please install socket!')
assert(socket.http,'Please install socket.http')
local re,info,kind = pcall(socket.http.request,conf.check_website1)
if not info or re == false then
print('::Google is off?\a')
if conf.check_website2 and conf.check_website2 ~= '' and conf.check_website2:len() > 6 then
local re,info,kind = pcall(socket.http.request,conf.check_website2)
if not info or re == false then
print('::We are under attack or you connection is offline!\a\a')
if conf.ifoff.kickall == true then
for i,b in pairs(getOnlinePlayers()) do
doRemoveCreature(b)
end
end
if conf.ifoff.save == true then
saveServer()
end
if conf.ifoff.closeserver == true then
os.sleep(2)
os.exit()
end
end
end
end
return TRUE
end
lottery.lua
Code:
-- by vDk, klekSu
local config = {
lottery_hour = "3 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
rewards_id = {2494, 2472, 2514, 2160}, -- Rewards ID
crystal_counts = 10, -- used only if on rewards_id you have crystal coins (ID: 2160).
website = "yes" -- Do you have `lottery` table in your database?
}
function onThink(interval, lastExecution)
local players = getPlayersOnline()
local list = {}
for i, tid in ipairs(players) do
list[i] = tid
end
local winner = list[math.random(1, #list)]
local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
local item_name = getItemNameById(random_item)
local world = tonumber(getPlayerWorldId(winner))
if(random_item == 2160) then
doPlayerAddItem(winner, random_item, config.crystal_counts)
doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: '.. config.crystal_counts ..' '.. item_name ..'s! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
else
doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: '.. item_name ..'! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
doPlayerAddItem(winner, random_item, 1)
end
if(config.website == "yes") then
db.executeQuery("INSERT INTO `lottery` (`name`, `item`, `world_id`) VALUES ('".. getCreatureName(winner) .."', '".. item_name .."', '".. world .."');")
end
return TRUE
end