• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[Trinity] Lottery System

Ghostcrawler336

Epic Member
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
Custom database table:
Code:
CREATE TABLE `game_lotto` (
	`entry` TEXT NULL,
	`comment` TEXT NULL
)

Best regards,
Ghostcrawler336.
 

Tommy

Founder
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.

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

class npc_lotto : public CreatureScript
{
public:
    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);
        else
            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)
    {
        player->PlayerTalkClass->ClearMenus();
        player->CLOSE_GOSSIP_MENU();

        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();
}
 
Last edited:

darksoke

OnTop500
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
 
Top