local weapon = creature:getSlotItem(CONST_SLOT_LEFT).itemid
local it = ItemType(weapon)
local attack = it:getAttack()
Yeah, let me explain again. I know how to check an items attack but for some reason it is returning 0 as its value.
Edit: Well, turns out the problem was I was using userdata when calling the itemtype... I tired it again by calling the ItemType with the items id and it worked.
So the fix is: Dont use userdata to get an itemtype use the ID. Sadly, I knew this but didn't think about it.
Thats exactly what i posted. If you read carefully my code, means that im getting from and itemid. ItemType() returns the kind of item is it, weapon or whatever, you need an actual id which has attack.
true but your code could error because you don't check if the weapon exists before indexing itThats exactly what i posted. If you read carefully my code, means that im getting from and itemid. ItemType() returns the kind of item is it, weapon or whatever, you need an actual id which has attack.
local weapon = creature:getSlotItem(CONST_SLOT_LEFT)
if weapon then
local attack = weapon:getType():getAttack()
end
Stop arguing, there is really no point, the answer that is the best is already marked and its correct. Fix your attitude and let other be good too, because as far as I see in any of your post, you are seeing yourself as someone more than you really are.Yes, someone who understands the difference and the importance for each way something is done can see it easily.
There is no obvious reason sending an items userdata wouldn't work to construct the ItemType. Especially because other classes can be defined with userdata such as: Player, Npc, Creature, and Monster.
Just because you think it is obvious because you can see the immediate difference doesn't mean it is so for everyone. So again, the best answer should always be the one that explains the problem, reason, solution.
Stop arguing, there is really no point, the answer that is the best is already marked and its correct. Fix your attitude and let other be good too, because as far as I see in any of your post, you are seeing yourself as someone more than you really are.
And you showed your attitude once again in the end of your last post. What did I demonstrate? btw. Nice one „attacking users” XDI don't care which one is marked as best. It seems _Static and I have a different idea on which one should be marked as best. I am simply trying to understand his reasoning behind marking a post that leads to the right answer, but not an answer itself.
I am glad Aeronx posted because it probably would have taken me a bit more time to figure out (I assumed if i had something like that wrong there would be an error).
There is no argument here, I am simply wondering if he agrees that in most cases the answer that is descriptive would be better than just throwing code out.
I am not sure what attitude you are referring too but you might want to fix your house before judging another.
As a member of the support team I wouldn't recommend attacking forum users like that. Not that I am in any position to tell you how to compose yourself on a forum you have higher status on but if I owned a forum and one of the mods were to demonstrate what you just did I might rethink his adequacy as one of my forums representative.