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

Little help, Could pay $

TriamerA

The Mystic One.
Joined
Nov 16, 2008
Messages
1,256
Reaction score
17
Location
Poland
Hello
Well I've got a little situation here, becasue I couldn't really understand this type of script.
I'm using darkhaos pet system and so I'd like to add a feature in which you coudln't attack your own pet.
So there is:
Code:
function onStatsChange(cid, attacker, type, combat, value)
 
	if getPlayerPet(cid) and getPlayerPet(cid) == attacker then
		return false
	end
	return true
end

I'd like to make it so a player could not attack his own pet by spells, but someone else could, or not.
Thanks for help.
 
Last edited:
Heres the fix for it. It actually will work for all summons. if you dont want to for all summons change function:

Code:
getCreatureSummons(cid)

TO

Code:
getPlayerPet(cid)-- I think should work.

But this way works fine.

creaturescripts.xml

Code:
<event type="target" name="aTarget" event="script" value="targetf.lua"/>

add to login.lua where all registers is this

Code:
registerCreatureEvent(cid, "aTarget")

targetf.lua

Lua:
function onTarget(cid, target)
local summons = getCreatureSummons(cid)
if(table.maxn(summons) > 0) and summons[1] == target then
doPlayerSendCancel(cid, "You can't attack your own summon.")
return false
else 
return true 
end
end

However I would appreciate that donation if you will want to send it then to: [email protected]
 
Use that script I gave up and this one it will avoid any attack by summon owner to summon. but you must to add for every pets this code:

Code:
 <script>
	<event name="area"/>
        </script>
actually add it anywhere, maybe before </loot>.

creaturescripts.xml

Code:
<event type="statschange" name="area" event="script" value="area.lua"/>

login.lua register it.

Code:
registerCreatureEvent(cid, "area")

and code area.lua

Lua:
function onStatsChange(cid, attacker, type, combat, value)
local summons = getCreatureSummons(attacker)
if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
if(table.maxn(summons) > 0) and summons[1] == cid then
return false
else 
return true 
end
end
end
 
Back
Top