• 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!

Weapon attribute

Doomdice

The N00betarian
Joined
Jul 20, 2009
Messages
659
Reaction score
108
Location
Indiana
tfs 1.2 version i try makeing a script for movements so attribute will work which im confuse in my self where the heck i put it and is this script right?

Code:
function onEquip(cid, item, slot)
    if player:getSlotItem(CONST_SLOT_LEFT).itemid == 2376 then
    player:itemType:getAttack(25)
    player:getPosition():sendMagicEffect (CONST_ME_CAKE)
return true
end
 
I don't know what you're trying to do here, but you put the script in movements/scripts and movements.xml would be something like this:
Code:
<movevent event="Equip" itemid="2376" slot="hand" script="script.lua">

Code:
function onEquip(cid, item, slot)
if player:getSlotItem(CONST_SLOT_LEFT).itemid == 2376 then
'player' is undefined.

Code:
player:itemType:getAttack(25)
Player has no field called itemType, to call a method you're missing the parenthesis, besides Player doesn't have any method called itemType either. getAttack doesn't expect any arguments. It returns the attack value of an item, it doesn't change it.

Some relevant methods are ItemType:getAttack(), Item:getType(), Item:getAttribute(key), Item:setAttribute(key, value).
 
But onEquip is only to equip items, should look into events onMoveItem.

I would done something like this:

Code:
if fromPosition.x ~= CONTAINER_POSITION and toPosition.x == CONTAINER_POSITION then
    if item:getId() == 2376 then
        self:sendTextMessage(MESSAGE_INFO_DESCR, string.format("%s attack: %d.", item:getName(), item:getType():getAttack()))
        self:getPosition():sendMagicEffect(CONST_ME_CAKE)
    end
end
 
Last edited:
But onEquip is only to equip items, should look into events onMoveItem.

I would done something like this:

Code:
if toPosition.x == CONTAINER_POSITION then
    if item:getId() == 2376 then
        self:sendTextMessage(MESSAGE_INFO_DESCR, string.format("%s attack: %d.", item:getName(), item:getType():getAttack()))
    end
end


Do i need to do this ?

Code:
function onEquip(cid, item, slot)
if toPosition.x == CONTAINER_POSITION then
self:sendTextMessage(MESSAGE_INFO_DESCR, string.format("%s attack: %d.", item:getName(), item:getType():getAttack()))
else
player:getPosition():sendMagicEffect (CONST_ME_CAKE)
return true
end
 
Back
Top