PDA

View Full Version : Honorable Kills Shop (script + NPC)



Wise
08-08-14, 10:43 PM
Hey guys. I just want to start with a little heads-up as a result from some of my other releases.. I am not a professional C++ coder, so I'm sure it can be done in a better way, but as far as it works, I'm happy about it and I'm just doing this to share what I can with you guys.
So, what does the script do? It checks if the player who's using it has (IN MY CASE - EDITABLE) 5,000 kills or more (also, editable!!), and if so - he can view the shop which you need to add ingame via .npc add item command, like any other vendor.

So, the creature for this script:

INSERT INTO `creature_template` (`entry`,`difficulty_entry_1`,`difficulty_entry_2` ,`difficulty_entry_3`,`KillCredit1`,`KillCredit2`, `modelid1`,`modelid2`,`modelid3`,`modelid4`,`name` ,`subname`,`IconName`,`gossip_menu_id`,`minlevel`, `maxlevel`,`exp`,`faction`,`npcflag`,`speed_walk`, `speed_run`,`scale`,`rank`,`mindmg`,`maxdmg`,`dmgs chool`,`attackpower`,`dmg_multiplier`,`baseattackt ime`,`rangeattacktime`,`unit_class`,`unit_flags`,` unit_flags2`,`dynamicflags`,`family`,`trainer_type `,`trainer_spell`,`trainer_class`,`trainer_race`,` minrangedmg`,`maxrangedmg`,`rangedattackpower`,`ty pe`,`type_flags`,`lootid`,`pickpocketloot`,`skinlo ot`,`resistance1`,`resistance2`,`resistance3`,`res istance4`,`resistance5`,`resistance6`,`spell1`,`sp ell2`,`spell3`,`spell4`,`spell5`,`spell6`,`spell7` ,`spell8`,`PetSpellDataId`,`VehicleId`,`mingold`,` maxgold`,`AIName`,`MovementType`,`InhabitType`,`Ho verHeight`,`Health_mod`,`Mana_mod`,`Armor_mod`,`Ra cialLeader`,`questItem1`,`questItem2`,`questItem3` ,`questItem4`,`questItem5`,`questItem6`,`movementI d`,`RegenHealth`,`mechanic_immune_mask`,`flags_ext ra`,`ScriptName`,`VerifiedBuild`) VALUES (151516, 0, 0, 0, 0, 0, 23445, 0, 0, 0, 'Name', 'Subname', '', 0, 80, 80, 0, 35, 129, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2000, 2000, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 'hk_kills_shop', 1);
Edit <SubName> if you wish. Also, feel free to change the displayID of the creature.


The script:

class honorable_kills_shop : public CreatureScript
{
public:
honorable_kills_shop() : CreatureScript("hk_kills_shop") { }

bool OnGossipHello(Player* player, Creature* creature)
{
player->ADD_GOSSIP_ITEM(4, "[5,000 Lifetime Kills are required in order to view my goods. Make sure you have it, or you won't be able to view nor purchase anything.]", GOSSIP_SENDER_MAIN, 1001); //first menu option - a note for what this creature is
player->ADD_GOSSIP_ITEM(4, "[5k kills] Show me what you got!", GOSSIP_SENDER_MAIN, 1002); //second option, click to send to the vendor (if he has 5k kills)
player->SEND_GOSSIP_MENU(1, creature->GetGUID()); // This sends the menu to the player
return true;
}

bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*uiSender*/, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
///////////START ACTIONS//////////////////
case 1001:
player->CLOSE_GOSSIP_MENU();
break;


case 1002:
if (player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KIL LS) >= 5000)
{
player->GetSession()->SendListInventory(pCreature->GetGUID()), //send to the vendor himself. add items via .npc add item command
pCreature->MonsterWhisper("You have 5,000 kills or more, therefore you can view my goods.", player, true); //if the player has 5k kills, send this message when
}
else
{
player->MonsterWhisper("You do not have 5,000 kills or more, therefore I cannot allow you to check my store. Sorry.", player, true), player->CLOSE_GOSSIP_MENU(); //send this "error" message and close everything
}
break;
}
return true;
}
};

void AddSC_Honorable_Kills_Shop()
{
new honorable_kills_shop();
}
To modify it from 5000 LIFETIME kills to any other number, find the following line and modify 5000 to any number you want.
The following code also includes if you want the script the script to an exact number of kills, more kills than (..) or less kills than (..).
To make it exact, edit the ">=" to "==".
To make it more than (..), leave it as it is.
To make it less than (..), edit the ">=" to "<=".


if (player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KIL LS) >= 5000)
When you are done, just modify all the options and texts to the number you want it to be.



Update - sorry for the huge delay, but instead of several screenshots I made a video.

http://youtu.be/pTeXd-Yx9M8


Credits : Zeraax

Dr.Core
13-10-14, 05:23 PM
Respect =)

But here is a Fixxed Version =)


class honorable_kills_shop : public CreatureScript
{
public:
honorable_kills_shop() : CreatureScript("hk_kills_shop") { }


bool OnGossipHello(Player* player, Creature* creature)
{
player->ADD_GOSSIP_ITEM(4, "[500 Lifetime Kills are required in order to view my goods. Make sure you have it, or you won't be able to view nor purchase anything.]", GOSSIP_SENDER_MAIN, 1001); //first menu option - a note for what this creature is
player->ADD_GOSSIP_ITEM(4, "[500 Kills] Show me what you got!", GOSSIP_SENDER_MAIN, 1002); //second option, click to send to the vendor (if he has 500 Kills)
player->SEND_GOSSIP_MENU(1, creature->GetGUID()); // This sends the menu to the player
return true;
}


bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*uiSender*/, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
switch (action)
{
///////////START ACTIONS//////////////////
case 1001:
player->CLOSE_GOSSIP_MENU();
break;



case 1002:
if (player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KIL LS) >= 500)
{
player->GetSession()->SendListInventory(pCreature->GetGUID()), //send to the vendor himself. add items via .npc add item command
pCreature->Whisper("You have 500 kills or more, therefore you can view my goods.", LANG_UNIVERSAL, player, true); //if the player has 500 Kills, send this message when
}
else
{
pCreature->Whisper("You do not have 500 kills or more, therefore I cannot allow you to check my store. Sorry.", LANG_UNIVERSAL, player, true), player->CLOSE_GOSSIP_MENU(); //send this "error" message and close everything
}
break;
}
return true;
}
};


void AddSC_Honorable_Kills_Shop()
{
new honorable_kills_shop();
}