Hide/show cloak/helm via OnPlayerChat
NeverwinterWights
Member Posts: 339
Just figured I'd share what I've done with my OnPlayerChat event to hide or show cloaks and helms simply by typing it. "/hide helm", "/show helm", "/hide cloak", "/show cloak". I also took into account a variable stored on the item that prevents it from being shown or hidden. If it helps anyone, awesome. If not, no harm done.
else if (sSaid == "/hide helm")
{
object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oSpeaker);
if (!GetIsObjectValid(oHelm))
SendMessageToPC(oSpeaker, "You do not have a head item equipped.");
else if (GetLocalInt(oHelm, "NO_HIDE"))
SendMessageToPC(oSpeaker, "This item can not be hidden.");
else if(!GetHiddenWhenEquipped(oHelm))
SetHiddenWhenEquipped(oHelm, TRUE);
else
SendMessageToPC(oSpeaker, "This item is already hidden.");
SetPCChatMessage("");
}
else if (sSaid == "/show helm")
{
object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oSpeaker);
if (!GetIsObjectValid(oHelm))
SendMessageToPC(oSpeaker, "You do not have a head item equipped.");
else if (GetLocalInt(oHelm, "HIDDEN"))
SendMessageToPC(oSpeaker, "This item can not be shown.");
else if (GetHiddenWhenEquipped(oHelm))
SetHiddenWhenEquipped(oHelm, FALSE);
else
SendMessageToPC(oSpeaker, "This item is already being shown.");
SetPCChatMessage("");
}
else if (sSaid == "/hide cloak")
{
object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK, oSpeaker);
if (!GetIsObjectValid(oCloak))
SendMessageToPC(oSpeaker, "You do not have a cloak item equipped.");
else if (GetLocalInt(oCloak, "NO_HIDE"))
SendMessageToPC(oSpeaker, "This item can not be hidden.");
else if(!GetHiddenWhenEquipped(oCloak))
SetHiddenWhenEquipped(oCloak, TRUE);
else
SendMessageToPC(oSpeaker, "This item is already hidden.");
SetPCChatMessage("");
}
else if (sSaid == "/show cloak")
{
object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK, oSpeaker);
if (!GetIsObjectValid(oCloak))
SendMessageToPC(oSpeaker, "You do not have a cloak item equipped.");
else if (GetLocalInt(oCloak, "HIDDEN"))
SendMessageToPC(oSpeaker, "This item can not be shown.");
else if (GetHiddenWhenEquipped(oCloak))
SetHiddenWhenEquipped(oCloak, FALSE);
else
SendMessageToPC(oSpeaker, "This item is already being shown.");
SetPCChatMessage("");
}
5
Comments
else if (sCommand == "hidehelm")
{
object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
if (!GetIsObjectValid(oHelm))
{
SendMessageToPC(oPC, "You do not have a head item equipped.");
}
else if (GetLocalInt(oHelm, "NO_HIDE"))
{
SendMessageToPC(oPC, "This item can not be hidden.");
}
else if(!GetHiddenWhenEquipped(oHelm))
{
SetHiddenWhenEquipped(oHelm, TRUE);
}
else
{
SendMessageToPC(oPC, "This item is already hidden.");
}
return;
}
else if (sCommand == "showhelm")
{
object oHelm = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
if (!GetIsObjectValid(oHelm))
{
SendMessageToPC(oPC, "You do not have a head item equipped.");
}
else if (GetLocalInt(oHelm, "HIDDEN"))
{
SendMessageToPC(oPC, "This item can not be shown.");
}
else if (GetHiddenWhenEquipped(oHelm))
{
SetHiddenWhenEquipped(oHelm, FALSE);
}
else
{
SendMessageToPC(oPC, "This item is already being shown.");
}
return;
}
else if (sCommand == "hidecloak")
{
object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC);
if (!GetIsObjectValid(oCloak))
{
SendMessageToPC(oPC, "You do not have a cloak item equipped.");
}
else if (GetLocalInt(oCloak, "NO_HIDE"))
{
SendMessageToPC(oPC, "This item can not be hidden.");
}
else if(!GetHiddenWhenEquipped(oCloak))
{
SetHiddenWhenEquipped(oCloak, TRUE);
}
else
{
SendMessageToPC(oPC, "This item is already hidden.");
}
return;
}
else if (sCommand == "showcloak")
{
object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC);
if (!GetIsObjectValid(oCloak))
{
SendMessageToPC(oPC, "You do not have a cloak item equipped.");
}
else if (GetLocalInt(oCloak, "HIDDEN"))
{
SendMessageToPC(oPC, "This item can not be shown.");
}
else if (GetHiddenWhenEquipped(oCloak))
{
SetHiddenWhenEquipped(oCloak, FALSE);
}
else
{
SendMessageToPC(oPC, "This item is already being shown.");
}
return;
}
else if (sCommand == "/hide" || sCommand == "/show" || sCommand == "/rename") { string sBreak = StringRemoveParsed(sSaid, sCommand, " "); string sSlot = StringParse(sBreak, " "); string sName = StringRemoveParsed(sBreak, sSlot, " "); int iSlot = -1; if (sSlot == "head" || sSlot == "helm") iSlot = INVENTORY_SLOT_HEAD; if (sSlot == "cloak" || sSlot == "cape") iSlot = INVENTORY_SLOT_CLOAK; if (sSlot == "ring1" || sSlot == "rightring") iSlot = INVENTORY_SLOT_RIGHTRING; if (sSlot == "ring2" || sSlot == "leftring") iSlot = INVENTORY_SLOT_LEFTRING; if (sSlot == "boots") iSlot = INVENTORY_SLOT_BOOTS; if (sSlot == "belt") iSlot = INVENTORY_SLOT_BELT; if (sSlot == "righthand" || sSlot == "mainhand") iSlot = INVENTORY_SLOT_RIGHTHAND; if (sSlot == "lefthand" || sSlot == "offhand") iSlot = INVENTORY_SLOT_LEFTHAND; if (sSlot == "chest" || sSlot == "armor" || sSlot == "robes") iSlot = INVENTORY_SLOT_CHEST; if (sSlot == "arms" || sSlot == "gloves" || sSlot == "bracers") iSlot = INVENTORY_SLOT_ARMS; if (sSlot == "neck" || sSlot == "necklace") iSlot = INVENTORY_SLOT_NECK; if (sSlot == "bullets") iSlot = INVENTORY_SLOT_BULLETS; if (sSlot == "arrows") iSlot = INVENTORY_SLOT_ARROWS; if (sSlot == "bolts") iSlot = INVENTORY_SLOT_BOLTS; if (iSlot > -1) { object oItem = GetItemInSlot(iSlot, oSpeaker); if (GetIsObjectValid(oItem)) { if (sCommand == "/hide") { if (GetLocalInt(oItem, "NO_HIDE")) { SendMessageToPC(oSpeaker, "This item can not be hidden."); } else { if (!GetHiddenWhenEquipped(oItem)) SetHiddenWhenEquipped(oItem, TRUE); else SendMessageToPC(oSpeaker, "This item is already hidden."); } } if (sCommand == "/show") { if (GetLocalInt(oItem, "NO_SHOW")) { SendMessageToPC(oSpeaker, "This item can not be shown."); } else { if (GetHiddenWhenEquipped(oItem)) SetHiddenWhenEquipped(oItem, FALSE); else SendMessageToPC(oSpeaker, "This item is already shown."); } } if (sCommand == "/rename") { if (sName != "") { SetName(oItem, sName); SendMessageToPC(oSpeaker, "Your item has been renamed."); } else { SendMessageToPC(oSpeaker, "You didn't type anything to name your item."); } } } else { SendMessageToPC(oSpeaker, "There is no item in that slot."); } } else { SendMessageToPC(oSpeaker, "That is not a valid item slot for items that can be hidden or shown."); } }
"Show my helmet"
"Hide my helmet"
"Show my cloak"
"Hide my cloak"