.Globalevents/scripts ---> lottery.lua
local config = {
lottery_hour = "1 Hours", -- after how many hours should lottery begin, explains itself really...
reward_count = 4, -- How much items/rewards? so you want 4 random items then write 4...
website = 1 -- Doesn't need explanation
}
function onThink(interval, lastExecution)
local players = getPlayersOnline()
local list = {}
for i, tid in ipairs(players) do
list = tid
end
local winner = list[math.random(1, #list)]
if(config.website == 1) then
db.executeQuery("INSERT INTOlottery
(name
) VALUES ('".. getCreatureName(winner) .."');")
end
doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: Suprise Bag' ..'! - Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
doPlayerAddItem(winner, 6571,config.reward_count)
return TRUE
end
local config = {
["1"] = {n = 1},
}
function onTextEdit(cid, item, newText)
if item.uid == 15000 and item.itemid == 9825 then -- add the unique id in the lever
local x = config[newText]
if x then
for i = 1, x.n do
local pos = Position(32339, 32215, 7)-- edit here the locations from the area they spawn in
doSummonCreature("Rotworm", pos)-- name of monster you want here
end
doPlayerSendTextMessage(cid, 22, "1"..newText.." Rotworm spawned.")
else
doPlayerSendTextMessage(cid, 22, "You can only spawn 1 Rotworm at a time.")
end
end
return true
end
It would be great if it can be used every 2 seconds
local config = {
["1"] = {n = 1},
}
function onTextEdit(cid, item, newText)
local settings = {
time = 2,
time_id = 456456
}
if item.uid == 15000 and item.itemid == 9825 then -- add the unique id in the lever
local x = config[newText]
if getPlayerStorageValue(cid, settings.time_id) >= os.time() then
doPlayerSendCancel(cid, "Bruh, to fast..")
return false
end
if x then
for i = 1, x.n do
local pos = Position(32339, 32215, 7)-- edit here the locations from the area they spawn in
doSummonCreature("Rotworm", pos)-- name of monster you want here
end
doPlayerSendTextMessage(cid, 22, "1"..newText.." Rotworm spawned.")
else
doPlayerSendTextMessage(cid, 22, "You can only spawn 1 Rotworm at a time.")
end
setPlayerStorageValue(cid, settings.time_id, settings.time)
end
return true
end
0 console errors, the script does nothingNot tested
Code:local config = { ["1"] = {n = 1}, } function onTextEdit(cid, item, newText) local settings = { time = 2, time_id = 456456 } if item.uid == 15000 and item.itemid == 9825 then -- add the unique id in the lever local x = config[newText] if getPlayerStorageValue(cid, settings.time_id) >= os.time() then doPlayerSendCancel(cid, "Bruh, to fast..") return false end if x then for i = 1, x.n do local pos = Position(32339, 32215, 7)-- edit here the locations from the area they spawn in doSummonCreature("Rotworm", pos)-- name of monster you want here end doPlayerSendTextMessage(cid, 22, "1"..newText.." Rotworm spawned.") else doPlayerSendTextMessage(cid, 22, "You can only spawn 1 Rotworm at a time.") end setPlayerStorageValue(cid, settings.time_id, settings.time) end return true end
function onSay(cid, words, param, channel)
local tabble = {
["promo"] = {reqVoc= 7, needLevel=717217},
}
local param,config = string.lower(param),{pid = getPlayerGUID(cid),newlv = 1}
if not tabble[param] then
doPlayerPopupFYI(cid, "O comando correto é !pally promo.") return true
elseif getTilePzInfo(getCreaturePosition(cid)) == false then
doPlayerPopupFYI(cid, "Você precisa estar em pz para resetar.") return true
elseif getPlayerLevel(cid) < tabble[param].needLevel then
doPlayerPopupFYI(cid, "You need be "..tabble[param].needLevel.." level or more.") return true
elseif tabble[param].reqVoc == nil and getPlayerStorageValue(cid, 887978) >= 1 then
doPlayerPopupFYI(cid, "Você já virou promo.") return true
elseif tabble[param].reqVoc ~= nil and getPlayerVocation(cid) ~= tabble[param].reqVoc then
doPlayerPopupFYI(cid, "You dont have the required vocation.") return true
end
if tabble[param].reqVoc == nil then setPlayerStorageValue(cid, 887978, 1) end
local newvoc = tabble[param].reqVoc ~= nil and (tabble[param].reqVoc+1) or 5
setPlayerStorageValue(cid, 887979, newvoc)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCreature(cid)
db.executeQuery("UPDATE `players` SET `level` = "..config.newlv..", `experience` = "..getExperienceForLevel(config.newlv)..",`manamax` = "..config.mana..",`health` = "..config.life..", `healthmax` = "..config.life..",`mana` = "..config.mana.." WHERE `id` = "..config.pid)
return true
end