PDA

View Full Version : [C++] Player Commands


Alex.
04-20-2009, 02:07 AM
This lets players type certain phrases and let them receive benefits from them. Don't forget to change the teleport locations. If you would like me to add a feature I'll gladly try.
Thanks
Alex.


Twingle.cpp
// "Twingle" System By Dr. Feelgood. Don't Ninja Leechers! Based of the idea of "FrozenEye" --- Made by Kelwing.
#include "StdAfx.h" /*Drfg*/
#include "Setup.h" /* Drfg */
#ifdef WIN32
#pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
#endif

#define FOOD_TY 22895 //Conjured Cinnamon Roll
#define COUNT_FOOD 20

static string pvp = "#pvp"; // Teleport to PvP Zone
static string mall = "#mall"; // Teleport to mall
static string buff = "#buffme"; // Buffs
static string help = "#help"; // Help Menu
static string command = "#commands"; // Shows Commands
static string foodz = "#poptart"; // Gives Food

void EventChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{




if (Message == foodz)
{
ItemPrototype* it = ItemPrototypeStorage.LookupEntry(FOOD_TY);
Item *item;
item = objmgr.CreateItem( FOOD_TY, pPlayer);
item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, ((COUNT_FOOD > it->MaxCount) ? it->MaxCount : COUNT_FOOD));
if(it->Bonding==ITEM_BIND_ON_PICKUP)
item->SoulBind();
if(!pPlayer->GetItemInterface()->AddItemToFreeSlot(item))
{
pPlayer->BroadcastMessage("No free slots were found in your inventory!");
delete item;
}
SlotResult *lr = pPlayer->GetItemInterface()->LastSearchResult();
pPlayer->GetSession()->SendItemPushResult(item,false,true,false,true,lr->ContainerSlot,lr->Slot,COUNT_FOOD);
}

if(Message == mall && pPlayer->CombatStatus.IsInCombat())

pPlayer->BroadcastMessage("Cannot teleport when in combat!");

else
{

if(Message == mall)
{

pPlayer->BroadcastMessage("You've been taken to the mall location!");
pPlayer->EventTeleport(map, x, y, z); // Change this
}
}

if(Message == pvp && pPlayer->CombatStatus.IsInCombat()){

pPlayer->BroadcastMessage("Cannot teleport when in combat!");
}
else
{
if(Message == pvp)
{

pPlayer->BroadcastMessage("CHANGE THIS");
pPlayer->EventTeleport(map, x, y, z);


}
}




if(Message == buff)
{

pPlayer->BroadcastMessage("Say hello to my little friend!");
pPlayer->CastSpell(pPlayer, 48161, true); // Fort
pPlayer->CastSpell(pPlayer, 48932, true); // Might
pPlayer->CastSpell(pPlayer, 48469, true); // Mark of Wild
pPlayer->CastSpell(pPlayer, 48936, true); // Wisdom
pPlayer->CastSpell(pPlayer, 42995, true); // Intell
}



if(Message == help){

pPlayer->BroadcastMessage("CHANGE ME"); // Add Name

}


if(Message == command){
pPlayer->BroadcastMessage("Commands currently operational:"); // Opening
pPlayer->BroadcastMessage("#pvp - Teleports you to the pvp location. #mall - teleports you to the mall. #buffme - Buffs you, duh. #help - for help. #poptart - Gives you food."); // Showing commands
}


}
void SetupTwingle(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &EventChat);
}

Setup.h



#ifndef DONATOR_TOOLS_SETUP_H
#define DONATOR_TOOLS_SETUP_H

void SetupTwingle(ScriptMgr * mgr);


#endif

Setup.cpp


#include "StdAfx.h"
#include "Setup.h"
#define SKIP_ALLOCATOR_SHARING 1
#include <ScriptSetup.h>

extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}

extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupTwingle(mgr);
}

#ifdef WIN32

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}

#endif

QQrofl
04-20-2009, 02:11 AM
Good job.

Terrorblade
04-20-2009, 02:15 AM
i've seen this before you basicly copied/pasted scripts together and just edited names + it looks like u took my food command script

Alex.
04-20-2009, 02:22 AM
I made this; I'm also Dr. Feelgood on another forums. Sorry to for the confusion.

swmr1991
04-20-2009, 02:30 AM
This really is his work. He based it off of my script which I posted on the ArcEmu forums. He only used mine as a reference, this is completely his work. Nice job Dr. Feelgood.

mattias9410
04-20-2009, 06:04 PM
this is myscript he has just remade it...

sorry if im wrong

ToXic_King
04-20-2009, 06:07 PM
this is myscript he has just remade it...

sorry if im wrong

you have any proof that is yours *cough* :o

QQrofl
04-20-2009, 07:55 PM
Okay, lets stick to the topic, please.

LanceDH
04-20-2009, 09:04 PM
pPlayer->BroadcastMessage("#home - Teleports to your starting zone. #pvp - Teleports you to the pvp location. #mall - teleports you to the mall. #buffme - Buffs you, duh. #help - for help. #poptart - Gives you food."); // Showing commands
I think you forgot to script that command

Alex.
04-20-2009, 09:34 PM
#home was a command very similar to #mall so I removed it, but forgot to remove it from #commands. Thanks for the reminder.

mattias9410
04-21-2009, 05:17 PM
you have any proof that is yours *cough* :o

no you just have to belive me

herculis
04-21-2009, 05:22 PM
well nice post man to bad the flamer's are getting to ya lol unless they got link's proving its there's then good work mate

slade1000
04-22-2009, 01:20 AM
he made it we used in on are server before it closed down

bloodshed2007
05-07-2009, 03:59 PM
hi

i just compiled this in my core but now i am unable to speak .. i can only type the commands