I have a scriptline:
GetInvName(i,buffer) in a loop.
It is obsolete but by what code can I replace it?
InventoryItem.name cannot work, but what then???
function geefterug(String inv_item){
Ã,Â
Ã, int i ;
Ã, String buffer;
Ã,Â
Ã, i=1;
Ã, buffer = "NONE";
Ã,Â
Ã, while (i<14){Ã, // do loop until inv item is returned or all inv_item slots (until 13) are checked
Ã, Ã, Ã, Ã,Â
GetInvName(i,buffer);Ã, Ã, Ã, Ã, Ã, // check if it has the correct name
Ã, Ã, Ã, Ã, Ã, if (StrComp(inv_item,buffer)==0) {Ã, Ã, Ã, Ã, //if so:
Ã, Ã, Ã, Ã, Ã, Ã, if (character[EGO].inv[i] == 0){Ã, Ã, //and if EGO does not already carry this inv_item
AddInventory(i); //add inv item
return i; //output inv_numer returned
i=14;Ã, Ã, Ã, Ã, Ã, //stops while loop
Ã, Ã, }
}
Ã, i++;
Ã, }
}
It's inventory.Name
What version are you using? You've mixed up the new String type and usage (buffer = "NONE";) and the old string stuff (StrComp(inv_item, buffer)).
For V2.71 it would be something like:
function geefterug(String inv_item){
int i = 1 ;
while (i<14){ // do loop until inv item is returned or all inv_item slots (until 13) are checked
if (inventory[i].Name == inv_item && cEgo.InventoryQuantity[i] == 0){
cEgo.AddInventory(inventory[i]);
return i; // 'return' should end the while loop, no need for 'i = 14'
}
i ++
}
return 0; // No matching item name found
}
For V2.7, you'll need to use inventory.GetName(buffer) (which should be linked in the manual, if you look up GetInvName()) and the Character.InventoryQuantity property instead of character.inv, but it's otherwise pretty much as you've got it.