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

Tutorials [LUA] Creating Actions/Movements & TalkActions

funny and very helpfull, very good tutorial. I enjoyed reading it! Thank you very much, also rep++ for you ;]
 
Im newbie to OT and now learning LUA.
Im reading this tutorial which was made in 12th August 2008, 17:55 so its a bit outdated and asking mod's to change things what is see has been changed since then.

there was for action scripts:
Code:
function onUse(cid, item, frompos, item2, topos)
now are:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

for Talk action scripts was:
Code:
function onSay(cid, words, param)
now are:
Code:
onSay(cid, words, param, channel)

im just learning, but in case someone else find this tutorial useful and dont get in wrong.

//Very useful tut.

thank you for updated those xD
 
I made another version of an "Exp Scroll", but it's not tested.

Code:
local config = {
	exp = 30000,
	voc = {1,2,5,6},
	level = 100,
	words = "Exp!",
	itemID = 6119
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerVocation(cid) == config.voc then
		if getPlayerLevel(cid) <= config.level then
			doPlayerAddExp(cid, config.exp)
			doCreatureSay(cid, config.words, 18)
			doRemoveItem(cid, config.itemID, 1)
			doSendMagicEffect(fromPosition, CONST_ME_FIREWORK_YELLOW)
		else
			doPlayerSendCancel(cid, "Sorry, you need to be lower than level "..config.level..".")
		end
	else
		doPlayerSendCancel(cid, "Only mages can use this scroll.")
	end
return TRUE
end
 
Last edited:
Fixed:
Code:
local config = {
	exp = 10000,
	voc = {1, 2, 5, 6},
	level = 100,
	words = "Exp!"
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray(config.voc, getPlayerVocation(cid)) == TRUE then
		if getPlayerLevel(cid) >= config.level then
			doPlayerAddExp(cid, config.exp)
			doCreatureSay(cid, config.words, TALKTYPE_YELL)
			doRemoveItem(item.uid)
		else
			doPlayerSendCancel(cid, "Sorry, you need to be higher than level " .. config.level .. ".")
		end
	else
		doPlayerSendCancel(cid, "Only mages can use this scroll.")
	end
	return TRUE
end
 
It's a good simple tutorial but it has to be update since many functions has been changed.
 
Thanks, helped me ;D
instead of
PHP:
function onStepIn(cid, item, position, fromPosition)
if item.uid == 1234 and getPlayerGroupId(cid) ~= 3 then
setPlayerGroupId(cid, 3)
end
end
;)[/QUOTE]

Why at the beginning of the script set item.uid since reading it in the xml file?
 
local group = 3 -- group id

function onStepIn(cid, item, position, fromPosition)
if getPlayerGroupId(cid) ~= 3 then
setPlayerGroupId(cid, group) end
end
 
Back
Top