• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Subtype Unknown

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
C++:
const std::string& itemName = items[subType].name;
s << " of " << (!itemName.empty() ? itemName : "unknown");

this function is not declaring the correct subtype, and is returning the string "unknown"...
when the item is fluidcontainer instead of having the fluid name is returning unknown...
where is subtype name declared?
Ex. 1 - water, 2 - other string

Thank you very much in advance

TFS 1.3
 
items is a vector of all item types, which means you're only able to access them with the corresponding item id
for example:
C++:
const ItemType& it = items[2160]; // crystal coin id = 2160
std::cout << it.name << std::endl // crystal coin
if subType is a number like 1 or 2 then of course it won't work, because you need to access it by item id
what you could do is use a switch statement to give each subtype a different name
C++:
std::string itemName;
switch (subType) {
    case 1: {
        itemName = "water";
        break;
    }
    case 2: {
        itemName = "other string";
        break;
    }
}
 
items is a vector of all item types, which means you're only able to access them with the corresponding item id
for example:
C++:
const ItemType& it = items[2160]; // crystal coin id = 2160
std::cout << it.name << std::endl // crystal coin
if subType is a number like 1 or 2 then of course it won't work, because you need to access it by item id
what you could do is use a switch statement to give each subtype a different name
C++:
std::string itemName;
switch (subType) {
    case 1: {
        itemName = "water";
        break;
    }
    case 2: {
        itemName = "other string";
        break;
    }
}
very explanatory !! in this case below, how would I identify this item, and identify each subtype of it with a name?
the vial example, where in the sources should I insert this switch? Does const.h no longer have this description for each subtype?
C++:
std::string itemName;
switch (subType) {
    case 1: {
        itemName = "water";
        break;
    }
    case 2: {
        itemName = "other string";
        break;
    }
}
 
i have no idea where you'd put it because you never provided where or what you were using this for, i just simply provided that as an example to replace your code
each subtype has to be a separate case
if you're trying to identify an actual item then you need it's id or name, otherwise that's how you set a different name for certain subtypes
if you're using vials you might want to look at FluidTypes_t and use those in the switch statement instead
for example:
C++:
std::string itemName;
switch (fluid) {
    case FLUID_WATER:
        itemName = "water";
        break;
    case FLUID_BLOOD:
        itemName = "blood";
        break;
}
 
i have no idea where you'd put it because you never provided where or what you were using this for, i just simply provided that as an example to replace your code
each subtype has to be a separate case
if you're trying to identify an actual item then you need it's id or name, otherwise that's how you set a different name for certain subtypes
if you're using vials you might want to look at FluidTypes_t and use those in the switch statement instead
for example:
C++:
std::string itemName;
switch (fluid) {
    case FLUID_WATER:
        itemName = "water";
        break;
    case FLUID_BLOOD:
        itemName = "blood";
        break;
}
exactly, I'm using the vials system, so I use the vial system!
this piece of code was taken from item.cpp, and is not able to pull the subtype name
Where do I add this switch?

item.cpp
nkeh9 - Ghostbin
 
Last edited:
u need put in items.xml kkkkk

<item id="30001" name="water" />
<item id="30002" name="blood" />
<item id="30003" name="beer" />
<item id="30004" name="slime" />
<item id="30005" name="lemonade" />
<item id="30006" name="milk" />
<item id="30007" name="manafluid" />
<item id="30010" name="lifefluid" />
<item id="30011" name="oil" />
<item id="30013" name="urine" />
<item id="30014" name="coconut milk" />
<item id="30015" name="wine" />
<item id="30019" name="mud" />
<item id="30021" name="fruit juice" />
<item id="30026" name="lava" />
<item id="30027" name="rum" />
<item id="30028" name="swamp" />
<item id="30035" name="tea" />
<item id="30043" name="mead" />

fedor de lixo!
 
u need put in items.xml kkkkk

<item id="30001" name="water" />
<item id="30002" name="blood" />
<item id="30003" name="beer" />
<item id="30004" name="slime" />
<item id="30005" name="lemonade" />
<item id="30006" name="milk" />
<item id="30007" name="manafluid" />
<item id="30010" name="lifefluid" />
<item id="30011" name="oil" />
<item id="30013" name="urine" />
<item id="30014" name="coconut milk" />
<item id="30015" name="wine" />
<item id="30019" name="mud" />
<item id="30021" name="fruit juice" />
<item id="30026" name="lava" />
<item id="30027" name="rum" />
<item id="30028" name="swamp" />
<item id="30035" name="tea" />
<item id="30043" name="mead" />

fedor de lixo!

¿? I do not need to add anything in items.xml, are you retarded? It's the second time you come on a topic that I'm to, to talk shit (do you know how to cod something my friend?). Even so, I've solved the problem by looking at the example above of our friend Static_
 
¿? I do not need to add anything in items.xml, are you retarded? It's the second time you come on a topic that I'm to, to talk shit (do you know how to cod something my friend?). Even so, I've solved the problem by looking at the example above of our friend Static_
put this and test! don't talk shit mai friendi!
 
Last edited:
C++:
const std::string& itemName = items[subType].name;
s << " of " << (!itemName.empty() ? itemName : "unknown");

this function is not declaring the correct subtype, and is returning the string "unknown"...
when the item is fluidcontainer instead of having the fluid name is returning unknown...
where is subtype name declared?
Ex. 1 - water, 2 - other string

Thank you very much in advance

TFS 1.3


if u have in items.xml more or 30000 ids, u need make this changes:
in items.xml replace this:
<item id="30001" name="water" />
<item id="30002" name="blood" />
<item id="30003" name="beer" />
<item id="30004" name="slime" />
<item id="30005" name="lemonade" />
<item id="30006" name="milk" />
<item id="30007" name="manafluid" />
<item id="30010" name="lifefluid" />
<item id="30011" name="oil" />
<item id="30013" name="urine" />
<item id="30014" name="coconut milk" />
<item id="30015" name="wine" />
<item id="30019" name="mud" />
<item id="30021" name="fruit juice" />
<item id="30026" name="lava" />
<item id="30027" name="rum" />
<item id="30028" name="swamp" />
<item id="30035" name="tea" />
<item id="30043" name="mead" />

for this:

<item id="40001" name="water" />
<item id="40002" name="blood" />
<item id="40003" name="beer" />
<item id="40004" name="slime" />
<item id="40005" name="lemonade" />
<item id="40006" name="milk" />
<item id="40007" name="manafluid" />
<item id="40010" name="lifefluid" />
<item id="40011" name="oil" />
<item id="40013" name="urine" />
<item id="40014" name="coconut milk" />
<item id="40015" name="wine" />
<item id="40019" name="mud" />
<item id="40021" name="fruit juice" />
<item id="40026" name="lava" />
<item id="40027" name="rum" />
<item id="40028" name="swamp" />
<item id="40035" name="tea" />
<item id="40043" name="mead" />

in items.cpp replace this:
items.reserve(30000);
nameToItems.reserve(30000);

for this:
items.reserve(40000);
nameToItems.reserve(40000);

and this:
if (serverId > 30000 && serverId < 30100) {
serverId -= 30000;

for this:
if (serverId > 40000 && serverId < 40100) {
serverId -= 40000;


and this :
if (id > 30000 && id < 30100) {
id -= 30000;


for this:
if (id > 40000 && id < 40100) {
id -= 40000;

credits for @mattyx14

have a nice day!
 
in fact, you do not need all this code to solve just a little problem ... I solved this problem, and I did not expect anyone to comment here again ...
 
in fact, you do not need all this code to solve just a little problem ... I solved this problem, and I did not expect anyone to comment here again ...

So mark the best awnser, please my friend.. the strange thing is that we used the code for months and never gave this bug, but that's okay, its fixed now. o_O
 
So mark the best awnser, please my friend.. the strange thing is that we used the code for months and never gave this bug, but that's okay, its fixed now. o_O
in fact, you do not need all this code to solve just a little problem ... I solved this problem, and I did not expect anyone to comment here again ...

Would any of you mind sharing how you fixed this issue? After searching all over the .xml's, libs and going all the way into dat/otb, I've come stuck at that same line of code in the source.
 
Back
Top