Sorry, I didn't put in the ==
if (sSay == "blue berry raven pie" || "peanut butter cake" || "caramel ripple covered apples" || "banana muffins" || "sweet tarts")
{
AssignCommand(OBJECT_SELF, SpeakString(sDontHave + sChat));
}
Additionally, you could just put all your food items in the last one and change == to !=.
if (sSay != "chicken broth" || "slice of bread" || "cheese" || "local fish" || "strongberry wine" || "dwarven stout ale" || "seven kingdom mead")
{
AssignCommand(OBJECT_SELF, SpeakString(sDontHave + sChat));
}
If you don't want to go this route, then go the route
Pstemarie suggested.
void main()
{
object oPC = GetPCSpeaker();
string sChat = GetLocalString(oPC, "LastSaid");
string sSay = GetStringLowerCase(sChat);
int nGP = GetGold(oPC);
string sNoCoins = GetLocalString(OBJECT_SELF, "NoCoins");
string sDontHave = GetLocalString(OBJECT_SELF, "DontHave");
/*Chicken Broth - 10 GP
Slice of Bread - 8 GP
Loaf of Bread - 25 GP
Cheese - 15 GP
Local Fish - 12 GP
*/
if (sSay == "chicken broth" && nGP >= 10)
{
CreateItemOnObject("ChickenBroth", oPC, 1);
TakeGoldFromCreature(10, oPC, TRUE);
return;
}
else if (sSay == "chicken broth" && nGP < 10)
{
AssignCommand(OBJECT_SELF, SpeakString(sNoCoins));
return;
}
else if (sSay == "slice of bread" && nGP >=
{
CreateItemOnObject("SliceOfBread", oPC, 1);
TakeGoldFromCreature(8, oPC, TRUE);
return;
}
else if (sSay == "slice of bread" && nGP <
{
AssignCommand(OBJECT_SELF, SpeakString(sNoCoins));
return;
}
else if (sSay == "cheese" && nGP >= 15)
{
CreateItemOnObject("Cheese", oPC, 1);
TakeGoldFromCreature(15, oPC, TRUE);
return;
}
else if (sSay == "cheese" && nGP < 15)
{
AssignCommand(OBJECT_SELF, SpeakString(sNoCoins));
return;
}
else if (sSay == "local fish" && nGP >= 12)
{
CreateItemOnObject("LocalFish", oPC, 1);
TakeGoldFromCreature(12, oPC, TRUE);
return;
}
/* Drinks
Strongberry Wine - 18 GP
Dwarven Stout Ale - 12 GP
Seven Kingdom Mead - 15 GP
*/
else if (sSay == "strongberry wine" && nGP >= 18)
{
CreateItemOnObject("StrongberryWine", oPC, 1);
TakeGoldFromCreature(18, oPC, TRUE);
return;
}
else if (sSay == "strongberry wine" && nGP < 18)
{
AssignCommand(OBJECT_SELF, SpeakString(sNoCoins));
return;
}
else if (sSay == "dwarven stout ale" && nGP >= 12)
{
CreateItemOnObject("DwarvenStoutAle", oPC, 1);
TakeGoldFromCreature(12, oPC, TRUE);
return;
}
else if (sSay == "dwarven stout ale" && nGP < 12)
{
AssignCommand(OBJECT_SELF, SpeakString(sNoCoins));
return;
}
else if (sSay == "seven kingdom mead" && nGP >= 15)
{
CreateItemOnObject("SevenKingdomMead", oPC, 1);
TakeGoldFromCreature(15, oPC, TRUE);
return;
}
else if (sSay == "seven kingdom mead" && nGP < 15)
{
AssignCommand(OBJECT_SELF, SpeakString(sNoCoins));
return;
}
else
{
AssignCommand(OBJECT_SELF, SpeakString(sDontHave + sChat));
}
}
Also, you have two checks for "cheese". One check <= 15 and the other <=12. I removed one in the above script.
FP!
Modifié par Fester Pot, 02 février 2014 - 07:43 .