• 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 Talkaction only for one vocation?

Michaeel

New Member
Joined
Mar 6, 2009
Messages
272
Reaction score
1
Hey, I have this script:
Code:
local config = {
    cost = 30000,
    id_enchantedruby = 7760,
    id_smallruby = 2147
    }
function onSay(cid, words, param)
local pos = getCreaturePosition(cid)
if getPlayerItemCount(cid, config.id_smallruby) >= 1 then
if getPlayerMoney(cid) >= config.cost then
doPlayerBuyItem(cid, config.id_enchantedruby, 1, config.cost, 1)
doPlayerRemoveItem(cid, config.id_smallruby, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enchanted small ruby.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
doPlayerAddSoul(cid, -50)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have 30000 gold coins!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have small ruby!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
return TRUE
end

It should work only for MS (voc ID=5), how can I set it?
Also if other voc will try enchant gem it should say
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not master sorcerer!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
thanks
 
Last edited:
Lua:
if sorcerer then
doPlayerRemoveSoul(cid, -50)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not an Sorcerer.")
end
    return TRUE
end
 
Code:
local config = {
    cost = 30000,
    id_enchantedruby = 7760,
    id_smallruby = 2147
    }
function onSay(cid, words, param)
local pos = getCreaturePosition(cid)
if getPlayerItemCount(cid, config.id_smallruby) >= 1 then
if getPlayerMoney(cid) >= config.cost then
if sorcerer then
doPlayerBuyItem(cid, config.id_enchantedruby, 1, config.cost, 1)
doPlayerRemoveItem(cid, config.id_smallruby, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enchanted small ruby.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
doPlayerRemoveSoul(cid, -50)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have 30000 gold coins!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have small ruby!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not an Sorcerer.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
return TRUE
end

doesnt work :/
 
Ok I did this:

Code:
local config = {
    cost = 30000,
    id_enchantedruby = 7760,
    id_smallruby = 2147
    }
function onSay(cid, words, param)
	local pos = getCreaturePosition(cid)
	if getPlayerItemCount(cid, config.id_smallruby) >= 1 then
	if getPlayerMoney(cid) >= config.cost then
		doPlayerBuyItem(cid, config.id_enchantedruby, 1, config.cost, 1)
		doPlayerRemoveItem(cid, config.id_smallruby, 1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enchanted small ruby.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
		doPlayerRemoveSoul(cid, -50)
	if(getPlayerLevel(cid) < 30) then
		doPlayerSendTextMessage(cid, 22, "Your need 30 level to enchant gems.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return TRUE	
	if(getPlayerSoul(cid) < 50) then
		doPlayerSendTextMessage(cid, 22, "You do not have 50 soul points.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return TRUE
        if(getPlayerMoney(cid) <30000 then
		doPlayerSendTextMessage(cid, 22, "Your need 30000 gold coins.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return TRUE	
	end
return TRUE
end

And I need one function "if" with vocations. only master sorcerer (voc id=5) can use it. how can i do that?
 
<instant name="NAME OF SPELL" words="WORDS TO CAST SPELL" lvl="12" mana="20" prem="1" range="3" casterTargetOrDirection="1" blockwalls="1" exhaustion="2000" needlearn="0" event="script" value="attack/SPELLNAME.lua">
<vocation id="5"/>
</instant>
 
spell62.png


spells.xml
Code:
<instant name="Enchant Ruby" words="!enchant ruby" lvl="30" mana="300" soul="50" prem="1" exhaustion="2000" needlearn="0" event="script" value="attack/enchant.lua">
<vocation id="5"/>
</instant>

spells/attack/enchant.lua
Code:
local config = {
    cost = 30000,
    id_enchantedruby = 7760,
    id_smallruby = 2147
    }
function onSay(cid, words, param)
local pos = getCreaturePosition(cid)
if getPlayerItemCount(cid, config.id_smallruby) >= 1 then
if getPlayerMoney(cid) >= config.cost then
doPlayerBuyItem(cid, config.id_enchantedruby, 1, config.cost, 1)
doPlayerRemoveItem(cid, config.id_smallruby, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enchanted small ruby.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
doPlayerAddSoul(cid, -50)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have 30000 gold coins!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have small ruby!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
return TRUE
end


Isn't possible to do it in talkaction?
 
It should work only for MS (voc ID=5), how can I set it?
Also if other voc will try enchant gem it should say
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not master sorcerer!")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
thanks

Code:
function onSay(cid, words, param, channel)
	local cfg = {}
	cfg.cost = 30000
	cfg.enchanted = 7760
	cfg.ruby = 2147
	cfg.voc = 5 -- Vocation
	if(getPlayerItemCount(cid, cfg.ruby) < 1) then
		doPlayerSendCancel(cid, "You must have a " .. getItemNameById(cfg.ruby) ..".")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	elseif(getPlayerMoney(cid) < cfg.cost) then
		doPlayerSendCancel(cid, "You must have atleast " .. cfg.cost .." gold.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	elseif(getPlayerVocation(cid) ~= cfg.voc) then
		doPlayerSendCancel(cid, "You must be a master sorcerer.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	else
		doPlayerAddSoul(cid, -50)
		doPlayerRemoveItem(cid, cfg.ruby, 1)
		doPlayerBuyItem(cid, config.enchanted, 1, cfg.cost)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have enchanted small ruby.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
	end
	return true
end
 
Back
Top