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

[SOLVED-DONE] Talkactions -Give Spell-

armitxe

New Member
Joined
Feb 15, 2009
Messages
65
Reaction score
1
Hello everyone...

Thanks for reading!

Well the title says everything...

I want to make a talkaction to give X spell to a player...

Why i need it?

Because i make custom spells but i want just a few people to use it in the server, so i have to make that spell to be learned...

Please guys, can you help me with this?

Thank you!

---

Thanks Cykotitan for your talkaction, it works perfect!

Code:
function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	local target, spell = getPlayerByNameWildcard(t[1]), t[2]	
	return (param == '' or #t ~= 2) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a players name and number.") or not target and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.") or getPlayerGroupId(target) > 11 and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give spells to another Staff member.") or getPlayerLearnedInstantSpell(target, spell) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player already knows this spell.") or doPlayerLearnInstantSpell(target, spell) and (doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(target) .." has now learned spell " .. getInstantSpellInfo(spell)) and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)) or doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This spell doesn't exist.")
end
 
Last edited:
This might help you.

Not an talkaction, but an item. If you use the item or something, you learn the spell. I haven't studied the script properly yet.
Hello there!
Xampy solved it! heres the working script :D

Lua:
local spellItemID = 8981
local Cancelwords = "You need to have a vocation and be over level 250 to read this book."
local Sorcererwords = "You've learned the Energy rage spell say \"Exevo vis rage\" to test it."
local Druidwords = "You've learned the Nature rage spell say \"Exevo pox rage\" to test it."
local Paladinwords = "You've learned the Holy rage spell say \"Exevo san rage\" to test it."
local Knightwords = "You've learned the Physical rage spell say \"Exevo hur rage\" to test it."
local reqLevel = 250

function onUse(cid, item, frompos, item2, topos)
        if item.itemid == spellItemID and (getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 5) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Energy Rage")
                doCreatureSay(cid, Sorcererwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Nature Rage")
                doCreatureSay(cid, Druidwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 3 or getPlayerVocation(cid) == 7) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Holy Rage")
                doCreatureSay(cid, Paladinwords, 19)
                doRemoveItem(cid, item.uid, 1)
        elseif item.itemid == spellItemID and (getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8) and getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Physical Rage")
                doCreatureSay(cid, Knightwords, 19)
                doRemoveItem(cid, item.uid, 1)
        else
                doPlayerSendCancel(cid, Cancelwords)
        end
        return 1
end

Rep++ to the ones who help!

To make it to an talkaction, here is something I scratched up after 10 seconds research:
Lua:
local Cancelwords = "You need to be level 50 or higher to learn this spell."
local reqLevel = 50
local PopupMessageWhenSpellLearned = "You've learned the Energy rage spell say \"Exevo vis rage\" to test it."
function onSay(cid, words, param, channel)
        if getPlayerLevel(cid) >= reqLevel then
                playerLearnInstantSpell(cid, "Energy Rage")
                doCreatureSay(cid, PopupMessageWhenSpellLearned, 19)
                doRemoveItem(cid, item.uid, 1)
                                        else
                doPlayerSendCancel(cid, Cancelwords)
        end
        return 1
end
 
Last edited:
Thanks ^^

But well is not what i exactly looking for..

What i real want is to say a diferent spell with a single command... like /addspell name, sky fury - /addspell name, dark street - etc..

I tried to make one based on a talkaction (of Cykotitan) but it only works with 1 spell...

If you want it, here it is:

Code:
  string.explode = function (str, sep)
        local pos, t = 1, {}
        if #sep == 0 or #str == 0 then
                return
        end

        for s, e in function() return str:find(sep, pos) end do
                table.insert(t, str:sub(pos, s - 1):trim())
                pos = e + 1
        end

        table.insert(t, str:sub(pos):trim())
        return t
end

local conditions = {}
for i = 1, 100 do
        table.insert(conditions, createConditionObject(CONDITION_MUTED))
        setConditionParam(conditions[i], CONDITION_PARAM_TICKS, i * 60 * 1000)
end


function onSay(cid, words, param)
        local t = string.explode(param, ",")
        local target = getPlayerByNameWildcard(t[1])

        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a players name and number.")
                return TRUE
        end
        if(getPlayerGroupId(target) > 11) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give spells to another Staff member.")
                return TRUE
        end
        if(not target) then
                target = getCreatureByName(param)
                if(not target) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.")
                        return TRUE
                end
        end

         doPlayerLearnInstantSpell(target, "Sky Fury")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You give a spell to  "..getCreatureName(target)..".")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
        return TRUE
end
 
Last edited:
Updated my post regarding simple spell.

Your example is a bit more bothersome. :p

But I understand your point. But I won't go deep into this now, I need to sleep.
 
Thanks ^^

But well is not what i exactly looking for..

What i real want is to say a diferent spell with a single command... like /addspell name, sky fury - /addspell name, dark street - etc..

I made 1 talkaction but it only works with 1 spell...

If you want it, here it is:

Code:
  string.explode = function (str, sep)
        local pos, t = 1, {}
        if #sep == 0 or #str == 0 then
                return
        end

        for s, e in function() return str:find(sep, pos) end do
                table.insert(t, str:sub(pos, s - 1):trim())
                pos = e + 1
        end

        table.insert(t, str:sub(pos):trim())
        return t
end

local conditions = {}
for i = 1, 100 do
        table.insert(conditions, createConditionObject(CONDITION_MUTED))
        setConditionParam(conditions[i], CONDITION_PARAM_TICKS, i * 60 * 1000)
end


function onSay(cid, words, param)
        local t = string.explode(param, ",")
        local target = getPlayerByNameWildcard(t[1])

        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a players name and number.")
                return TRUE
        end
        if(getPlayerGroupId(target) > 11) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give spells to another Staff member.")
                return TRUE
        end
        if(not target) then
                target = getCreatureByName(param)
                if(not target) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.")
                        return TRUE
                end
        end

         doPlayerLearnInstantSpell(target, "Sky Fury")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You give a spell to  "..getCreatureName(target)..".")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
        return TRUE
end
lulz u didnt make that, ;o credits to meh

Code:
function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	local target, spell = getPlayerByNameWildcard(t[1]), t[2]

	if param == '' or #t ~= 2 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a players name and number.")
	elseif not target then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.")
	elseif getPlayerGroupId(target) > 11 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give spells to another Staff member.")
	elseif getPlayerLearnedInstantSpell(target, spell) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player already knows this spell.")
	else
		if doPlayerLearnInstantSpell(target, spell) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(target) .." has now learned spell " .. getInstantSpellInfo(spell))
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This spell doesn't exist.")
		end
	end
	return true
end
moar rocks:
Code:
function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	local target, spell = getPlayerByNameWildcard(t[1]), t[2]	
	return (param == '' or #t ~= 2) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires a players name and number.") or not target and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online.") or getPlayerGroupId(target) > 11 and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot give spells to another Staff member.") or getPlayerLearnedInstantSpell(target, spell) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player already knows this spell.") or doPlayerLearnInstantSpell(target, spell) and (doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(target) .." has now learned spell " .. getInstantSpellInfo(spell)) and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)) or doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This spell doesn't exist.")
end
 
True cyko, that's not my script...! XD i'm sorry i think i don't expressed correctly.. if u made it ALL the credits for you...

I based in a script for mute people... but i really just change the "doMute" for the spell think xD

Thank you very much, both of your talkactions works perfect!

Greetings!
 
Back
Top