Sizaro
Advanced OT User
So I've been playing around with a new server of mine for a while now and I need a few things, thought I'd request them.
(If you have a better idea that works the same way please let me know)
[DONE] #1: onLogin add outfit (once) based on gender and vocation.
Thanks Ninja
Heres the code:
data\creaturescripts\Actions.xml
data\creaturescripts\scripts\firstoutfit.lua
\data\global or compat.lua
bottom add:
[DONE] #2: Dual-Wielding daggers (Swords)
Thanks hakeee
[DONE] #3: Teleport to house exit function StepIn.
Thanks Ninja
Heres the code:
data\movements\movements.xml
data\movements\scripts\houseTeleport.lua
[DONE] #3: Summons following you
and then in creaturescripts.xml
and in summonfollow.lua
don't forget to remove utevo res from spells.xml
(If you have a better idea that works the same way please let me know)
[DONE] #1: onLogin add outfit (once) based on gender and vocation.
Thanks Ninja
Heres the code:
data\creaturescripts\Actions.xml
Code:
<event type="login" name="FirstOutfit" script="firstoutfit.lua"/>
data\creaturescripts\scripts\firstoutfit.lua
Code:
local config = {
[1] = {female = 575, male = 574},
[2] = {female = 269, male = 268},
[3] = {female = 142, male = 134},
[4] = {female = 138, male = 130},
[5] = {female = 148, male = 144},
[6] = {female = 137, male = 129}
}
function onLogin(cid)
local player = Player(cid)
local targetVocation = config[player:getVocation():getBase():getId()]
if not targetVocation then
return true
end
if player:hasOutfit(player:getSex() == 0 and targetVocation.female or targetVocation.male) then
return true
end
player:addOutfit(targetVocation.female)
player:addOutfit(targetVocation.male)
return true
end
\data\global or compat.lua
bottom add:
Code:
add this to your global/compat.lua, credits goes to dalkon
function Vocation.getBase(self)
local demotion = self:getDemotion()
while demotion do
local tmp = demotion:getDemotion()
if not tmp then
return demotion
end
demotion = tmp
end
return self
end
[DONE] #2: Dual-Wielding daggers (Swords)
Thanks hakeee
[DONE] #3: Teleport to house exit function StepIn.
Thanks Ninja
Heres the code:
data\movements\movements.xml
Code:
<movevent event="StepIn" actionid="x" script="houseTeleport.lua" />
data\movements\scripts\houseTeleport.lua
Code:
function onStepIn(cid, item, position, fromPosition)
local player = Player(cid)
if not player then
return true
end
local house = player:getHouse()
if not house then
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
player:teleportTo(house:getExitPosition())
player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
[DONE] #3: Summons following you
XML:
<talkaction words="utevo res" separator=" " script="summonmonster.lua" />
Lua:
local summonables = {
'Rat',
'Bat',
'Cat'
}
local sum = {}
for _, mon in pairs(summonables) do -- LOWERCASE ALL MONSTER NAMES FOR COMPARISON WITH PARAMETER
table.insert(sum,mon:lower())
end
function onSay(player, words, param)
local name = param:match('%a+')
if not name then
player:sendCancelMessage('Invalid parameters.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if #player:getSummons() > 1 then
player:sendCancelMessage('You cannot summon any more creatures.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
if not isInArray(sum,name:lower()) then
player:sendCancelMessage('You cannot summon this monster.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local monster = Game.createMonster(name, player:getPosition())
if not monster then
player:sendCancelMessage('There is not enough room.')
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
monster:setMaster(player)
monster:registerEvent('summonfollow')
return false
end
XML:
<event type="think" name="summonfollow" script="summonfollow.lua" />
Lua:
function onThink(cid, interval)
local cpos = cid:getPosition()
local ppos = cid:getMaster():getPosition()
if cpos.z ~= ppos.z or math.abs(cpos.x - ppos.x) > 8 or math.abs(cpos.y - ppos.y) > 6 then
cid:teleportTo(ppos)
end
return true
end
Last edited: