• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lottery System configuration ;)

Status
Not open for further replies.
Na oczy nie mogę uwierzyć... otlandowicze pomagają! o.0!

Nie każdemu da się pomóc... tzn. nie dlatego, że nie ma się wiedzy, tylko(każdy powinien wiedzieć o co chodzi, jeśli nie wie niech poczyta posty w tym dziale...)<- patrz w nawias.
 
No więc tak, z timerem już znalazłem i powinno działać. Lecz skrypt Piotrka jest dziwny (?). Wklejam go do data/scripts/globalevents to wyskakuje:
hp.png

A ten skrypt tam jest, więc nie wiem :/
Nazwa skryptu to lottery.lua

bo musi być interval ustawiony, czyli nie możesz mieć w globalevents.xml (ograniczeniem jest tu sam skrypt...)
time="", tylko interval="10800"
 
No dobra zmieniłem na to co powiedziałeś, lecz teraz to będzie na zasadzie że co 3h. A nie o danej godzienie.
Próbowałem zrobić tak jak jest w example:
<!-- <globalevent name="timer_example" time="21:35" event="script" value="my_script.lua"/> -->
I zmieniłem na:
<globalevent name="lottery" time="20:00" event="script" value="lottery.lua"/>
I nie działa, bo wyskakuje ten błąd.
Więc jak mogę teraz ustawić żeby było o danej godzinie?
 
bo kurna mowie ze ograniczeniem ejst tu sam skrypt wiec musisz ustawic interval...

#edit
możesz użyć
Code:
function onTimer()
zamiast
Code:
function onThink(....)
Żeby time="" działało...
 
Last edited:
w ktorym miejscu skrypt w jakikolwiek sposob ogranicza swoje wykonanie? patrze i nie moge znalezc (patrze na skrypt piotrka na poprzedniej stronie)
pozatym, nie lepiej jest w ten sposob:
LUA:
local random = math.random(1, #getOnlinePlayers())
local player = getPlayerByName(getOnlinePlayers()[random])
??
 
w ktorym miejscu skrypt w jakikolwiek sposob ogranicza swoje wykonanie? patrze i nie moge znalezc (patrze na skrypt piotrka na poprzedniej stronie)
pozatym, nie lepiej jest w ten sposob:
LUA:
local random = math.random(1, #getOnlinePlayers())
local player = getPlayerByName(getOnlinePlayers()[random])
??

Popatrz na pierwszą linię, mówi sama za siebie.
Popatrz także an mój wcześniejszy post, podałem co można zrobić...
 
Zmieniłem, zaraz zobaczymy czy zadziała ;)
 
No i jest błąd...
bug.png

Potrafi ktoś pomóc ;p?
Pozdro Boomer.
 
Code:
local config = {
    lottery_hour = "24 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
    points = 15, -- how many points winner get?
    website = "yes" -- Do you have `lottery` table in your database?
    }
function onTimer(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)]
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = ".. getAccountByName(winner) ..";")
                doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: +' .. points ..' points to the SMS Shop! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
                if(config.website == "yes") then
                        db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. config.points .." premium points');")
                end
    return TRUE
end

ALBO TAKI:

Code:
local config = {
    lottery_hour = "24 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
    points = 15, -- how many points winner get?
    website = "yes" -- Do you have `lottery` table in your database?
    }
function onTimer()
    local players = getPlayersOnline()
    local list = {}
    for i, tid in ipairs(players) do
    list[i] = tid
end
        local winner = list[math.random(1, #list)]
                db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = ".. getAccountByName(winner) ..";")
                doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: +' .. points ..' points to the SMS Shop! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
                if(config.website == "yes") then
                        db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. config.points .." premium points');")
                end
    return TRUE
end

A w .xml mam
Code:
      <globalevent name="lottery" time="18:00" event="script" value="lottery.lua"/>
 
mosz..
LUA:
local config = {
	lottery_hour = "24 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
	points = 15, -- how many points winner get?
	website = "yes" -- Do you have `lottery` table in your database?
	}
function onTimer()
	local rand_player = math.random(1, #getOnlinePlayers())
	local winner = getPlayerByName(getOnlinePlayers()[rand_player]) 
		db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = ".. getAccountByName(winner) ..";")
		doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. getCreatureName(winner) ..', Reward: +' .. points ..' points to the SMS Shop! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
		if(config.website == "yes") then
			db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. config.points .." premium points');")
		end
	return TRUE
end
 
LUA:
local config = {
	lottery_hour = "24 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
	points = 15, -- how many points winner get?
	website = "yes" -- Do you have `lottery` table in your database?
}

function onTimer()

	local random = math.random(1, #getOnlinePlayers())
	local name = getOnlinePlayers()[random]

	db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `name` = ".. getAccountByName(name) ..";")
	doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. name ..', Reward: +' .. points ..' points to the SMS Shop! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
	if(config.website == "yes") then
		db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. name .."', '".. config.points .." premium points');")
	end
	return true
end

na szybko robione, jak beda bledy to wklej
 
LUA:
local config =
{
	lottery_hour = "24 Hours", -- Time to next lottery (real time you set on globalevents.xml, its only for broadcast message.)
	points = 15, -- how many points winner get?
	website = "yes" -- Do you have `lottery` table in your database?
}

function onTimer()
	local random, name = math.random(1, #getOnlinePlayers()), getPlayerNameByGUID(random)
	
	db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` +" .. config.points .. " WHERE `id` = ".. getAccountIdByName(name) ..";")
	doBroadcastMessage('[LOTTERY SYSTEM] Winner: '.. name ..', Reward: +' .. points ..' points to the SMS Shop! Congratulations! (Next Lottery in '.. config.lottery_hour ..')')
	if(config.website == "yes") then
		db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. name .."', '".. config.points .." premium points');")
	end
	return true
end
na szybko robione, jak beda bledy to wklej
 
Ani jeden ani drugi nie działą ;<
helppppppppppppppppppppppp.png
 
Ilu masz graczy online?
Hę? 0 bo dopiero robię OTS ;p

Pewnie null
Hmmm?

Znaczy nie wiem czy dobrze zrozumiałem, ale czy chodzi wam o to że musi ktoś być online żeby zadziałał skrypt?
 
Status
Not open for further replies.
Back
Top