I'm modifying a script - this script gives xp and gold to party members no matter who has the item:
#include "nw_i0_tool"
#include "X0_I0_PARTYWIDE"
void main()
{
object oItem = GetFirstItemInInventory(GetPCSpeaker());
while (GetIsObjectValid(oItem) == TRUE)
{
string sTag = GetTag(oItem);
int sNum = GetNumStackedItems(oItem);
if (sTag == "JS_SeaFleaCara" && GetHitDice(GetPCSpeaker()) < 20)
{
DestroyObject(oItem);
GiveGoldToAll(GetPCSpeaker(), (10*sNum));
GiveXPToAll(GetPCSpeaker(), (10*sNum));
}
if (sTag == "JS_SeaFleaCara" && GetHitDice(GetPCSpeaker()) >= 20)
{
DestroyObject(oItem);
GiveGoldToAll(GetPCSpeaker(), (3*sNum));
GiveXPToAll(GetPCSpeaker(), (3*sNum));
}
oItem = GetNextItemInInventory(GetPCSpeaker());
}
}
My problem is that this gives party xp across the server. What's the proper scripting to award only for party members in the area the award is being given to?
XP and Gold only for party members in area
Débuté par
Badwater
, janv. 05 2012 10:34
#1
Posté 05 janvier 2012 - 10:34
#2
Posté 05 janvier 2012 - 01:51
I would do it differently, getting a count of all the items first, and then awarding the XP and gold in a lump sum at the end. Otherwise, you have to loop through every party member and check area each time. I would use something along this line for it:
void main()
{
object oPC = GetPCSpeaker();
object oArea = GetArea (oPC);
object oTarget, oItem;
int sNum;
oItem = GetFirstItemInInventory (oPC);
while (GetIsObjectValid(oItem))
{
if (GetTag (oItem) == "JS_SeaFleaCara")
{
sNum += GetNumStackedItems (oItem);
DestroyObject(oItem);
}
oItem = GetNextItemInInventory (oPC);
}
// Adjust the count based on the level determined modifier.
if (GetHitDice (oPC) < 20) sNum *= 10;
else sNum *= 3;
oTarget = GetFirstFactionMember (oPC);
while (GetIsObjectValid(oTarget))
{
// Checks area to ensure only PCs in that area get the award.
if (GetArea (oTarget) == oArea)
{
GiveGoldToCreature (oTarget, sNum);
GiveXPToCreature (oTarget, sNum);
}
oTarget = GetNextFactionMember (oPC);
}
}
void main()
{
object oPC = GetPCSpeaker();
object oArea = GetArea (oPC);
object oTarget, oItem;
int sNum;
oItem = GetFirstItemInInventory (oPC);
while (GetIsObjectValid(oItem))
{
if (GetTag (oItem) == "JS_SeaFleaCara")
{
sNum += GetNumStackedItems (oItem);
DestroyObject(oItem);
}
oItem = GetNextItemInInventory (oPC);
}
// Adjust the count based on the level determined modifier.
if (GetHitDice (oPC) < 20) sNum *= 10;
else sNum *= 3;
oTarget = GetFirstFactionMember (oPC);
while (GetIsObjectValid(oTarget))
{
// Checks area to ensure only PCs in that area get the award.
if (GetArea (oTarget) == oArea)
{
GiveGoldToCreature (oTarget, sNum);
GiveXPToCreature (oTarget, sNum);
}
oTarget = GetNextFactionMember (oPC);
}
}
#3
Posté 05 janvier 2012 - 09:20
Thanks FB, works like a charm.





Retour en haut






