- /*
- Used variables, set up as you like.
- Thank you, Rochet.
- */
- SET
- @ENTRY = 120000,
- @NAME = "Honorable Kills",
- @SUBNAME = "",
- @MODEL = 21572,
- @TEXT_ID = 40000;
- -- Delete existing data
- DELETE FROM world.creature_template WHERE entry = @ENTRY ;
- DELETE FROM world.npc_text WHERE ID BETWEEN @TEXT_ID AND @TEXT_ID+2;
- DELETE FROM world.gossip_menu WHERE entry BETWEEN 41000 AND 41002;
- DELETE FROM world.gossip_menu_option WHERE menu_id BETWEEN 41000 AND 41002;
- -- Creature
- INSERT INTO world.creature_template (entry, modelid1, NAME, subname, IconName, gossip_menu_id, minlevel, maxlevel, faction, npcflag, speed_walk, speed_run, scale, rank, unit_class, unit_flags, TYPE, type_flags, InhabitType, RegenHealth, flags_extra, AiName) VALUES
- (@ENTRY, @MODEL, @NAME, @SUBNAME, "Directions", 41000, 71, 71, 35, 3, 1, 1.14286, 1.25, 1, 1, 2, 7, 138936390, 3, 1, 2, "");
- -- Link text to gossip menu.
- INSERT INTO world.gossip_menu (entry, text_id) VALUES
- (41000, @TEXT_ID),
- (41001, @TEXT_ID+1),
- (41002, @TEXT_ID+2);
- -- Add the text'.
- INSERT INTO world.npc_text (ID, text0_0, em0_1) VALUES
- (@TEXT_ID, "Greetings.", 0),
- (@TEXT_ID+1, "Top kills all time.", 0),
- (@TEXT_ID+2, "Top kills today.", 0);
- -- Add the menu.
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text) VALUES
- (41000, 1, 0, 'Top kills', 1, 1, 41001, 0, 0, 0, NULL),
- (41000, 2, 0, 'Top kills today', 1, 1, 41002, 0, 0, 0, NULL);
- -- Populate lifetime kills with already existing data
- SET @id = 0;
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text)
- SELECT 41001, @id:=@id+1, 0, CONCAT(NAME, ' - lifetime kills: ', totalkills), 1, 1, 0, 0, 0, 0, NULL
- FROM characters.Characters AS C
- ORDER BY totalKills DESC
- LIMIT 30;
- -- Add a back button
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text) VALUES
- (41001, @id+1, 0, '[Back]', 1, 1, 41000, 0, 0, 0, NULL);
- -- Populate today kills with the already exiting data
- SET @id = 0;
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text)
- SELECT 41002, @id:=@id+1, 0, CONCAT(NAME, ' - today kills: ', todaykills), 1, 1, 0, 0, 0, 0, NULL
- FROM characters.Characters AS C
- ORDER BY todaykills DESC
- LIMIT 30;
- -- Add a back button
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text) VALUES
- (41002, @id+1, 0, '[Back]', 1, 1, 41000, 0, 0, 0, NULL);
- -- Change delimiter, so we can use ';' in the trigger.
- DELIMITER //
- -- Trigger that will update the todaykills/totalkill whenever
- -- a character kill is updated.
- DROP TRIGGER IF EXISTS characters.tr_update_kills//
- CREATE TRIGGER characters.tr_update_kills
- AFTER UPDATE
- ON characters.Characters
- FOR EACH ROW
- BEGIN
- IF NEW.todaykills <> OLD.todaykills THEN
- DELETE FROM world.gossip_menu_option
- WHERE menu_id = 41002;
- SET @id = 0;
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text)
- SELECT 41002, @id:=@id+1, 0, CONCAT(NAME, ' - today kills: ', todaykills), 1, 1, 0, 0, 0, 0, NULL
- FROM characters.Characters AS C
- ORDER BY todaykills DESC
- LIMIT 30;
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text) VALUES
- (41002, @id+1, 0, '[Back]', 1, 1, 41000, 0, 0, 0, NULL);
- END IF;
- IF NEW.totalkills <> OLD.totalkills THEN
- DELETE FROM world.gossip_menu_option
- WHERE menu_id = 41001;
- SET @id = 0;
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text)
- SELECT 41001, @id:=@id+1, 0, CONCAT(NAME, ' - lifetime kills: ', totalkills), 1, 1, 0, 0, 0, 0, NULL
- FROM characters.Characters AS C
- ORDER BY totalKills DESC
- LIMIT 30;
- INSERT INTO world.gossip_menu_option (menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text) VALUES
- (41001, @id+1, 0, '[Back]', 1, 1, 41000, 0, 0, 0, NULL);
- END IF;
- END//
- DELIMITER ;