• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Action] + [MoveEvent] + [TalkAction]: Scripts for the public

frankfarmer

who'r ninja now
Premium User
Joined
Aug 5, 2008
Messages
1,581
Reaction score
80
The point of the thread is to release all the scripts that i've used on my server. I hope they may help someone. If credits are missing, post in the thread and i'll add them. All of the scripts work for 0.3.6 servers. And I know most of them are scattered around OTland but here is a thread where everyone are at the same one.

Mechanical Fishingrod
Mechanical_Fishing_Rod.gif
+
Nail.gif
=
Mechanical_Fish.gif

action.xml
Code:
<action itemid="10223" event="script" value="tools/mechanical_fishing.lua" allowfaruse="1"/>

action/scripts/tools/mechanical_fishing.lua
Code:
local useNails = TRUE
local waterIds = {493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray(waterIds, itemEx.itemid) == TRUE then
		if itemEx.itemid ~= 493 then
			if useNails == FALSE or useNails == TRUE and doPlayerRemoveItem(cid, 8309, 1) == TRUE then
				if math.random(1, (100 + (getPlayerSkill(cid, SKILL_FISHING) / 10))) <= getPlayerSkill(cid, SKILL_FISHING) then
					doPlayerAddItem(cid, 10224, 1)
				end
				doPlayerAddSkillTry(cid, SKILL_FISHING, 1)
			end
		end
		doSendMagicEffect(toPosition, CONST_ME_LOSEENERGY)
		return TRUE
	end
	return FALSE
end

Rust Remover
Rust_Remover.gif
=
Rusty_Armor_%28Common%29.gif

action.xml
Code:
<action itemid="9930" event="script" value="tools/rustremover.lua"/>

action/scripts/rustremover.lua
Code:
local breakChance = 60
local rustyItems = {
    [9808] = {2464, 2465, 2483, 2463, 2476}, --common rusty armor
    [9809] = {2464, 2465, 2483, 2463, 2476, 8891, 2487}, --semi-rare rusty armor
    [9810] = {2465, 2463, 2476, 8891, 2487, 2466, 2492, 2472}, --rare rusty armor
    [9811] = {2468, 2648, 2478, 2647, 2477}, --common rusty legs
    [9812] = {2468, 2648, 2478, 2647, 2477, 2488}, --semi-rare rusty legs
    [9813] = {2468, 2648, 2478, 2647, 2477, 2488, 2470}, --rare rusty legs
    [9814] = {2511, 2510, 2530, 2509, 2513, 2515}, --common rusty shield
    [9815] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519}, --semi-rare rusty shield
    [9816] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield 
    [9817] = {2643, 3982, 5462, 7457}, --common rusty boots
    [9818] = {2643, 3982, 5462, 7457, 2195}, --semi-rare rusty boots
    [9819] = {2643, 3982, 5462, 7457, 2195, 2645}, --rare rusty boots
    [9820] = {2458, 2460, 2480, 2481, 2457, 2491}, --common rusty helmet
    [9821] = {2458, 2460, 2480, 2481, 2457, 2491, 2497}, --semi rare rusty helmet
    [9822] = {2458, 2460, 2480, 2481, 2457, 2491, 2497, 2475, 2498} --rare rusty helmet
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if rustyItems[itemEx.itemid] ~= nil then
        if math.random(100) <= breakChance then
            doRemoveItem(itemEx.uid)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
        else
            local newId = rustyItems[itemEx.itemid][math.random(#rustyItems[itemEx.itemid])]
            doTransformItem(itemEx.uid,newId)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
        end
        doRemoveItem(item.uid,1)
        return TRUE
    end
    return FALSE
end

Ceremonial Ankh
Ceremonial_Ankh.gif


action.xml
Code:
	<action itemid="6561" event="script" value="tools/ceremonial_ankh.lua"/>

action/scripts/ceremonial_ankh.lua
Code:
local blessings = {"\nWisdom of Solitude", "\nSpark of the Phoenix", "\nFire of the Suns", "\nSpiritual Shielding", "\nEmbrace of Tibia"}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local result = "Received blessings:"
	for i = 1, 5 do
		result = getPlayerBlessing(cid, i) and result .. blessings[i] or result
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 20 > result:len() and "No blessings received." or result)
	return TRUE
end

Experience Stage Item
Christmas_Token.gif


action.xml
Code:
<action itemid="6527" event="script" value="donator/exp.lua"/>

action/scripts/exp.lua
Code:
local config = {
	rate = 1.6, -- 4x More Experience
	time = 5, -- Hours of Exp Time
	storage = 20012
}
local function endExpRate(cid)
	if isPlayer(cid) == TRUE then
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		setPlayerStorageValue(cid, config.storage, -1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
	end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerStorageValue(cid, config.storage) < 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is now: " .. config.rate .. ". It will last for ".. config.time .." hours.")
		doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
		setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
		addEvent(endExpRate, config.time * 3600 * 1000, cid)
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
	end
	return TRUE
end

creaturescripts.xml
Code:
<event type="login" name="expRate" event="script" value="extraExpRate.lua"/>

creaturescripts/scripts/extraExpRate.lua
Code:
local config = {
	rate = 1.6, -- 4x More Experience
	storage = 20012
}
local function endExpRate(cid)
	if isPlayer(cid) == TRUE then
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		setPlayerStorageValue(cid, config.storage, -1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
	end
end
function onLogin(cid)
	local str = getPlayerStorageValue(cid, config.storage)
	if(str >= 0 and (str - os.time()) > 0) then
		doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your extra exp rate will expire at: " .. os.date("%X", str))
		addEvent(endExpRate, (str - os.time()) * 1000, cid)
	else
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You do not have any extra experience time.")
		setPlayerStorageValue(cid, config.storage, -1)
	end
	return TRUE
end

Winning Lottery Ticket
Winning_Lottery_Ticket.gif


action.xml
Code:
	<action itemid="5957" event="script" value="other/lotto.lua"/>

action/scripts/lotto.lua
Code:
function onUse(cid, item, frompos, item2, topos)
	rand = math.random(1,11)

if item.itemid == 5957 then
	if rand == 7 then
		doPlayerSendTextMessage(cid,25,"WINNER, Congratulations you draw a winner lottery ticket!")
		doSendMagicEffect(frompos, 12) 
		doTransformItem(item.uid,item.itemid+1)
	else
		doPlayerSendTextMessage(cid,25,"Try again later, you draw blank.")
		doSendMagicEffect(frompos, 12)
		doTransformItem(item.uid,item.itemid-1)
	end 
	
    return
    end
end

I will update it when I have more time. This is all you get for now. Credits to the creators of the scripts! I am just sorting them in one thread.


 
Last edited:


Rookgaard Premium Tile
newb2.jpg


movements.xml
Code:
<movevent type="StepIn" actionid="60043" event="script" value="rook_premiumtile.lua"/>

movements/scripts/rook_premiumtile.lua
Code:
local pos = {x = 32060, y = 32193, z = 7}
function onStepIn(cid, item, position, fromPosition)
	if(not(isPremium(cid))) then
		doTeleportThing(cid, pos)
		doSendMagicEffect(pos, CONST_ME_TELEPORT)
	end
	return true
end

Tomb Magical Flames
Mystic_Flame.gif


movements.xml
Code:
<movevent type="StepIn" uniqueid="60063" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60064" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60065" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60066" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60067" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60068" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60069" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60070" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60071" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60072" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60073" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60074" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60075" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60076" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60077" event="script" value="tomb.lua" />
<movevent type="StepIn" uniqueid="60078" event="script" value="tomb.lua" />

movements/scripts/tomb.lua
Code:
local config = {
	[60063] = {{x=33073, y=32589, z=13}, {x=33079,y=32589,z=13}},
	[60064] = {x=33072,y=32589,z=13},
	[60065] = {{x=33098,y=32816,z=13}, {x=33093,y=32824,z=13}},
	[60066] = {x=33097,y=32815,z=13},
	[60067] = {{x=33135,y=32682,z=12}, {x=33130,y=32683,z=12}},
	[60068] = {x=33136,y=32683,z=12},
	[60069] = {{x=33161,y=32831,z=10}, {x=33156,y=32832,z=10}},
	[60070] = {x=33162,y=32832,z=10},
	[60071] = {{x=33233,y=32692,z=13}, {x=33234,y=32687,z=13}},
	[60072] = {x=33234,y=32693,z=13},
	[60073] = {{x=33240,y=32855,z=13}, {x=33246,y=32850,z=13}},
	[60074] = {x=33239,y=32856,z=13},
	[60075] = {{x=33276,y=32552,z=14}, {x=33271,y=32553,z=14}},
	[60076] = {x=33277,y=32553,z=14},
	[60077] = {{x=33293,y=32741,z=13}, {x=33299,y=32742,z=13}},
	[60078] = {x=33292,y=32742,z=13}
}
function onStepIn(cid, item, pos, fromPosition)
	if(config[item.uid]) then
		if(type(config[item.uid]) == "table") then
			local coin = getTileItemById(config[item.uid][1], 2159).uid
			if(coin > 0) then
				doRemoveItem(coin, 1)
				doSendMagicEffect(config[item.uid][1], CONST_ME_HITBYFIRE)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
				doTeleportThing(cid, config[item.uid][2], FALSE)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
			end
		else
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
			doTeleportThing(cid, config[item.uid], FALSE)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
		end
	end
	return TRUE
end

Naruto Car System

movements.xml
Code:
	<movevent type="StepIn" itemid="7266" event="script" value="car.lua"/>
	<movevent type="StepIn" itemid="7267" event="script" value="car.lua"/>"/>

movements/scripts/car.lua
Code:
local storages = {isMoving = 12550, direction = 12551, speed = 12552}

local SpeedMeter = {Default = 800, Max = 0, Min = 2500}

function tileChecker(pos, type_)
        local myTable = {}
        if (type(pos) == 'table') then
                for i = 1, 5 do
                        pos.stackpos = i
                        local Thing = getThingFromPos(pos)
                        local thisID, thisUID = Thing.itemid, Thing.uid
                        if thisID > 1 then
                                if type_ == "itemID" then
                                        table.insert(myTable, thisID)
                                elseif type_ == "itemUID" then
                                        table.insert(myTable, thisUID)
                                end
                        end
                end
        end
        return #myTable > 0 and myTable or nil
end

local function findItem(pos, t)
        if (type(pos) == 'table' and type(t) == 'table') then
                for _i, i in ipairs(tileChecker(pos, "itemID")) do
                        if isInArray(t, i) then
                                pos.stackpos = _i
                                ret = getThingFromPos(pos).uid
                                break
                        end
                end
        end
        return ret
end

function moveCar(x)
        if x.Dir ~= -1 then
                doCreateItem(isInArray({1, 2}, x.Dir) == TRUE and 7267 or 7266, 1, x.nPos)
                doTeleportThing(x.cid, x.nPos, FALSE)
                doRemoveItem(findItem(x.pos, {7266, 7267}))
        end
end

function onStepIn(cid, item, position, fromPosition)
        if isPlayer(cid) == TRUE then
                local status =
                {
                        isMoving = getPlayerStorageValue(cid, storages.isMoving),
                        direction = getPlayerStorageValue(cid, storages.direction),
                        speed = getPlayerStorageValue(cid, storages.speed)
                }
                if status.speed <= SpeedMeter.Max then
                        setPlayerStorageValue(cid, storages.speed, SpeedMeter.Default)
                        status.speed = SpeedMeter.Default
                elseif status.speed >= SpeedMeter.Min then
                        setPlayerStorageValue(cid, storages.speed, SpeedMeter.Default)
                        status.speed = SpeedMeter.Default
                end
                if status.isMoving == 1 then
                        local Movements =
                        {
                                [1] = {x = position.x - 1, y = position.y, z = position.z},
                                [2] = {x = position.x + 1, y = position.y, z = position.z},
                                [3] = {x = position.x, y = position.y - 1, z = position.z},
                                [4] = {x = position.x, y = position.y + 1, z = position.z}
                        }
                       
                        if not Movements[status.direction] then setPlayerStorageValue(cid, status.direction, 1) end
                       
                        local Stor = status.direction
                       
                        local newPos = Movements[Stor]
                       
                        local Check = tileChecker(newPos, "itemUID")
                       
                        if Check ~= nil then   
                                for _, i in ipairs(Check) do
                                        if (hasProperty(i, CONST_PROP_BLOCKSOLID) == TRUE or isCreature(i) or getTilePzInfo(newPos)) then
                                                Stor = isInArray({1, 2}, Stor) == TRUE and (Stor == 1 and 2 or 1) or isInArray({3, 4}, Stor) and (Stor == 3 and 4 or 3) or nil
                                                newPos = Movements[Stor]
                                                setPlayerStorageValue(cid, storages.direction, Stor)
                                                break
                                        end    
                                end
                        end                    
                        addEvent(moveCar, status.speed, {cid = cid, pos = position, nPos = newPos, Dir = Stor})      
                       
                elseif status.isMoving == -1 then
                        setPlayerStorageValue(cid, storages.isMoving, 1)
                end
        end
        return TRUE
end


I will update it when I have more time. This is all you get for now. Credits to the creators of the scripts! I am just sorting them in one thread.


 
Last edited:


Reward Players Online

talkactions.xml
Code:
<talkaction log="yes" words="/reward" access="5" event="script" value="reward.lua"/>

talkactions/scripts/reward.lua
Code:
function onSay(cid, words, param, channel)   
        local t = string.explode(param, ",")
        local gm = getCreatureName(cid)
        for _, cid in ipairs(getPlayersOnline()) do
                local accId = getPlayerAccount(cid)
                if(getNotationsCount(accId) < 1) then
                    doPlayerAddItem(cid, t[1], 1)
                        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Everyone have been rewarded a "..getItemNameById(t[1]).." by "..gm.." for the reason: "..tostring(t[2])..".")
                        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)                
                end
        end
        return TRUE
end


I will update it when I have more time. This is all you get for now. Credits to the creators of the scripts! I am just sorting them in one thread.


 
Last edited:
You should put the creators name above the script or something :thumbup: But anyways nice job and i hope you go far with this. ^^
 
You should put the creators name above the script or something :thumbup: But anyways nice job and i hope you go far with this. ^^

I would do it without any hesitation, but who are the creators?
 
I'm the creator of ceremonial ankh and winner lottery ticket. Would be nice if you credit me.

Here, Artiruz Death.
Thx in advance, Yours Last Knight.
 
Improved ceremonial ankh, 100[?]% real:
Code:
local blessings = {"\nWisdom of Solitude", "\nSpark of the Phoenix", "\nFire of the Suns", "\nSpiritual Shielding", "\nEmbrace of Tibia"}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local result = "Received blessings:"
	for i = 1, 5 do
		result = getPlayerBlessing(cid, i) and result .. blessings[i] or result
	end
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 20 > result:len() and "No blessings received." or result)
	return TRUE
end
 
Really nice :eek:
Thanks :wub::wub:

@edit
When you are giving the line to the actions.xml for instance:
Code:
<action itemid="10223" event="script" value="tools/mechanical_fishing.lua" allowfaruse="1"/>

you are giving this one under:
action/scripts/mechanical_fishing.lua

Shouldn't it be:
actions/scripts/tools/mechanical_fishing.lua
?

Its only my one suggestion, there are few newbies, and they will ask why the script doesn't work :p
 
Last edited:
Really nice :eek:
Thanks :wub::wub:

@edit
When you are giving the line to the actions.xml for instance:
Code:
<action itemid="10223" event="script" value="tools/mechanical_fishing.lua" allowfaruse="1"/>

you are giving this one under:
action/scripts/mechanical_fishing.lua

Shouldn't it be:
actions/scripts/tools/mechanical_fishing.lua
?

Its only my one suggestion, there are few newbies, and they will ask why the script doesn't work :p

Thanks mate, edited it now.


I will update the thread asap. Thank you for all the nice comments!
 
Premium Tile:
Code:
<movevent type="StepIn" actionid="60043" event="script" value="if (not(isPremium(cid))) then (doTeleportThing(cid, fromPosition) and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)) end"/>
 
Back
Top