player can only attack monster if it has storage

kalew

New Member
Joined
Mar 19, 2016
Messages
6
Best answers
0
Reaction score
1
I need a script or some source code to make the player when it has storage> 1 (configurable) can not attack monster x, and when it has storage = 2 (configurable) can attack the monster
 

Danger II

FluppiX.com
Joined
Nov 21, 2012
Messages
1,597
Best answers
11
Reaction score
397
Location
Germany
What about monster? Does it still attack the player even through player cannot attack the monster?
 
OP
K

kalew

New Member
Joined
Mar 19, 2016
Messages
6
Best answers
0
Reaction score
1
the monster is configured to not attack the player if it does not have storage, but the player attacks it with or without storage, I want it if the player does not have the necessary storage, it can not attack the monster, it would be like attacking an npc, then when he gained the storage, he could do damage to the monster to kill him
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Joined
Mar 16, 2017
Messages
448
Best answers
41
Reaction score
271
Location
London
events/events.xml
events/scripts/creature.lua
Code:
<event class="Creature" method="onTargetCombat" enabled="1" />
Code:
if self:isPlayer() and target:isMonster() and target:getName() == "Demon" and self:getStorageValue(1000) == 1 then
        return RETURNVALUE_NOTPOSSIBLE
    end
36867
this it should work
 
OP
K

kalew

New Member
Joined
Mar 19, 2016
Messages
6
Best answers
0
Reaction score
1
@Sarah Wesker
Where install ??
creaturescripts?
in the folder date does not have this folder event / ...
Do you need to tag in the monster file?
<script> <event name = "creature" /> </ script>
 

zxmatzx

Intermediate OT User
Joined
Dec 1, 2010
Messages
159
Best answers
6
Reaction score
41
@Sarah Wesker
Where install ??
creaturescripts?
in the folder date does not have this folder event / ...
Do you need to tag in the monster file?
<script> <event name = "creature" /> </ script>
events/events.xml
events/scripts/creature.lua
 
OP
K

kalew

New Member
Joined
Mar 19, 2016
Messages
6
Best answers
0
Reaction score
1
@zxmatzx
events/events.xml
events/scripts/creature.lua


but I do not have this event folder .... could not adapt to creaturscripts?

Edit : i using The Forgotten Server version 0.3.6 (Crying Damson)
 
Last edited:

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Joined
Mar 16, 2017
Messages
448
Best answers
41
Reaction score
271
Location
London
Script!
Code:
function onCombat(cid, target)
    if isMonster(target) and isPlayer(cid) then
        if getCreatureName(target) == "Demon" and getCreatureStorage(cid, 1000) == 1 then
            return false
        end
    end
    return true
end
Login.lua
Code:
registerCreatureEvent(cid, "monsterProtected")
Creaturescripts.xml
Code:
<event type="combat" name="monsterProtected" event="script" value="monsterProtected.lua"/>
 
OP
K

kalew

New Member
Joined
Mar 19, 2016
Messages
6
Best answers
0
Reaction score
1
@Sarah Wesker
THANKS!!!!!
its worked....

How to put more than 1 value? or is it put 1, 2, 3, .......?
 
OP
K

kalew

New Member
Joined
Mar 19, 2016
Messages
6
Best answers
0
Reaction score
1
@Sarah Wesker

yes, because I tested with a player that has storage 2, and the player can attack

Edit : No more, it's working, thank you.
 
Last edited:
Top