Merth
06-09-2003, 03:26 AM
There's a custom command (#merthitem) on my server (Merth's Florida Server) for testing the visual appearance of an item. There's a thread about it in the EQEMu forum. This is the code for it, if you want something similar on your server.
Note 1: I don't know if this struct init syntax works on all compilers: MyStruct myStruct = {0};
Note 2: I created an item with id=1 in my database, so if a user's inventory is saved, we're somewhat safe.
client.cpp, under whatever section you want (It's in VeryPrivUser() on my server)
else if ((strcasecmp(sep->arg[0], "#merthitem") == 0)) {
// #merthitem: Allows user to create an item on the fly with a particular item
// visual look-and-feel just for testing visual appearance
if (sep->arg[1][0] == 0) {
Message(0, "Usage: #merthitem [model] [equiptype] [icon] [R G B]");
Message(1, "[model]: Use Kaiyodo's Model Viewer, model names up to first underscore (i.e., IT11001)");
Message(1, "[equipType]: 0-28");
Message(1, "[icon]: 500-1399");
Message(1, "[R G B]: 0-255, red/green/blue, 0=dark, 255=bright");
return true;
}
Item_Struct item = {0};
// Place new item on user's cursor
if(pp.inventory[0] != 0xFFFF && pp.inventory[0] != 0) {
Message(0, "Item currently on your cursor is being replaced by summoned Merth's Summoned Editing Item");
}
pp.inventory[0] = 0;
const int ALL_VISIBLE_SLOTS = 948100;
const int ALL_RACES = 32767;
const int ALL_CLASSES = 32767;
// Set basic item properties
strcpy(item.name, "Merth's Summoned Editing Item");
strcpy(item.lore, item.name);
item.equipableSlots = ALL_VISIBLE_SLOTS;
item.common.classes = ALL_CLASSES;
item.common.normal.races = ALL_RACES;
item.icon_nr = 1314; // default (shield of solusek)
item.item_nr = 1;
// Argument #1: item visual
char* model = 0;
if (sep->GetMaxArgNum() > 0) {
model = sep->arg[1];
}
int len = strlen(model);
if (len > 0) {
// Observed idfile is 30 bytes wide, not 6
if (len > 29) {
model[29] = '\0';
}
strcpy(item.idfile, model);
}
else
{
strcpy(item.idfile, "IT5"); // default model
}
// Argument #2: equiptype
if ((sep->GetMaxArgNum() > 1) && sep->IsNumber(2)) {
item.common.material = atoi(sep->arg[2]);
}
// Arguments #3: icon
if ((sep->GetMaxArgNum() > 2) && sep->IsNumber(3))
{
int icon_nr = atoi(sep->arg[3]);
const int MIN_ICON = 500;
const int MAX_ICON = 1399;
if ((icon_nr >= MIN_ICON) && (icon_nr <= MAX_ICON)) {
item.icon_nr = icon_nr;
}
else {
Message(0, "Invalid icon: using default 1314");
}
}
// Arguments #4-#6: RGB color triplet
if ((sep->GetMaxArgNum() > 5) && sep->IsNumber(4) && sep->IsNumber(5) && sep->IsNumber(6)) {
item.common.color = (atoi(sep->arg[4]) << 16) | (atoi(sep->arg[5]) << 8) | atoi(sep->arg[6]);
}
// Notify user
Message(0, "Temporary item summoned for visual testing");
// Send item out to player
APPLAYER* outapp = new APPLAYER(OP_SummonedItem, sizeof(SummonedItem_Struct));
memcpy(outapp->pBuffer, &item, sizeof(Item_Struct));
QueuePacket(outapp);
delete outapp;
found=true;
}
Note 1: I don't know if this struct init syntax works on all compilers: MyStruct myStruct = {0};
Note 2: I created an item with id=1 in my database, so if a user's inventory is saved, we're somewhat safe.
client.cpp, under whatever section you want (It's in VeryPrivUser() on my server)
else if ((strcasecmp(sep->arg[0], "#merthitem") == 0)) {
// #merthitem: Allows user to create an item on the fly with a particular item
// visual look-and-feel just for testing visual appearance
if (sep->arg[1][0] == 0) {
Message(0, "Usage: #merthitem [model] [equiptype] [icon] [R G B]");
Message(1, "[model]: Use Kaiyodo's Model Viewer, model names up to first underscore (i.e., IT11001)");
Message(1, "[equipType]: 0-28");
Message(1, "[icon]: 500-1399");
Message(1, "[R G B]: 0-255, red/green/blue, 0=dark, 255=bright");
return true;
}
Item_Struct item = {0};
// Place new item on user's cursor
if(pp.inventory[0] != 0xFFFF && pp.inventory[0] != 0) {
Message(0, "Item currently on your cursor is being replaced by summoned Merth's Summoned Editing Item");
}
pp.inventory[0] = 0;
const int ALL_VISIBLE_SLOTS = 948100;
const int ALL_RACES = 32767;
const int ALL_CLASSES = 32767;
// Set basic item properties
strcpy(item.name, "Merth's Summoned Editing Item");
strcpy(item.lore, item.name);
item.equipableSlots = ALL_VISIBLE_SLOTS;
item.common.classes = ALL_CLASSES;
item.common.normal.races = ALL_RACES;
item.icon_nr = 1314; // default (shield of solusek)
item.item_nr = 1;
// Argument #1: item visual
char* model = 0;
if (sep->GetMaxArgNum() > 0) {
model = sep->arg[1];
}
int len = strlen(model);
if (len > 0) {
// Observed idfile is 30 bytes wide, not 6
if (len > 29) {
model[29] = '\0';
}
strcpy(item.idfile, model);
}
else
{
strcpy(item.idfile, "IT5"); // default model
}
// Argument #2: equiptype
if ((sep->GetMaxArgNum() > 1) && sep->IsNumber(2)) {
item.common.material = atoi(sep->arg[2]);
}
// Arguments #3: icon
if ((sep->GetMaxArgNum() > 2) && sep->IsNumber(3))
{
int icon_nr = atoi(sep->arg[3]);
const int MIN_ICON = 500;
const int MAX_ICON = 1399;
if ((icon_nr >= MIN_ICON) && (icon_nr <= MAX_ICON)) {
item.icon_nr = icon_nr;
}
else {
Message(0, "Invalid icon: using default 1314");
}
}
// Arguments #4-#6: RGB color triplet
if ((sep->GetMaxArgNum() > 5) && sep->IsNumber(4) && sep->IsNumber(5) && sep->IsNumber(6)) {
item.common.color = (atoi(sep->arg[4]) << 16) | (atoi(sep->arg[5]) << 8) | atoi(sep->arg[6]);
}
// Notify user
Message(0, "Temporary item summoned for visual testing");
// Send item out to player
APPLAYER* outapp = new APPLAYER(OP_SummonedItem, sizeof(SummonedItem_Struct));
memcpy(outapp->pBuffer, &item, sizeof(Item_Struct));
QueuePacket(outapp);
delete outapp;
found=true;
}