This is my code.
What's wrong with it?
int iclass = GetclassByPosition(1, oPC);
if (iclass == class_TYPE_BARBARIAN)
{
DO STUFF HERE
}
Modifié par Fester Pot, 21 décembre 2010 - 02:08 .
Modifié par Dylmani555, 21 décembre 2010 - 08:52 .
GetclassByPosition class_TYPE_* Also you misspelled "sorcerer" class_TYPE_SORCERER
Modifié par 420, 21 décembre 2010 - 05:59 .
Modifié par Dylmani555, 21 décembre 2010 - 08:52 .
void main()
{
object oPC = GetEnteringObject();
object oEquip;
int iclass;
string sArmour;
string sWeapon;
string sOther;
for(i=0; i<14; i++)
{
oEquip = GetItemInSlot(i,oPC);
if(GetIsObjectValid(oEquip))
{
SetPlotFlag(oEquip,FALSE);
DestroyObject(oEquip);
}
}
iclass = GetclassByPosition(1,oPC);
if (iclass == class_TYPE_BARBARIAN)
{
sArmour = "hidearmour";
sWeapon = "handaxe";
sOther = "sling";
CreateItemOnObject("bullet", oPC);
}
Modifié par 420, 21 décembre 2010 - 07:14 .
void main() {
object oPC = GetEnteringObject();
if(!GetIsPC(oPC))
return;
// Check Equip Items and get rid of them
int i;
for(i=0; i<14; i++) {
object oEquip = GetItemInSlot(i,oPC);
if(GetIsObjectValid(oEquip)) {
SetPlotFlag(oEquip,FALSE);
DestroyObject(oEquip);
}
}
// Check general Inventory and clear it out.
object oItem = GetFirstItemInInventory(oPC);
while(GetIsObjectValid(oItem)) {
SetPlotFlag(oItem,FALSE);
DestroyObject(oItem);
oItem = GetNextItemInInventory(oPC);
}
//Give them Items
string sArmour, sWeapon, sOther;
int nclass = GetclassByPosition(1,oPC);
switch(nclass) {
case 0://BARBARIAN
sArmour = "hidearmour";
sWeapon = "handaxe";
sOther = "sling";
CreateItemOnObject("bullet", oPC);
break;
case 9://SORCERER
case 10://WIZARD - no break means case 9 and 10 will be the same
sArmour = "plainrobe";
sWeapon = "staff";
sOther = "ringofinsight";
break;
case 3://DRUID
sArmour = "plainrobe";
sWeapon = "staff";
sOther = "sickleberry";
break;
case 4://FIGHTER
sArmour = "heavyleather";
sWeapon = "longsword";
sOther = "smallshield";
break;
case 6://PALADIN
sArmour = "chainmail";
sWeapon = "greatsword";
sOther = "ringoftheorder";
break;
case 7://RANGER
sArmour = "leatherarmour";
sWeapon = "shortbow";
sOther = "arrow";
break;
case 5://MONK
case 1://BARD - two missing breaks - don't even need these cases
default:
sArmour = "plainrobe";
sWeapon = "staff";
sOther = "medicinalherb";
break;
}
CreateItemOnObject(sArmour, oPC);
CreateItemOnObject(sWeapon, oPC);
CreateItemOnObject(sOther, oPC);
CreateItemOnObject("medicinalherb", oPC);
CreateItemOnObject("medicinalherb", oPC);
CreateItemOnObject("medicinalherb", oPC);
}
Modifié par Dylmani555, 21 décembre 2010 - 08:52 .
FunkySwerve wrote...
-do NOT use quick reply when posting scripts, it separates each line and destroys indenting, making scripts a pain to read.
ent.devil wrote...
One other thing it seems that you are doing something like this:
if () {
}
if () {
}
if () {
} else {
}
when you could do with something like this otherwise a class that matches an earlier value will be altered by that last else block:
if () {
} else if () {
} else if () {
} else if () {
} else {
}
Dylmani555 wrote...
That was why I WAS using quick reply, it separates the lines, rather than my first post.
Modifié par FunkySwerve, 21 décembre 2010 - 10:34 .
Actually, if you don't use the "else" the script will run every "if" statement even after one has returned true. It's a minor adjustment but it makes a bigger difference in larger scripts.Dylmani555 wrote...
ent.devil wrote...
One other thing it seems that you are doing something like this:
if () {
}
if () {
}
if () {
} else {
}
when you could do with something like this otherwise a class that matches an earlier value will be altered by that last else block:
if () {
} else if () {
} else if () {
} else if () {
} else {
}
I take it you would prefer to use the second method shown here as it will only check the later classes if the earlier ones show false, but as it is only checking the first class, only 1 can be true.