DiS
Advanced User
- Joined
- Apr 5, 2008
- Messages
- 274
- Reaction score
- 12
Witam!
Mam taki skrypcik z forum na lottery system, chcia?bym go przerobi? tak, aby nie losowa? wygranego z graczy online (poniewa? moj silnik nie zna funkcji getPlayersOnline :/
Tylko ?eby losowa? z po?r?d graczy kt?rzy maj? jakie? storage.
Storage gracz b?dzie kupowa? przez komende !lottery za 1000gp
Teraz moja pro?ba: m?g?by kto? POPRAWNIE umie?ci? t? funkcje w tym skrypcie? nie wiem czemu mi nie wychodzi
Mam taki skrypcik z forum na lottery system, chcia?bym go przerobi? tak, aby nie losowa? wygranego z graczy online (poniewa? moj silnik nie zna funkcji getPlayersOnline :/
Tylko ?eby losowa? z po?r?d graczy kt?rzy maj? jakie? storage.
Storage gracz b?dzie kupowa? przez komende !lottery za 1000gp
Teraz moja pro?ba: m?g?by kto? POPRAWNIE umie?ci? t? funkcje w tym skrypcie? nie wiem czemu mi nie wychodzi
if getPlayerStorageValue(cid, 10005) == 1 then
local config = {
lottery_hour = "5 Hour", -- Czas do nast?pnej loterii (tylko bedzie pisa?o na czerwono ile czasu wszystko w globalevents.xml ustawiamy)
rewards_id = {2494, 2472, 2514, 2160, 2495, 6132, 2493, 8266, 8905}, -- Wygrane przedmioty
crystal_counts = 4, -- U?ywamy to jesli do wygrania jest cc (ID: 2160).
website = "no" -- Tylko w tedy jesli mamy strone i tabele`lottery` w bazie danych!
}
function onThink(interval, lastExecution)
if(getWorldCreatures(0) == 0)then
return true
end
local list = {}
for i, tid in ipairs(getPlayersOnline()) do
list = tid
end
local winner = list[math.random(1, #list)]
local random_item = config.rewards_id[math.random(1, #config.rewards_id)]
if(random_item == 2160) then
doPlayerAddItem(winner, random_item, config.crystal_counts)
doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .. " " .. getItemNameById(random_item) .. "s! Congratulations! (Next Lottery in " .. config.lottery_hour .. ")")
else
doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. getItemNameById(random_item) .. "! 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`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');")
end
return true
end