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

Lua SummonCreature Script

domyno2837

Member
Joined
Oct 28, 2013
Messages
168
Reaction score
5
Hello Otland,

i tryed to get a script only for paladin.. that they can summon pets for her PVE/PVP Fights..

But in spells.xml are only
event="function" value="SummonMonster"

so how i can create a script that when he can summon Pet Bear for example.. and ONLY Paladin can do it..

tryed yesterday like 3-4 hours to find anything but no luck.. :/
THANKS FOR EVERY HELP!

greetz domy
 
well you have to make a script for it by summoning a monster then making the player it's master.

Since i need to make a similar script for my project, tell me which TFS version you are using and i will help you with it :)
 
i use The Forgotten Server, version 0.3.4 (Crying Damson)..

so thanks man that u can help me!

edit: its possible that the creature can attack only monsters.. or only player?
 
i use The Forgotten Server, version 0.3.4 (Crying Damson)..

so thanks man that u can help me!

edit: its possible that the creature can attack only monsters.. or only player?

I think it is possible with creaturescript, i will give it a shot.
 
a small tip for you, if you turned to TFS 1.0, i can make the script with a modal interface where you can select a monster to summon with a click of a button :P
 
cool job.. but on there is no tfs.exe to start server ;o
you need to compile it yourself ;)

anyway!

the script is done but i did not test it since i don't have a working tfs 0.3.7 server.

Firstly you might need to disable or remove the default utana res spell from spells.xml

then you need to add this line to talkactions.xml

Code:
 <talkaction words="summon" event="script" value="custom summon.lua"/>

and inside Data/Talkactions/Scripts folder, create a new file called custom summon.lua and add this script to it:

Code:
config = {
[1] = {Name = "rat" , Vocations = {1,2,3,4,5,6,7,8}, Mana = 10, TargetPlayers = true, TargetMonsters = true},
[2] = {Name = "wolf" , Vocations = {4,8}, Mana = 30, TargetPlayers = false, TargetMonsters = true}
}


function onSay(cid, words, param)
local pos = getCreaturePosition(cid)
for i=1, #config do
    if param == config[i].Name then
        if isInArray(config[i].Vocations, getPlayerVocation(cid)) then
            if getCreatureMana(cid) < config[i].Mana then
                doCreatureAddMana(cid, -config[i].Mana)
                local creatureId = doSummonMonster(cid, param)
                if creatureId == false then
                    doPlayerSendCancel(cid, "There is not enough room.")
                    return doSendMagicEffect(pos, CONST_ME_POFF)
                else
                    if config[i].TargetPlayers ~= true and config[i].TargetMonsters ~= true then   
                        if config[i].TargetPlayers == true then
                            registerCreatureEvent(creatureId,"AttackPlayersOnly")
                        end
                        if config[i].TargetMonsters == true then
                            registerCreatureEvent(creatureId,"AttackPlayersOnly")
                        end
                    end
                return doSendMagicEffect(pos, CCONST_ME_MAGIC_RED)
                end
            else
                doPlayerSendCancel(cid, "You don't have enough mana to summon this monster.")
                return doSendMagicEffect(pos, CONST_ME_POFF)
            end
        end
    end
end
doPlayerSendCancel(cid, "There is no such monster to summon.")
return doSendMagicEffect(pos, CONST_ME_POFF)
end

and then go to Data/Creaturescripts and open Creaturescripts.xml then add those lines:

Code:
<event type="think" name="AttackMonstersOnly" script="attackmonstersonly.lua"/>
    <event type="think" name="AttackPlayersOnly" script="attackplayersonly.lua"/>

and inside Data/Creaturescripts/Scripts folder, create 2 new files called attackmonstersonly.lua and attackplayersonly.lua

inside attackmonstersonly.lua add this script:

Code:
function onThink(cid, interval)
    local targets = getMonsterTargetList(cid)
if targets ~= nil and #targets ~= 0 then
    for i=1 , #targets do
        if isPlayer(targets[i]) then
            if i ~= #targets then
            doMonsterSetTarget(targets[i+1])
            else
            doMonsterSetTarget(0)
        end
    end
end
return true
end

inside attackplayersonly.lua add this script:

Code:
function onThink(cid, interval)
    local targets = getMonsterTargetList(cid)
if targets ~= nil and #targets ~= 0 then
    for i=1 , #targets do
        if isMonster(targets[i]) then
            if i ~= #targets then
            doMonsterSetTarget(targets[i+1])
            else
            doMonsterSetTarget(0)
        end
    end
end
return true
end

Like i said, i did not test the scripts, to come back to me if there is any errors or problems. if anyone else want to improve the script, feel free to do so :)
 
great really thanks you.

now i saw the changes up from 8.42 to the newest on 9.0/10.0 omg.. what for great changes..
maybe u know how i can change my 8.42 ot to like 9.0 or higher?

BTW THANKS!!
 
hm when i cast "summon pet bear" for my monster its comes "there is no such monster to summon"

edit from creature script:

[06/10/2014 16:34:06] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/attackmonstersonly.lua)
[06/10/2014 16:34:06] data/creaturescripts/scripts/attackmonstersonly.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>'
[06/10/2014 16:34:06] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/attackplayersonly.lua)
[06/10/2014 16:34:07] data/creaturescripts/scripts/attackplayersonly.lua:14: 'end' expected (to close 'function' at line 1) near '<eof>'
[06/10/2014 16:34:07] Reloaded creature events.
 
yea i have

<monster name="Pet Bear" file="Pets/Pet Bear.xml"/>
<monster name="Pet Tiger" file="Pets/Pet Tiger.xml"/>

in monster.xml

and in your config

[1] = {Name = "Pet Bear" , Vocations = {3,7}, Mana = 1000, TargetPlayers = true, TargetMonsters = true},
[2] = {Name = "Pet Tiger" , Vocations = {3,7}, Mana = 1000, TargetPlayers = false, TargetMonsters = true}
 
Back
Top