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

Solved Can't attack with an specific item if i don't have an storage value

Joined
Jul 18, 2014
Messages
193
Solutions
2
Reaction score
15
Hi, i want to know how can i make a script when a player tries to attack to another player, be impossible if he doesnt have an specific storage with value 1.
Example:
I found a sword (ID: 24098) but i cant attack players with it because i dont have the storage (456091) with value 1.

I know this is possible with creaturescripts but i dont know how.
IT'S FOR TFS 1.2

Please help.
Thanks :)
 
you want to be able to hit with weapon but damage will be 0? (creaturescripts folder)
you don't want it to be able to attack with the weapon in first place? (weapons folder)
you don't want it to be able to equipped in first place? (movements folder)
 
you want to be able to hit with weapon but damage will be 0? (creaturescripts folder)
you don't want it to be able to attack with the weapon in first place? (weapons folder)
you don't want it to be able to equipped in first place? (movements folder)
If a player has equipped that weapon and he doesnt have the storage 456091 with value 1, he cant attack.
 
That can be easily achived with:
Code:
Creature:onTargetCombat(target)
Yup! yesterday i saw it and works perfectly, but the problem is, he cant attack with another items and i want that the player can attack with another weapons but not with the item i want.
I did this:
Code:
if self:isPlayer() and target:isPlayer() then
        if self:getStorageValue(456001) >= 1 then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end
I thought this can be possible with some function who talks about an equipped item, but i dont know.
 
Yup! yesterday i saw it and works perfectly, but the problem is, he cant attack with another items and i want that the player can attack with another weapons but not with the item i want.
I did this:
Code:
if self:isPlayer() and target:isPlayer() then
        if self:getStorageValue(456001) >= 1 then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end
I thought this can be possible with some function who talks about an equipped item, but i dont know.
Code:
if (self:getSlotItem(CONST_SLOT_RIGHT):getId() == 24098 or self:getSlotItem(CONST_SLOT_LEFT):getId() == 24098) and self:getStorageValue(456001) >= 1 then
You never actually checked what the player's weapon was, hence not being able to attack with any weapon.
 
Code:
if (self:getSlotItem(CONST_SLOT_RIGHT):getId() == 24098 or self:getSlotItem(CONST_SLOT_LEFT):getId() == 24098) and self:getStorageValue(456001) >= 1 then
You never actually checked what the player's weapon was, hence not being able to attack with any weapon.
That's the function that i want! Thanks dude! :)
 
Code:
if (self:getSlotItem(CONST_SLOT_RIGHT):getId() == 24098 or self:getSlotItem(CONST_SLOT_LEFT):getId() == 24098) and self:getStorageValue(456001) >= 1 then
You never actually checked what the player's weapon was, hence not being able to attack with any weapon.
I recently tested this but in console appears: attempt to index a nil value :/
 
Back
Top