• 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 [SCRIPTS] Read before requesting, updating...

Aarthec

w0000t
Joined
Apr 25, 2009
Messages
129
Reaction score
0
Location
Sweden
If you want a script to be added to the list, tell me.

[All scripts made by me]


ACTIONS:

Experience Scroll:
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
		getStorage = 1337, -- Storage Value
		setStorage = 1337, -- Storage Value
		experience = 5000000, -- How much experience the player should get
		message = "You gained 5,000,000 experience points!", -- Message when the player get experience
		cancelMessage = "You have already used this item." -- Message if the player already has used the experience scroll
		}
		
	if getPlayerStorageValue(cid, config.getStorage) == -1 then
		doPlayerAddExp(cid, config.experience)
		doPlayerSendTextMessage(cid, 22, config.message)
		setPlayerStorageValue(cid, config.setStorage, 1)
		doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendCancel(cid, config.cancelMessage)
		doSendMagicEffect(frompos, CONST_ME_POFF)
	end
end

Use this and you'll learn a spell:
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
		message = "You\'ve learned a new spell!", -- Message if you learn the spell
		cancelMessage = "You already know how to use this spell.", -- Message if you already know the spell
		spell = "Strong Haste" -- Name of the spell
		}
	
	if getPlayerLearnedInstantSpell(cid, config.spell) == FALSE then
		doPlayerSendTextMessage(cid, 22, config.message)
		doPlayerLearnInstantSpell(cid, config.spell)
		doRemoveItem(item.uid, 1)
		doSendMagicEffect(frompos, CONST_ME_MAGIC_BLUE)
	else
		doPlayerSendCancel(cid, config.cancelMessage)
		doSendMagicEffect(frompos, CONST_ME_POFF)
	end
end

This one removes a wall when using a switch (1 minute later, the wall will be created again)
PHP:
function createWall()
local wallPos = {x=92, y=134, z=7, stackpos=1} -- Position of the wall
	doCreateItem(1112, 1, wallPos) -- Replace 1112 to the ID of your wall
	end

function onUse(cid, item, frompos, item2, topos)
local config = {
		removeMessage = "You removed a wall!", -- Message when you remove the wall
		createMessage = "You created a wall!", -- Message when you create the wall
		wallPos = {x=92, y=134, z=7, stackpos=1}, -- Position of the wall
		switchUID = 1337, -- Unique ID of the switch
		timer = 1*60*1000 -- After how long time the wall should be created again after using the switch 
		}
			
local getWall = getThingFromPos(config.wallPos)
	if item.uid == switchUID then
		doRemoveItem(getWall.uid, 1)
		doPlayerSendTextMessage(cid, 19, config.removeMessage)
		doTransformItem(item.uid, item.itemid+1)
		addEvent(createWall, config.timer)
	end

Use an item/switch and you'll get teleported:
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
		message = "You\'ve been teleported!", -- Message when you've been teleported
		teleportPos = {x=98, y=130, z=7}, -- Where the player should get teleported 
		itemUID = 1337 -- Unique ID of the teleport item
		}
		
	if item.uid == itemUID then
		doPlayerSendTextMessage(cid, 19, config.message)
		doTeleportThing(cid, config.teleportPos)
	end
end

Check if 2 players are on their positions, then teleport then to another position:
PHP:
function onUse(cid, item, frompos, item2, topos)
	local playerPos = {
			{x=96, y=129, z=7}, -- Player 1 pos
			{x=94, y=129, z=7} -- Player 2 pos
			}

local toPos = {x=95, y=132, z=7} -- Where players will get teleported
local teleport = {}

	for i, v in ipairs(playerPos) do
		local players = getTopCreature(v).uid or getTopCreature(v)
	if isPlayer(players) ~= TRUE then
		return FALSE
	else
		table.insert(teleport, players)
	end
end
	for i, v in ipairs(teleport) do
		doTeleportThing(v, toPos)
	end
end

If you want to use another item than a chest in quests:
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
		storage = 1331, -- Storage Value
		message = "You obtained a crown armor!", -- Message when you get the crown armor
		cancelMessage = "You\'ve already made this quest.", -- Message if you've already made the quest
		capMessage = "You don\'t have enough capacity.", -- Message if the player doesn't have enough cap
		itemID = 2487, -- Item ID of the item you get
		cap = 99 -- How much cap the item weighs
		}
	
	if getPlayerStorageValue(cid, config.storage) == -1 and getPlayerFreeCap(cid) >= config.cap then
		doPlayerAddItem(cid, config.itemID)
		doPlayerSendTextMessage(cid, 22, config.message)
		setPlayerStorageValue(cid, config.storage, 1)
	elseif getPlayerFreeCap(cid) < config.cap then
		doPlayerSendCancel(cid, config.capMessage)
	else
		doPlayerSendCancel(cid, config.cancelMessage)
	end
end

Use an item to summon a demon:
PHP:
function onUse(cid, item, frompos, item2, topos)
local config = {
		storage = 1337, -- Storage Value
		monster = "Demon", -- Name of the monster
		message = "You summon a Demon!", -- Message when you summon the monster
		cancelMessage = "You\'ve already summoned a monster." -- Message if you've already summoned a monster
		}
		
	if getPlayerStorageValue(cid, config.storage) == -1 then
		doSummonCreature(cid, config.monster)
		setPlayerStorageValue(cid, config.storage, 1)
		doPlayerSendTextMessage(cid, 19, config.message)
	else
		doPlayerSendCancel(cid, config.cancelMessage)
	end
end

Mining system:
PHP:
function onUse(cid, item, frompos, item2, topos)
local chance = math.random(1, 25)
local monsterChance = math.random(1, 300)

	if getPlayerLevel(cid) >= 50 then
		if item2.actionid == 9418 then
			if chance == 12 then
				doPlayerAddItem(cid, 8306, 1)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
				doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
			elseif chance == 4 then
				doRemoveItem(item.uid, 1)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
				doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
			elseif chance == 19 or chance == 20 or chance == 21 then
				doPlayerAddItem(cid, 2152, math.random(1, 54))
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_YALAHARIGHOST)
			elseif chance == 10 then
				doPlayerAddItem(cid, 2147, 1)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_YALAHARIGHOST)
				doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
			elseif monsterChance == 5 then
				doSummonCreature("Dwarf", getCreaturePosition(cid))
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
			elseif monsterChance == 4 then
				doSummonCreature("Dwarf Guard", getCreaturePosition(cid))
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
			else
				doSendMagicEffect(topos, CONST_ME_BLOCKHIT)
			end
		end 
	else
		doPlayerSendTextMessage(cid, 22, "You do not have the required level to mine.")
	end 
end

Smithing:
PHP:
function onUse(cid, item, frompos, item2, topos)
local chance2 = math.random(1, 500)
local softchance2 = math.random(1, 200)
local demonSetchance2 = math.random(1, 500)
local dragonSetchance2 = math.random(1, 300)

local orePos1 = {x=1036, y=1008, z=7, stackpos=1}
local getOre1 = getThingFromPos(orePos1)

if item.itemid == 1945 then
	doTransformItem(item.uid, 1946, 1)
elseif item.itemid == 1946 then
	doTransformItem(item.uid, 1945, 1)
end 



if item.actionid == 19525 then
	if getOre1.itemid == 9662 then
		if demonSetchance2 == 1 then
			doTransformItem(getOre1.uid, 2493, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif demonSetchance2 == 2 then
			doTransformItem(getOre1.uid, 2494, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif demonSetchance2 == 3 then
			doTransformItem(getOre1.uid, 2495, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 4 then
			doTransformItem(getOre1.uid, 2471, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 5 then
			doTransformItem(getOre1.uid, 2466, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 6 then
			doTransformItem(getOre1.uid, 2470, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 7 then
			doTransformItem(getOre1.uid, 2462, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 8 then
			doTransformItem(getOre1.uid, 2476, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 9 then
			doTransformItem(getOre1.uid, 2477, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif dragonSetchance2 == 10 then
			doTransformItem(getOre1.uid, 2506, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif dragonSetchance2 == 11 then
			doTransformItem(getOre1.uid, 2492, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif dragonSetchance2 == 12 then
			doTransformItem(getOre1.uid, 2469, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 13 then
			doTransformItem(getOre1.uid, 2491, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 14 then
			doTransformItem(getOre1.uid, 2487, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 15 then
			doTransformItem(getOre1.uid, 2488, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 16 then
			doTransformItem(getOre1.uid, 2663, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 17 then
			doTransformItem(getOre1.uid, 2656, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 18 then
			doTransformItem(getOre1.uid, 7730, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 19 then
			doTransformItem(getOre1.uid, 2498, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 20 then
			doTransformItem(getOre1.uid, 2472, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 21 then
			doTransformItem(getOre1.uid, 2648, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 22 then
			doTransformItem(getOre1.uid, 2461, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 23 then
			doTransformItem(getOre1.uid, 2467, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 24 then
			doTransformItem(getOre1.uid, 2649, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 25 then
			doTransformItem(getOre1.uid, 2195, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif softchance2 == 26 then
			doTransformItem(getOre1.uid, 6132, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 == 27 then
			doTransformItem(getOre1.uid, 2646, 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGCLOUDS)
		elseif chance2 >= 28 then
			doTransformItem(getOre1.uid, math.random(2222, 2225), 1)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	else
		doPlayerSendCancel(cid, "You have to put an ore on the anvil first.")
		end 
	end 
	end
end

TALKACTIONS:

Buy Amulet of Loss

PHP:
function onSay(cid, words, param)

	if doPlayerRemoveMoney(cid, 50000) == TRUE then
		doPlayerAddItem(cid, 2173, 1)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MORTAREA)
		doPlayerSendTextMessage(cid, 19, "You've bought Amulet of Loss!")
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enough money.")
	end
end

Buy blessings:
PHP:
function onSay(cid, words, param)

if getPlayerBlessing(cid,5) then
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already been blessed.")
else
	if doPlayerRemoveMoney(cid, 50000) == TRUE then
		for i = 1,5 do
			doPlayerAddBlessing(cid,i)
		end
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been blessed by the gods!")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_ENERGYHIT)
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have enough money.")
	end
end
end

Movements:

Step on a tile, summon a monster. For a quest? (Only possible to summon it once)
PHP:
function onStepIn(cid, item, position, fromPosition)
local jugger = {x=2887, y=678, z=6, stackpos=1}
	if isPlayer(cid) == TRUE and getPlayerStorageValue(cid,9191) == -1 then
		doSummonCreature("Juggernaut", jugger)
		setPlayerStorageValue(cid,9191,1)
	end
end
 
Last edited:
About movements, you haven't to declare stackpos while summoning monster :thumbup:
 
@Chojrak
I don't know why I'm doing that oO

@Shawak
Changing the storage value isn't hard ^^
 
If you want to make the script for me.
Code:
local number = 3 --3 monsters are summoned
local positions = {{x=,y=,z=},{x=,y=,z=}{x=,y=,z=}} --3 positions if 3 monsters
local monsters = {"Rat","Fire Devil","Dragon Ghost"}
Make a script which summons a "number" of "monsters" on positions[number], but only if there are no monsters in an area, only players. Script should be an action script. TY
 
Aarthec, sorry for making it but I'm bored.

@Rhux:
It will automatically get count of monsters in table, you haven't to set number.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local positions = {
		{x = , y = , z = , stackpos = 253},
		{x = , y = , z = , stackpos = 253},
		{x = , y = , z = , stackpos = 253}
	}

	local monsters = {
		"Orshabaal",
		"Morgaroth",
		"Ghazbaran"
	}

	if (#positions ~= #monsters) then
		return true
	end

	for i = 1, #positions do
		if (not getThingFromPos(positions[i])) then
			doSummonCreature(monsters[i], positions[i])
		end
	end
	return true
end

Code is untested, if you have problems - post it here.
 
Thanks seems nice,but I will add area check.
 
Code is untested, if you have problems - post it here.

If I have problems I fix it myself XD

I am no noob in scripting just was to bored off working on my OT to do it :D
 
Back
Top Bottom