View Full Version : [Trinity] Lottery System

11-20-2013, 09:54 PM
Hello everyone,

I'm going to release a lottery system. I don't know who made it, I have had the system for a long time now. So I updated it and made it a bit better.

Information about the script -

This is a simple script but can come in handy to offer anther event / service on your server. This system is not a automatic system yet, all it does is execute the character name into a custom database table.

For the time being you will have to pick the winners by hand, but you can use a random name picker or something along those lines. I'm trying to figure out a way to pick winners automatic, but not having the best luck at the moment.

Custom script: Lottery System - pastebin (http://pastebin.com/eFhdGZpZ)
Custom database table:

CREATE TABLE `game_lotto` (
`entry` TEXT NULL,
`comment` TEXT NULL

Best regards,

11-20-2013, 10:11 PM
Cleaned your script up. Watch your indentation and switch statements. Don't really need a switch statement considering there's only one menu to go to, you also don't have to use open/close ({ }) brackets when you're only calling one thing in an if statement. One more thing, the include isn't needed as well as the enumerator.

Other than that, nice script. Thanks.

- Made by: ??
- Developer(s): Ghostcrawler336
- Complete: %100
- ScriptName: 'Lotto system'
- Comment: N/A

class npc_lotto : public CreatureScript
npc_lotto() : CreatureScript("npc_lotto") { }

bool OnGossipHello(Player* player, Creature* creature)
if (player->HasItemCount(200800, 1, false))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Test your luck in the lottery this week.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
creature->MonsterWhisper("You don't have enough Lottery Tickets", player->GetGUID());

player->PlayerTalkClass->SendGossipMenu(65002, creature->GetGUID());
return true;

bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)

if (action == GOSSIP_ACTION_INFO_DEF+1)
creature->MonsterWhisper("Greetings competitor! Thank you for purchasing your Lottery ticket, we give out prizes every Monday. Prizes change every week!", player->GetGUID());
WorldDatabase.PExecute("INSERT INTO game_lotto (entry, comment) values ('%s',0)", player->GetName().c_str());
player->DestroyItemCount(200800, 1, true, false);
return true;

void AddSC_npc_lotto()
new npc_lotto();

11-20-2013, 10:14 PM
Thank you cleaning up the script for me, and thank you for those tips!

11-23-2013, 09:03 AM
Good work Ghost !

11-23-2013, 07:40 PM
i have an ideea on how to pick a random name

use an enum for all names in database

enum Participants
here must be an increment for taking the names from database

and right after call it like this

int random= urand(0,n-1);
Player->GetPlayerByID(Participants[random]); or something like this

n-1 will be the number of participants from your database table -1

12-15-2013, 07:14 PM
Nice Lottery game :D