• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[Help] Talkaction

jubix

New Member
Joined
Aug 7, 2007
Messages
21
Reaction score
0
I was made that script:
Code:
-StArT-
function onSay(cid, words, param) 
-SeTtInGs-
local mana = 10
local voce = 1
local lvl = 30
local voc = 2
local vocTime = 6000
local pacc = 0
local pacce = 0
local outfit = {lookType=7,lookHead=0,lookAddons=0,lookLegs=0,lookBody=0,lookFeet=0}
local outfitTime = 6000
local napis = "Transformation!"
-CoDe-
if(getPlayerMana(cid) >= mana and getPlayerVocation(cid) == voce and getPlayerLevel(cid) >= lvl and isPremium(cid) == pacc or isPremium(cid) == pacce and getPlayerVocation(cid) < voc )then 
doPlayerSetVocation(cid, voc, vocTime) 
doPlayerAddMana(cid,-mana) 
doSetCreatureOutfit(cid, outfit, outfitTime) 
doPlayerSay(cid,napis,16) 
else 
doPlayerSendCancel(cid,"You are too weak.") 
end 
return 1 
end 
-EnD-
The vocation are not changing. What is wrong? Pleae reply.
 
Code:
-- Transform
-- Config:
local config = {
	vocToUse = 1,
	lvl = 30,
	newVoc = 2,
	delay = 1, -- in minutes
	extraHp = 2000,
	extraMp = 2000,
	drainMana = 5,
	timeDrain = 5, -- in seconds
	storage = 5000,
	oldVocStorage = 5001,
	msg = "Transformation."
	}
	
-- Script:
function onSay(cid, words, param)
	if getPlayerVocation(cid) == config.vocToUse then
		if getPlayerLevel(cid) >= config.lvl then
			if getPlayerStorageValue(cid, config.storage) ~= 1 then
				setPlayerStorageValue(cid, config.storage, 1)
				setPlayerStorage(cid, config.oldVocStorage, getPlayerVocation(cid))
				doPlayerSetVocation(cid, newVoc)
				addEvent(revert, config.delay * 60 * 1000, cid)
				addEvent(manaDrain, 1, cid)
				setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + config.extraHp)
				setCreatureMaxMana(cid, getPlayerMaxMana(cid) + config.extraMp)
				doCreatureSay(cid, msg, TALKTYPE_SAY)
				doSetCreatureOutfit(cid, { lookType = 7, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0 }, -1)
			else
				doPlayerSendTextMessage(cid, 17, "You are already transformed.")
			end
		else
			doPlayerSendTextMessage(cid, 17, "Only players of level "..config.lvl.." and above may use this spell.")
		end
	else
		doPlayerSendTextMessage(cid, 17, "Your vocation may not use this transformation.")
	end
	return TRUE
end

function revert(cid)
	setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - config.extraHp)
	setCreatureMaxMana(cid, getPlayerMaxMana(cid) - config.extraMp)
	doPlayerSetVocation(cid, getPlayerStorageValue(cid, config.oldVocStorage))
	doRemoveCondition(cid, CONDITION_OUTFIT)
        setPlayerStorageValue(cid, config.storage, 0)
	stopEvent(manaDrain)
end

function manaDrain(cid)
	repeat
		addEvent(doPlayerAddMana, config.timeDrain * 1000, cid, - config.drainMana)
	until getPlayerMana(cid) < 5
        addEvent(revert, 1, cid)
end

Config said:
vocToUse = wokacja ktora moze uzyc spellu
lvl = lvl do uzycia
newVoc = wokacja w ktora sie transformuja
delay = jak dlugo efekt bedzie sie trzymal w minutach
extraHp = ile dojdzie hp
extraMp = ile dojdzie mp
drainMana = ile many bedzie zabieralo
timeDrain = co ile sekund bedzie zabieralo mane
storage = gdzie bedzie zapisane czy juz jest zamieniony
oldVocStorage = gdzie bedzie zapisywac stara wokacje
msg = co powie gracz

:p
 
Last edited:
Thanks! But is there one problem. I see in console:

Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/transform.lua:onSay

data/talkactions/scripts/transform.lua:23: attempt to call global 'setPlayerStorage' <a nil value>

Can you help me?
 
Last edited:
Code:
-- Transform
-- Config:
local config = {
	vocToUse = { 1 },
	lvl = 30,
	newVoc = 2,
	delay = 1, -- in minutes
	extraHp = 2000,
	extraMp = 2000,
	extraMelee = 10,
	extraShield = - 5,
	drainMana = 5,
	timeDrain = 5, -- in seconds
	timeOutfit = 6, -- in minutes
	storage = 5000,
	oldVocStorage = 5001,
	msg = "Transformation."
	}
-- Conditions:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, config.delay * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_SKILL_MELEE, config.extraMelee)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, config.extraShield)
-- Script:
function onSay(cid, words, param)
	if isInArray(config.vocToUse, getPlayerVocation(cid)) == TRUE then
		if getPlayerLevel(cid) >= config.lvl then
			if getPlayerStorageValue(cid, config.storage) ~= 1 then
				setPlayerStorageValue(cid, config.storage, 1)
				setPlayerStorageValue(cid, config.oldVocStorage, getPlayerVocation(cid))
				doPlayerSetVocation(cid, config.newVoc)
				addEvent(revert, config.delay * 60 * 1000, cid)
				addEvent(manaDrain, 1, cid)
				setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + config.extraHp)
				setCreatureMaxMana(cid, getPlayerMaxMana(cid) + config.extraMp)
				doCreatureSay(cid, config.msg, TALKTYPE_SAY)
				doSetCreatureOutfit(cid, { lookType = 7, lookHead = 0, lookAddons = 0, lookLegs = 0, lookBody = 0, lookFeet = 0 }, -1)
				doAddCondition(cid, condition)
			else
				doPlayerSendTextMessage(cid, 17, "You are already transformed.")
			end
		else
			doPlayerSendTextMessage(cid, 17, "Only players of level "..config.lvl.." and above may use this spell.")
		end
	else
		doPlayerSendTextMessage(cid, 17, "Your vocation may not use this transformation.")
	end
	return TRUE
end

function revert(cid)
	setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - config.extraHp)
	setCreatureMaxMana(cid, getPlayerMaxMana(cid) - config.extraMp)
	doPlayerSetVocation(cid, getPlayerStorageValue(cid, config.oldVocStorage))
	doRemoveCondition(cid, CONDITION_OUTFIT)
    setPlayerStorageValue(cid, config.storage, 0)
	stopEvent(manaDrain)
end

function manaDrain(cid)
	repeat
		addEvent(doPlayerAddMana, config.timeDrain * 1000, cid, - config.drainMana)
	until getPlayerMana(cid) < 5
        addEvent(revert, 1, cid)
end
Added condition, fixed few bugs :p
 
I have new problem. When i want to transform then make chaos in console.
look:
beznazwy2ho6.jpg

Did u test this script? If yes please tell me on what OTServ.
 
Last edited:
Try changing:
Code:
function manaDrain(cid)
	repeat
		addEvent(doPlayerAddMana, config.timeDrain * 1000, cid, - config.drainMana)
	until getPlayerMana(cid) < 5
        addEvent(revert, 1, cid)
end

to
Code:
function manaDrain(cid)
    local param = { cid = cid, mana = - config.drainMana }
    repeat
        addEvent(doPlayerAddMana, config.timeDrain * 1000, param)
    until getPlayerMana(cid) < 5
    addEvent(revert, 1, cid)
end

Im not sure if this will work, so... ^^
 
Back
Top