• 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!

(MOD) Lottery System TFS 0.4

Rossii

Member
Joined
Mar 27, 2012
Messages
366
Reaction score
6
Location
England
Yo i was searching for a Lottery System couldn't find one for TFS 0.4 Once again haha..
Soooo heree it is DNO WHO CREDITS GO TO? Chojrak?



Lottery System. MODS/Lottery System.xml

PHP:
<mod name="Lottery System" version="1.0" author="Chojrak" contact="[email protected]" enabled="yes">
	<config name="lottery">
	<![CDATA[
		config = {
			broadcast = true,
			rewards = {
				-- Item ID[, count]
				{ITEM ID, AMMOUT},
				{ITEM ID, AMMOUT},
                                {ITEM ID, AMMOUT},
                                {ITEM ID, AMMOUT},
                                {ITEM ID, AMMOUT},
                                {ITEM ID, AMMOUT},
			}
		}
		
		
	]]>
	</config>
	<globalevent name="lottery" interval="10000000" event="script">
	<![CDATA[
		domodlib("lottery")
		local dbHandle = db.query and db.query or db.executeQuery;
		function onThink(interval, lastExecution)
			local list = getPlayersOnline()
			if (#list == 0) then
				return true
			end

			local winner = list[math.random(#list)]
			local item = config.rewards[math.random(#config.rewards)]

			doPlayerAddItem(winner, item[1], item[2] or 1)
			if (config.broadcast) then
				doBroadcastMessage(".: Lottery System :.\nWinner is: ".. getCreatureName(winner) .."\nReward: ".. getItemNameById(item[1]) .."\nNext lottery in ".. interval / 60000 .." minutes.")
			end
			dbHandle("INSERT INTO `lottery_system`(`player_id`, `date`, `item_id`, `item_name`) VALUES ( ".. getPlayerGUID(winner) ..", ".. os.time() ..", ".. item[1] ..", '".. getItemNameById(item[1]) .."');");
			return true
		end
	]]>
</globalevent>
</mod>


Add this to your PHPMYADMIN/MYSQL File

PHP:
-- Table structure for table `lottery_system`
--

CREATE TABLE IF NOT EXISTS `lottery_system` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `player_id` int(11) NOT NULL DEFAULT '0',
  `date` int(10) unsigned NOT NULL DEFAULT '0',
  `item_id` int(11) NOT NULL DEFAULT '0',
  `item_name` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `lottery_system`
--

INSERT INTO `lottery_system` (`id`, `player_id`, `date`, `item_id`, `item_name`) VALUES
(3, 205, 1327460833, ITEM ID, 'NAME'),
(4, 217, 1327486033, ITEM ID, 'NAME'),
(5, 266, 1327511233, ITEM ID, 'NAME'),
(6, 236, 1327571565, ITEM ID, 'NAME'),
(7, 180, 1327596765, ITEM ID, 'NAME'),
(8, 403, 1327681153, ITEM ID, 'NAME');

-- --------------------------------------------------------
 
Last edited:
You know that query's gonna show an error in console right?
 
Thanks i updated it.

PHP:
-- Table structure for table `lottery_system`
--

CREATE TABLE IF NOT EXISTS `lottery_system` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `player_id` int(11) NOT NULL DEFAULT '0',
  `date` int(10) unsigned NOT NULL DEFAULT '0',
  `item_id` int(11) NOT NULL DEFAULT '0',
  `item_name` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `lottery_system`
--

INSERT INTO `lottery_system` (`id`, `player_id`, `date`, `item_id`, `item_name`) VALUES
(3, 205, 1327460833, ITEM ID, 'NAME'),
(4, 217, 1327486033, ITEM ID, 'NAME'),
(5, 266, 1327511233, ITEM ID, 'NAME'),
(6, 236, 1327571565, ITEM ID, 'NAME'),
(7, 180, 1327596765, ITEM ID, 'NAME'),
(8, 403, 1327681153, ITEM ID, 'NAME');

-- --------------------------------------------------------
 
Last edited:
Nice job! btw pl0x move the database add in main post becouse there are alot of ppls who only check main post
Repp++
 
edit your first post and add database code easy :)
and nice thx for putting here
 
O right i thought he meant move this thread to a different post thingy i will do now
 
Error
SQL query:

--
-- Dumping data for table `lottery_system`
--
INSERT INTO `lottery_system` ( `id` , `player_id` , `date` , `item_id` , `item_name` )
VALUES ( 3, 205, 1327460833, ITEM ID, 'NAME' ) , ( 4, 217, 1327486033, ITEM ID, 'NAME' ) , ( 5, 266, 1327511233, ITEM ID, 'NAME' ) , ( 6, 236, 1327571565, ITEM ID, 'NAME' ) , ( 7, 180, 1327596765, ITEM ID, 'NAME' ) , ( 8, 403, 1327681153, ITEM ID, 'NAME' ) ;


MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ID, 'NAME'),
(4, 217, 1327486033, ITEM ID, 'NAME'),
(5, 266, 1327511233, ITEM ' at line 6


Getting this error please help when creating table help rep++
 
you can't use syntax " ' ". You need use syntax: " ` ".

or

check your file error (you don't close syntax)

to use near 'ID, 'NAME'),

look you need close 'ID', 'NAME'
you have 'ID, 'NAME
 
[09/05/2014 21:28:26] Reward: crystal coin
[09/05/2014 21:28:26] Next lottery in 0.0016666666666667 minutes.".
[09/05/2014 21:28:26] mysql_real_query(): INSERT INTO `lottery_system`(`player_id`, `date`, `item_id`, `item_name`) VALUES ( 4, 1399663706, 2160, 'crystal coin'); - MYSQL ERROR: Table 'ots.lottery_system' doesn't exist (1146)
why?:/
 
Back
Top