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

Lua [HELPING] Post here your lua errors for help

Mokerhamer

Retired Global Mod
Senator
Joined
Aug 6, 2007
Messages
1,767
Reaction score
36
Hello,

I'v made this thread because i noticed that many people wont help others with error's so i made this thread so i can help people.

How to report:
1. What the script should do (Important)
2. Post script (Important)
3. Post error (Important)
4. What distro you use. (Important)
4. What do u think it's wrong with it (NOT important)


P.s)
Dont expect me to know everything i can only help you on my own knownlege


Thread that could help with Lua actions (2 post):
http://otland.net/showthread.php?t=571


Yours,
Mokerhamer
 
Last edited by a moderator:
FiX ThiS :p

I need you'r help Mokerhamer...

I don't know if this is a LUA problem, but I hope you can help me.

Im using The Forgotten Server (TFS), Rev. 1000.

The problem is that when Im fighting with like a minotaur, of course I get the swords (PZ Lock), that it's supposed to be 60 seconds, and when I got the swords, I can logout...
Im fighting the minotaur, and if I want I can logout...

I want my OT to be RPG, that's not cool...
I'll show you some pictures about my problem:

photo1ix5.png



photo2mh5.png



photo3wr0.png



photo4un1.png


If I'am offline in OtLand, and you wanna be smart, message me in my msn: [email protected]
 
On the second error, it looks like to me that it tries to read the file getSpellDamage. You should remove " and replace it with this: getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
cid is fine, but the others, you'll need to get from somewhere/define in some way.

Kult spell forresten ;)

After this changing, I get this in my console:
Code:
[20/07/2008  15:41:48] Lua Script Error: [Spell Interface] 
[20/07/2008  15:41:48] data/spells/scripts/custom/death star.lua

[20/07/2008  15:41:48] data/spells/scripts/custom/death star.lua:14: bad argument #2 to 'random' (interval is empty)
[20/07/2008  15:41:48] Warning: [Event::loadScript] Can not load script. data/spells/scripts/custom/death star.lua
 
On the second error, it looks like to me that it tries to read the file getSpellDamage. You should remove " and replace it with this: getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)
cid is fine, but the others, you'll need to get from somewhere/define in some way.

Kult spell forresten ;)

[20/07/2008 15:41:48] Lua Script Error: [Spell Interface]
[20/07/2008 15:41:48] data/spells/scripts/custom/death star.lua

[20/07/2008 15:41:48] data/spells/scripts/custom/death star.lua:14: bad argument #2 to 'random' (interval is empty)
[20/07/2008 15:41:48] Warning: [Event::loadScript] Can not load script. data/spells/scripts/custom/death star.lua

Code:
local combat = createCombatObject() 
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) 
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, TRUE) 
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_NONE) 
  
local condition = createConditionObject(CONDITION_PARALYZE) 
setConditionParam(condition, CONDITION_PARAM_TICKS, 50000) 
setCombatCondition(combat, condition) 
  
function getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength) 
local attack = 20 
local skill = getPlayerMagLevel(cid) 
local maxWeaponDamage = (skill * attack) / 20 + attack 
local damage = -((math.random(50, maxWeaponDamage) * attackStrength) / 80) * 2.5 
  
return damage, damage 
end 
  
function sonichoming(param) 
if isCreature(param.cid) == TRUE and param.crc == 1 then 
for abs = param.nxp, param.pxp do 
for coo = param.nyp, param.pyp do 
local pretile = {x = abs, y = coo, z = param.nzp, stackpos = 255} 
local thing = getThingfromPos(pretile) 
if isCreature(thing.uid) == TRUE and thing.uid ~= param.cid [B]and getTilePzInfo(pretile) == FALSE[/B] then 
crcb = 1 
jumps = jumps + 1 
  
local radius = param.radius 
local nodea = getCreaturePosition(param.cid) 
local nodeb = getCreaturePosition(thing.uid) 
  
local nha = {x = nodeb.x, y = nodeb.y - 2, z = nodeb.z, stackpos = 255} 
local sha = {x = nodeb.x, y = nodeb.y + 2, z = nodeb.z, stackpos = 255} 
local wha = {x = nodeb.x - 2, y = nodeb.y, z = nodeb.z, stackpos = 255} 
local eha = {x = nodeb.x + 2, y = nodeb.y, z = nodeb.z, stackpos = 255} 
  
doTeleportThing(param.cid, nodeb, FALSE) 
  
doSendMagicEffect(nodea, CONST_ME_GROUNDSHAKER) 
doSendMagicEffect(nodea, CONST_ME_POFF) 
doSendDistanceShoot(nodea, nodeb, CONST_ANI_ENERGYBALL) 
doSendMagicEffect(nodeb, CONST_ME_STUN) 
doSendDistanceShoot(nodeb, eha, CONST_ANI_ENERGY) 
doSendDistanceShoot(nodeb, wha, CONST_ANI_ENERGY) 
doSendDistanceShoot(nodeb, sha, CONST_ANI_ENERGY) 
doSendDistanceShoot(nodeb, nha, CONST_ANI_ENERGY) 
doSendMagicEffect(eha, CONST_ME_PURPLEENERGY) 
doSendMagicEffect(wha, CONST_ME_PURPLEENERGY) 
doSendMagicEffect(sha, CONST_ME_PURPLEENERGY) 
doSendMagicEffect(nha, CONST_ME_PURPLEENERGY) 
  
var = numberToVariant(thing.uid) 
  
doCombat(param.cid, param.combat, var) 
break 
end 
end 
if crcb == 1 then 
break 
end 
end 
if crcb == 1 and limit > 0 and jumps < limit then 
crcb = 0 
addEvent(sonichoming, param.tbj, param) 
end 
if crcb == 1 and limit == 0 then 
crcb = 0 
addEvent(sonichoming, param.tbj, param) 
end 
end 
end 
  
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, [B]getSpellDamage(cid, weaponSkill, weaponAttack, attackStrength)[/B]) 
  
function onCastSpell(cid, var) 
  
-- >>> Small config -- 
  
local radius = 5 -- Quite self explanatory -- 
limit = 10 -- Limit of homing jumps, 0 = Unlimited -- 
local tbj = 200 -- Time between jumps in miliseconds -- 
  
-- Small config <<< -- 
  
local nodea = getCreaturePosition(cid) 
local nodeb = getCreaturePosition(variantToNumber(var)) 

local nha = {x = nodeb.x, y = nodeb.y - 2, z = nodeb.z, stackpos = 255} 
local sha = {x = nodeb.x, y = nodeb.y + 2, z = nodeb.z, stackpos = 255} 
local wha = {x = nodeb.x - 2, y = nodeb.y, z = nodeb.z, stackpos = 255} 
local eha = {x = nodeb.x + 2, y = nodeb.y, z = nodeb.z, stackpos = 255} 
  
doTeleportThing(cid, nodeb, FALSE) 
  
doSendMagicEffect(nodea, CONST_ME_GROUNDSHAKER) 
doSendMagicEffect(nodea, CONST_ME_POFF) 
doSendDistanceShoot(nodea, nodeb, CONST_ANI_ENERGYBALL) 
doSendMagicEffect(nodeb, CONST_ME_STUN) 
doSendDistanceShoot(nodeb, eha, CONST_ANI_ENERGY) 
doSendDistanceShoot(nodeb, wha, CONST_ANI_ENERGY) 
doSendDistanceShoot(nodeb, sha, CONST_ANI_ENERGY) 
doSendDistanceShoot(nodeb, nha, CONST_ANI_ENERGY) 
doSendMagicEffect(eha, CONST_ME_PURPLEENERGY) 
doSendMagicEffect(wha, CONST_ME_PURPLEENERGY) 
doSendMagicEffect(sha, CONST_ME_PURPLEENERGY) 
doSendMagicEffect(nha, CONST_ME_PURPLEENERGY) 
  
jumps = 1 
  
doCombat(cid, combat, var) 
  
param = { cid = cid, var = var, combat = combat, nxp = nodeb.x - radius, pxp = nodeb.x + radius, nyp = nodeb.y - radius, pyp = nodeb.y + radius, radius = radius, nzp = nodeb.z, crc = 1, tbj = tbj} 
  
addEvent(sonichoming, tbj, param) 
end
Maybe this will work?
Also notice that spell damage part, and see if it works better.

When executing this script, i shooted at a giant spider, and it jumped at a player inside depot.

(I changed back to
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "getSpellDamage")
because it was buggy the version you gave me)
 
Another issue:

picture.php


This happens sometimes.

This is not an repeatly error message, it happens once in a while, and its some players who cries over loosing much lvls and things, even tho they buyed blessings, its not allways working properly.

Any ideas to prevent this? Maybe anyone can improove my bless script and make it a bit more smooth?

Another issue, sometimes it pops up in the console "Error on loading depot for id xxxx".

Any ideas to prevent this?

Anyway, heres the bless script, I guess its pretty standard:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()						npcHandler:onThink()						end

function creatureSayCallback(cid, type, msg)
	--- TODO: bless function in modules.lua
	if(npcHandler.focus ~= cid) then
		return FALSE
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
		npcHandler:say("I can provide you with five blessings... the 'first bless', 'second bless', 'third bless', 'fourth bless' and the 'fifth bless', they 10k each.")
		talkState = 0
	elseif msgcontains(msg, 'first bless') then
		npcHandler:say("Do you want to buy the first blessing for 10000 gold?")
		talkState = 1
	elseif msgcontains(msg, 'second bless') then
		npcHandler:say("Do you want to buy the second blessing for 10000 gold?")
		talkState = 2
	elseif msgcontains(msg, 'third bless') then
		npcHandler:say("Do you want to buy the third blessing for 10000 gold?")
		talkState = 3
	elseif msgcontains(msg, 'fourth bless') then
		npcHandler:say("Do you want to buy the fourth blessing for 10000 gold?")
		talkState = 4
	elseif msgcontains(msg, 'fifth bless') then
		npcHandler:say("Do you want to buy the fifth blessing for 10000 gold?")
		talkState = 5
	elseif talkState > 0 then
		if msgcontains(msg, 'yes') then
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
			elseif TRUE == TRUE then
				if doPlayerRemoveMoney(cid, 10000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					npcHandler:say("You have been blessed by one of the five gods!")
				else
					npcHandler:say("You don't have enough money.")
				end
			else
				npcHandler:say("Your character is bugged, please contact God Almighty and he will fix you.")
			end
		elseif msgcontains(msg, 'no') then
			npcHandler:say("Then not.")
		end
		talkState = 0
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Also errors on console makes the CPU raise a bit, so errors on colsole makes the game more freezy I beleives.
 
This should fix it:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)			 npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)	 npcHandler:onCreatureSay(cid, type, msg) end
function onThink()						 npcHandler:onThink() end
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') then
		selfSay('I have five blessings, the \'first bless\', \'second bless\', \'third bless\', \'fourth bless\' and the \'fifth bless\', they cost 10000 gold coins each.')
	elseif getPlayerPremiumDays(cid) > 0 then
		if msgcontains(msg, 'first bless') then
			selfSay('Do you want to buy the first blessing for 10000 gold?')
			talk_state = 1
		elseif msgcontains(msg, 'second bless') then
			selfSay('Do you want to buy the second blessing for 10000 gold?')
			talk_state = 2
		elseif msgcontains(msg, 'third bless') then
			selfSay('Do you want to buy the third blessing for 10000 gold?')
			talk_state = 3
		elseif msgcontains(msg, 'fourth bless') then
			selfSay('Do you want to buy the fourth blessing for 10000 gold?')
			talk_state = 4
		elseif msgcontains(msg, 'fifth bless') then
			selfSay('Do you want to buy the fifth blessing for 10000 gold?')
			talk_state = 5
		elseif talk_state >= 0 then
			if msgcontains(msg, 'yes') then
				if getPlayerBlessing(cid, talk_state) then
					selfSay('A god has already blessed you with this blessing.')
				else
					if doPlayerRemoveMoney(cid, 10000) == 1 then
						doPlayerAddBlessing(cid, talk_state)
						selfSay('You have been blessed by one of the five gods!')
					else
						selfSay('You don\'t have enough money.')
					end
				end
				talk_state = 0
			elseif msgcontains(msg, 'no') then
				selfSay('Then not.')
				talk_state = 0
			end
		end
	else
		selfSay('You need a premium account to buy \'blessings\', there\'s nothing else you can do here..')
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Znote remember i'm in your team.. just ask me to fix it..
 
I need you'r help Mokerhamer...

I don't know if this is a LUA problem, but I hope you can help me.

Im using The Forgotten Server (TFS), Rev. 1000.

The problem is that when Im fighting with like a minotaur, of course I get the swords (PZ Lock), that it's supposed to be 60 seconds, and when I got the swords, I can logout...
Im fighting the minotaur, and if I want I can logout...

I want my OT to be RPG, that's not cool...
I'll show you some pictures about my problem:

photo1ix5.png



photo2mh5.png



photo3wr0.png



photo4un1.png


If I'am offline in OtLand, and you wanna be smart, message me in my msn: [email protected]

Set player flags to 0 in your database
 
can u help me with the script for arena ?
npc saying
23:37 Halvar: Someone is currently participating in the arena. Please wait your turn.
when i teleported into arena and into telerport to arena it backing me to the enter ...and says too that somone is there but any 1 is there because im alone on the server:S any bug in console..

arena npc.lua
Code:
-- Umby

local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

--  	      masterpos is the location that the player will first be teleported to.   It is TWO squares south of the MIDDLE of the FIRST room       (see screen shot)
local masterpos = {x=32300, y=31154, z=7, stackpos=1}   -- this must match the position in the movement script
local timeLimit = 600   							-- this is the time limit in seconds  (600 = 10 minutes)       this has to match the timeLimit in the Svargrond.lua script aswell.
local arenaCost = {1000, 5000, 10000} 				-- this is the ammount of gp it costs to start the arena  (first, second, third.)
--  you shouldnt need to edit any more of the script.


local stone1pos = {x = masterpos.x-5, y = masterpos.y-2, z = masterpos.z, stackpos = 1}
local stone2pos = {x = masterpos.x-19, y = masterpos.y-2, z = masterpos.z, stackpos = 1}
local stone3pos = {x = masterpos.x-33, y = masterpos.y-2, z = masterpos.z, stackpos = 1}
local stone4pos = {x = masterpos.x-47, y = masterpos.y-2, z = masterpos.z, stackpos = 1}
local stone5pos = {x = masterpos.x-41, y = masterpos.y-15, z = masterpos.z, stackpos = 1}
local stone6pos = {x = masterpos.x-27, y = masterpos.y-15, z = masterpos.z, stackpos = 1}
local stone7pos = {x = masterpos.x-13, y = masterpos.y-15, z = masterpos.z, stackpos = 1}
local stone8pos = {x = masterpos.x-21, y = masterpos.y-28, z = masterpos.z, stackpos = 1}
local stone9pos = {x = masterpos.x-35, y = masterpos.y-28, z = masterpos.z, stackpos = 1}
local stone10pos = {x = masterpos.x-29, y = masterpos.y-41, z = masterpos.z, stackpos = 1}
local npcpos = {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z}
local playerID = getGlobalStorageValue(9000)

function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureTurn(creature)
end
local function arenaOver(cid)        --  if the player leaves, dies, logs out, wins, or is teleported out:
	setGlobalStorageValue(3000,-1)       --  if the arena is in use or not
	setGlobalStorageValue(9000,-1)       --  if the arena is in use or not
	arenaStatus = 0
	arenaStatus1 = 0
	setPlayerStorageValue(cid,5029,-1)   -- reset the player arena status (hard med easy) 
	setPlayerStorageValue(cid,3002,-1)   -- if the player is still in the arena or not
	setPlayerStorageValue(cid,9000,-1)   -- reset the player ID
	focus = 0
	talk_start = 0
end
local function arenaStartFirstLvl(cid)
	setGlobalStorageValue(3000,1)      --  if the arena is in use or not  
	setPlayerStorageValue(cid,5029,1)      -- set the player arena status (hard med easy) 
	setPlayerStorageValue(cid,3002,1)      -- if the player is still in the arena or not
	doTeleportThing(cid, {x=masterpos.x+24,y=masterpos.y-1,z=masterpos.z})
	arenaStatus = arenaStatus1
end
local function arenaStartSecondLvl(cid)    
	setGlobalStorageValue(3000,1)      --  if the arena is in use or not  
	setPlayerStorageValue(cid,5029,2)      -- set the player arena status (hard med easy) 
	setPlayerStorageValue(cid,3002,1)      -- if the player is still in the arena or not
	doTeleportThing(cid, {x = masterpos.x+24, y = masterpos.y-1, z = masterpos.z})  
	arenaStatus = arenaStatus1
end
local function arenaStartThirdLvl(cid)   
	setGlobalStorageValue(3000,1)      --  if the arena is in use or not  
	setPlayerStorageValue(cid,5029,3)      -- set the player arena status (hard med easy) 
	setPlayerStorageValue(cid,3002,1)      -- if the player is still in the arena or not 
	doTeleportThing(cid, {x = masterpos.x+24, y = masterpos.y-1, z = masterpos.z})
	arenaStatus = arenaStatus1
end
local function doCheckStone(stonepos)
	local stone = getThingfromPos(stonepos)
		if stone.itemid ~= 1354 then
			doCreateItem(1354,1,stonepos)
		end
			if stone.actionid == 6000 then
				doSetItemActionId(stone.uid,5999)
			end
end
function onCreatureDisappear(cid, pos)
if getGlobalStorageValue(3000) ~= 1 then
	arenaStatus = 0
	arenaStatus1 = 0
	setPlayerStorageValue(cid,5029,-1)   -- reset the player arena status (hard med easy) 
	setPlayerStorageValue(cid,3002,-1)   -- if the player is still in the arena or not
	focus = 0
end
end
function onCreatureSay(cid, type, msg)

msg = string.lower(msg)
cname = getCreatureName(cid)

  	if (msgcontains(msg, 'hi') and (focus == 0) and getDistanceToCreature(cid) < 4 and getGlobalStorageValue(3000) ~= 1) then
			selfSay('Hello competitor! Do you want to fight in the arena or shall I explain the rules first?')
			talk_state = 0
			arenaStatus = 0
			focus = cid	
			talk_start = os.clock()
			setGlobalStorageValue(3000,-1)
			setPlayerStorageValue(cid,5030,-1)  
			setPlayerStorageValue(cid,5029,-1)   -- reset the player arena status (hard med easy) 
			setPlayerStorageValue(cid,3002,-1)   -- if the player is still in the arena or not
			setPlayerStorageValue(cid,2998,-1)    -- resets so that the time limit will start
			setPlayerStorageValue(cid,9000,-1)   -- playerID reset so no one has the same one when they start (unless you win the lottery often)
			setPlayerStorageValue(cid,2999,-1)   -- this makes sure the player isnt tped into the arena twice by being an idiot and stepping on the start teleport more then once in 0.5 seconds  (might sound confusing)
  	elseif (msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 and getGlobalStorageValue(3000) == 1 and getPlayerStorageValue(cid,5029) == 1 and getPlayerStorageValue(cid,3002) > 0) then
	  	setPlayerStorageValue(cid,5029,-1)   -- reset the player arena status (hard med easy) 
		setPlayerStorageValue(cid,3002,-1)   -- if the player is still in the arena or not
		selfSay('Someone is currently participating in the arena.  Please wait your turn.')	
	elseif (msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 and getGlobalStorageValue(3000) == 1) then
		selfSay('Someone is currently participating in the arena.  Please wait your turn.')	
	elseif (focus == cid and getPlayerStorageValue(cid,3002) < 0) then
		talk_start = os.clock()	
		if msgcontains(msg, 'rules') or msgcontains(msg, 'rule') or msgcontains(msg, 'first') then	
			selfSay('What do you want to know? Something about the three different difficulties, the general rules or the prices? Maybe you also want to know what happens when you die?')			
		elseif msgcontains(msg, 'die') or msgcontains(msg, 'death') then	
			selfSay('It would be better not to die! In every pit there is an emergency exit to the south. If you die in a pit... well... your corpse and backpack are gone, so enter at your own risk.')			
		elseif msgcontains(msg, 'different') or msgcontains(msg, 'difficulties') or msgcontains(msg, 'level') or msgcontains(msg, 'lvl') then	
			selfSay('There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.')			
		elseif talk_state == 0 and (msgcontains(msg, 'greenhorn') or msgcontains(msg, 'green') or msgcontains(msg, 'horn')) then	
			selfSay('That is the easiest way in our arena. The fee is 1000 gold. We were setting this up for of our children to challenge some easy monsters and train them for the future.')			
		elseif talk_state == 0 and (msgcontains(msg, 'scrapper') or msgcontains(msg, 'scrap')) then	
			selfSay('The most common difficulty for us. The fee is 5000 gold. So if you are experienced in fighting middle class monsters this is your challenge!')			
		elseif talk_state == 0 and (msgcontains(msg, 'warlord') or msgcontains(msg, 'war') or msgcontains(msg, 'lord')) then	
			selfSay('Only the strongest among us will take this challenge. The fee is 10000 gold. If you pass that I promise you the respect of all citizens here. You will be a hero!')			
		elseif msgcontains(msg, 'price') or msgcontains(msg, 'prices') or msgcontains(msg, 'cost') or msgcontains(msg, 'offer') then	
			selfSay('The fee is 1,000/5,000/10,000 gold for one try. Remember that if you die, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack.')			
		elseif msgcontains(msg, 'general') then	
			selfSay('Basically you pay me a fee, and you are sent into an arena with 10 different stages.  If you succeed you will be rewarded accordingly.')	
		elseif talk_state == 1 and (msgcontains(msg, 'greenhorn') or msgcontains(msg, 'green') or msgcontains(msg, 'horn')) then
			if getPlayerStorageValue(cid,3001) < 2 then	
				selfSay('The fee is 1,000 gold for one try. Remember that if you die, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack. Do you really want to participate in the arena in the low difficulty?')				
				arenaStatus1 = 1				
				doCheckStone(stone1pos)
				doCheckStone(stone2pos)
				doCheckStone(stone3pos)
				doCheckStone(stone4pos)
				doCheckStone(stone5pos)
				doCheckStone(stone6pos)
				doCheckStone(stone7pos)
				doCheckStone(stone8pos)
				doCheckStone(stone9pos)
				doCheckStone(stone10pos)		
			elseif getPlayerStorageValue(cid,3001) == 2 or getPlayerStorageValue(cid,3001) == 3 then
				selfSay('You have already completed the arena on this difficulty.')		
			elseif getPlayerStorageValue(cid,3001) == 4 then
				selfSay('You may not enter the arena after finishing it.')
			end			
		elseif talk_state == 1 and (msgcontains(msg, 'scrapper') or msgcontains(msg, 'scrap')) then	
			if getPlayerStorageValue(cid,3001) == -1 then
				selfSay('You have to complete the \'Greenhorn\' difficulty before you may attempt the \'Scrapper\' difficulty.')
			elseif getPlayerStorageValue(cid,3001) == 3 then
				selfSay('You have already completed the arena on this difficulty.')		
			elseif getPlayerStorageValue(cid,3001) == 4 then
				selfSay('You may not enter the arena after finishing it.')
			elseif getPlayerStorageValue(cid,3001) == 2 then	
				selfSay('The fee is 5,000 gold for one try. Remember that if you die, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack. Do you really want to participate in the arena in the medium difficulty?')				
				arenaStatus1 = 2				
				doCheckStone(stone1pos)
				doCheckStone(stone2pos)
				doCheckStone(stone3pos)
				doCheckStone(stone4pos)
				doCheckStone(stone5pos)
				doCheckStone(stone6pos)
				doCheckStone(stone7pos)
				doCheckStone(stone8pos)
				doCheckStone(stone9pos)
				doCheckStone(stone10pos)					
			end			
		elseif talk_state == 1 and (msgcontains(msg, 'warlord') or msgcontains(msg, 'war') or msgcontains(msg, 'lord')) then
			if getPlayerStorageValue(cid,3001) == -1 then
				selfSay('You have to complete the \'Greenhorn\' difficulty before you may attempt the \'Warlord\' difficulty.')
			elseif getPlayerStorageValue(cid,3001) == 2 then
				selfSay('You have to complete the \'Scrapper\' difficulty before you may attempt the \'Warlord\' difficulty.')	
			elseif getPlayerStorageValue(cid,3001) == 4 then
				selfSay('You may not enter the arena after finishing it.')
			elseif getPlayerStorageValue(cid,3001) == 3 then	
				selfSay('The fee is 10,000 gold for one try. Remember that if you die, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack. Do you really want to participate in the arena in the high difficulty?')				
				arenaStatus1 = 3				
				doCheckStone(stone1pos)
				doCheckStone(stone2pos)
				doCheckStone(stone3pos)
				doCheckStone(stone4pos)
				doCheckStone(stone5pos)
				doCheckStone(stone6pos)
				doCheckStone(stone7pos)
				doCheckStone(stone8pos)
				doCheckStone(stone9pos)
				doCheckStone(stone10pos)						
			end		
		elseif msgcontains(msg, 'fight') or msgcontains(msg, 'start') or msgcontains(msg, 'begin') then	
				selfSay('So you agree to the rules and want to participate in the challenge? Which difficulty do you choose, Greenhorn, Scrapper or Warlord?')	
				talk_state = 1
		elseif msgcontains(msg, 'no') then	
			selfSay('Well get back to me when you\'d like to attempt the arena.')		
			talk_state = 0
		elseif msgcontains(msg, 'bye') then	
			selfSay('See ya next time.')		
			focus = 0
			talk_state = 0
			talk_start = 0
		elseif talk_state == 1 and msgcontains(msg, 'yes') then	
			if arenaStatus1 == 1 then  --first
				if (doPlayerRemoveMoney(focus, arenaCost[1]) == TRUE) then	
					selfSay('As you wish!')	
					talk_state = 0						
					arenaStartFirstLvl(focus) 						
					setGlobalStorageValue(3001,-1) -- this will turn to 1 and make the NPC tp the player in when they step on the entrance TP					
					local rand = math.random(1, 15000)  -- this will make the player unique hopefully
					setGlobalStorageValue(9000,rand) 
					setPlayerStorageValue(cid,9000,(getGlobalStorageValue(9000))) -- i cant believe it was so easy and i wasted 3 days
				else
					selfSay('You dont have enough gold to attempt this difficulty.')
					talk_state = 0				
				end		
			elseif arenaStatus1 == 2 then  --second
				if (doPlayerRemoveMoney(focus, arenaCost[2]) == TRUE) then
					selfSay('As you wish!')	
					talk_state = 0		
					arenaStartSecondLvl(focus) 
					setGlobalStorageValue(3001,-1) -- this will turn to 1 and make the NPC tp the player in when they step on the entrance TP			
					local rand = math.random(1, 15000)  -- this will make the player unique hopefully
					setGlobalStorageValue(9000,rand) 
					setPlayerStorageValue(cid,9000,(getGlobalStorageValue(9000))) -- i cant believe it was so easy and i wasted 3 days
				else
					selfSay('You dont have enough gold to attempt this difficulty.')
					talk_state = 0				
				end		
			elseif arenaStatus1 == 3 then  --third
				if (doPlayerRemoveMoney(focus, arenaCost[3]) == TRUE) then
					selfSay('As you wish!')	
					talk_state = 0		
					arenaStartThirdLvl(focus)
					setGlobalStorageValue(3001,-1) -- this will turn to 1 and make the NPC tp the player in when they step on the entrance TP			
					local rand = math.random(1, 15000)  -- this will make the player unique hopefully
					setGlobalStorageValue(9000,rand) 
					setPlayerStorageValue(cid,9000,(getGlobalStorageValue(9000))) -- i cant believe it was so easy and i wasted 3 days
				else
					selfSay('You dont have enough gold to attempt this difficulty.')	
					talk_state = 0			
				end				
			end		
		end
	end
end
function onThink()
	doNpcSetCreatureFocus(focus)
	  if focus > 0 then
		if (getGlobalStorageValue(3001) == 1 and getPlayerStorageValue(focus,5030) == 1) then  -- this is going to be what teleports the player into the arena to make sure that no one gets in without the NPC's focus      also makes sure the player stepped on the teleport and not someone else
			doTeleportThing(focus, {x = masterpos.x, y = masterpos.y, z = masterpos.z})
			doSendMagicEffect({x = masterpos.x, y = masterpos.y, z = masterpos.z},10)	
			setGlobalStorageValue(3001,-1)  
			setPlayerStorageValue(focus,5030,-1)  				
	
		elseif (getPlayerStorageValue(focus,3002) == 1 and (os.clock() - talk_start) > timeLimit) then -- player ran out of time while in the arena 
			doTeleportThing(focus, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})
			doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)
			doCheckStone(stone1pos)
			doCheckStone(stone2pos)
			doCheckStone(stone3pos)
			doCheckStone(stone4pos)
			doCheckStone(stone5pos)
			doCheckStone(stone6pos)
			doCheckStone(stone7pos)
			doCheckStone(stone8pos)
			doCheckStone(stone9pos)
			doCheckStone(stone10pos)
			doPlayerSendTextMessage(focus, 22, "Time is up!  Sorry, you took too long.  Thanks and Good luck next time!")
			arenaOver(focus)
		elseif (getGlobalStorageValue(3000) ~= 1 and arenaStatus ~= nil and arenaStatus > 0) then		-- this is a backup and will make sure to set the focus to 0 after the player completes the arena.
			doCheckStone(stone1pos)
			doCheckStone(stone2pos)
			doCheckStone(stone3pos)
			doCheckStone(stone4pos)
			doCheckStone(stone5pos)
			doCheckStone(stone6pos)
			doCheckStone(stone7pos)

			doCheckStone(stone8pos)
			doCheckStone(stone9pos)
			doCheckStone(stone10pos)
			arenaOver(focus)
		elseif (getGlobalStorageValue(3000) == 1 and getPlayerByName(getPlayerName(focus)) == 0) then  -- player must have logged out while in the arena
			doCheckStone(stone1pos)
			doCheckStone(stone2pos)
			doCheckStone(stone3pos)
			doCheckStone(stone4pos)
			doCheckStone(stone5pos)
			doCheckStone(stone6pos)
			doCheckStone(stone7pos)
			doCheckStone(stone8pos)
			doCheckStone(stone9pos)
			doCheckStone(stone10pos)
			setGlobalStorageValue(3000,-1)       --  if the arena is in use or not
			arenaStatus = 0
			arenaStatus1 = 0
			focus = 0
		elseif (arenaStatus > 0 and getPlayerStorageValue(focus, 3002) == -1) then	-- this is a backup		
			doCheckStone(stone1pos)
			doCheckStone(stone2pos)
			doCheckStone(stone3pos)
			doCheckStone(stone4pos)
			doCheckStone(stone5pos)
			doCheckStone(stone6pos)
			doCheckStone(stone7pos)
			doCheckStone(stone8pos)
			doCheckStone(stone9pos)
			doCheckStone(stone10pos)
			arenaOver(focus)
		elseif (getGlobalStorageValue(3000) == 1 and (((npcpos.x-getPlayerPosition(focus).x) > 85) or ((npcpos.x-getPlayerPosition(focus).x) < -30) or ((npcpos.y-getPlayerPosition(focus).y) > 50) or ((npcpos.y-getPlayerPosition(focus).y) < -13) or (getPlayerPosition(focus).z ~= npcpos.z))) then    --  player must have been teleported out ( will not remove the monster if u tp the player out so dont)
			doCheckStone(stone1pos)
			doCheckStone(stone2pos)
			doCheckStone(stone3pos)
			doCheckStone(stone4pos)
			doCheckStone(stone5pos)
			doCheckStone(stone6pos)
			doCheckStone(stone7pos)
			doCheckStone(stone8pos)
			doCheckStone(stone9pos)
			doCheckStone(stone10pos)
		end  
	end
end
Svargrond login.lua <movevents>
Code:
-- Umby



-- masterpos is the location that the player will first be teleported to. It is TWO squares south of the MIDDLE of the FIRST room (see screen shot)

local masterpos = {x=32300, y=31154, z=7, stackpos=1} -- this must match the position in the NPC script

-- you shouldnt need to edit any more of the script.



local stone1pos = {x = masterpos.x-5, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone2pos = {x = masterpos.x-19, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone3pos = {x = masterpos.x-33, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone4pos = {x = masterpos.x-47, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone5pos = {x = masterpos.x-41, y = masterpos.y-15, z = masterpos.z, stackpos = 1}

local stone6pos = {x = masterpos.x-27, y = masterpos.y-15, z = masterpos.z, stackpos = 1}

local stone7pos = {x = masterpos.x-13, y = masterpos.y-15, z = masterpos.z, stackpos = 1}

local stone8pos = {x = masterpos.x-21, y = masterpos.y-28, z = masterpos.z, stackpos = 1}

local stone9pos = {x = masterpos.x-35, y = masterpos.y-28, z = masterpos.z, stackpos = 1}

local stone10pos = {x = masterpos.x-29, y = masterpos.y-41, z = masterpos.z, stackpos = 1}



function onStepIn(cid, item, pos)

playerID = getGlobalStorageValue(9000)

local function doCheckStoneId(stonepos)

local stone = getThingfromPos(stonepos)

if stone.itemid ~= 1354 then

doCreateItem(1354,1,stonepos)

end

if stone.actionid == 6000 then

doSetItemActionId(stone.uid,5999)

end

end



local function arenaOver(cid) -- if the player leaves, dies, logs out, wins, or is teleported out:

setPlayerStorageValue(cid,5029,-1) -- reset the player arena status (hard med easy)

setPlayerStorageValue(cid,3002,-1) -- player should be in the arena or not

setPlayerStorageValue(cid,2999,-1) -- dont mind this (addEvent)

end

if (item.actionid >= 3001 and item.actionid <= 3010) then

if isPlayer(cid) == TRUE then --make more efficient with (and) later

if getPlayerAccess(cid) < 3 then -- makes sure the player is not a monster/GM

if (getPlayerStorageValue(cid, 3002) ~= 1 or getGlobalStorageValue(3000) ~= 1) then -- player is not supposed to be in arena and must have logged in

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

arenaOver(cid)

elseif (getPlayerStorageValue(cid, 9000) ~= playerID) then -- this means the player probably logged off and waited for someone else to start the arena, then logged in. (its gotta be flawless!)

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doPlayerSendTextMessage(cid, 22, "You are not supposed to be in the arena at the moment.")

arenaOver(cid)

end

end

elseif (isCreature(cid) == TRUE and getGlobalStorageValue(3000) ~= 1) then -- if the timer runs out this will remove the creature

doCreatureAddHealth(cid,-10000)

doCheckStoneId(stone1pos)

doCheckStoneId(stone2pos)

doCheckStoneId(stone3pos)

doCheckStoneId(stone4pos)

doCheckStoneId(stone5pos)

doCheckStoneId(stone6pos)

doCheckStoneId(stone7pos)

doCheckStoneId(stone8pos)

doCheckStoneId(stone9pos)

doCheckStoneId(stone10pos)

end

end

end
Svargrond.lua <movements>
Code:
-- Svargrond Arena by Arthur1408



-- masterpos É A LOCAçao do primeiro lugar que o player será teletransportado. It is TWO squares south of the MIDDLE of the FIRST room (see screen shot)

local masterpos ={x=32300, y=31154, z=7, stackpos=1} -- this must match the position in the NPC script

local timeLimit = 600 -- this is the time limit in seconds (600 = 10 minutes) this has to match the timeLimit in the arenaNPC.lua script aswell.

-- you shouldnt need to edit any more of the script.



local stone1pos = {x = masterpos.x-5, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone2pos = {x = masterpos.x-19, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone3pos = {x = masterpos.x-33, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone4pos = {x = masterpos.x-47, y = masterpos.y-2, z = masterpos.z, stackpos = 1}

local stone5pos = {x = masterpos.x-41, y = masterpos.y-15, z = masterpos.z, stackpos = 1}

local stone6pos = {x = masterpos.x-27, y = masterpos.y-15, z = masterpos.z, stackpos = 1}

local stone7pos = {x = masterpos.x-13, y = masterpos.y-15, z = masterpos.z, stackpos = 1}

local stone8pos = {x = masterpos.x-21, y = masterpos.y-28, z = masterpos.z, stackpos = 1}

local stone9pos = {x = masterpos.x-35, y = masterpos.y-28, z = masterpos.z, stackpos = 1}

local stone10pos = {x = masterpos.x-29, y = masterpos.y-41, z = masterpos.z, stackpos = 1}



local function doCheckStoneId(stonepos)

local stone = getThingfromPos(stonepos)

if stone.itemid ~= 1354 then

doCreateItem(1354,1,stonepos)

end

if stone.actionid == 6000 then

doSetItemActionId(stone.uid,5999)

end

end

local function doChange(cid, pos, creature, tpos)

local stone = getThingfromPos(pos)

doSetItemActionId(stone.uid,6000)

local pos = getThingPos(stone.uid)

monster = doSummonCreature(creature, pos)

doTeleportThing(cid,tpos)

doSendAnimatedText(tpos,"Fight!",198)

doSendMagicEffect(pos,10)

end

function onStepIn(cid, item, pos)

playerID = getGlobalStorageValue(9000)



local function arenaOver(cid) -- if the player leaves, dies, logs out, wins, or is teleported out:

setGlobalStorageValue(3000,-1) -- if the arena is in use or not

setPlayerStorageValue(cid,5029,-1) -- reset the player arena status (hard med easy)

setPlayerStorageValue(cid,3002,-1) -- if the player is still in the arena or not

setPlayerStorageValue(cid,2999,-1) -- dont mind this (addEvent)

end

local function doCheckLvl(cid, storage)

if getPlayerStorageValue(cid, storage) == 1 then -- easy

monsters = {"Frostfur", "Bloodpaw", "Bovinus", "Achad", "Colerian the Barbarian", "The Hairy One", "Axeitus Headbanger", "Rocky", "Cursed Gladiator", "Orcus the Cruel"}

elseif getPlayerStorageValue(cid, storage) == 2 then -- medium

monsters = {"Avalanche", "Kreebosh the Exile", "The Dark Dancer", "The Hag", "Slim", "Grimgor Guteater", "Drasilla", "Spirit of Earth", "Spirit of Water", "Spirit of Fire"}

elseif getPlayerStorageValue(cid, storage) == 3 then -- hard

monsters = {"Webster", "Darakan the Executioner", "Norgle Glacierbeard", "The Pit Lord", "Svoren The Mad", "The Masked Marauder", "Gnorre Chyllson", "Fallen Mooh'Tah Master Ghar", "Deathbringer", "The Obliverator"}

end

end

local function doCheckStone(stonepos)

local stone = getThingfromPos(stonepos)

if stone.actionid ~= 6000 and stone.itemid == 1354 then

return 0

elseif stone.actionid == 6000 or stone.itemid ~= 1354 then

return 1

end

end

local function roomBusy(cid, pos)

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doSendMagicEffect(pos,10)

doPlayerSendTextMessage(cid, 22, "The arena is in use right now, wait your turn!")

end



doCheckLvl(cid, 5029)



if item.actionid == 2002 then

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doCheckStoneId(stone1pos)

doCheckStoneId(stone2pos)

doCheckStoneId(stone3pos)

doCheckStoneId(stone4pos)

doCheckStoneId(stone5pos)

doCheckStoneId(stone6pos)

doCheckStoneId(stone7pos)

doCheckStoneId(stone8pos)

doCheckStoneId(stone9pos)

doCheckStoneId(stone10pos)

arenaOver(cid)

doCreatureAddHealth(monster,-10000) -- might give an error if someone leaves after the monster is dead

elseif item.actionid == 2003 then -- tp leading from the reward room to the NPC area

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

elseif item.actionid == 2004 and doCheckStone(stone1pos) == 0 then -- from the npc room, teleports you to room one

if (getGlobalStorageValue(3000) == 1 and hasAddedEvent ~= 1) then

local passArgs = {cid=cid, npos=npos}

setPlayerStorageValue(cid,5030,1)

setGlobalStorageValue(3001,1)

local npos = masterpos

if getPlayerStorageValue(cid,2999) == -1 then

addEvent(after1second,1000,passArgs)

setPlayerStorageValue(cid,2999,1)

end

else -- player was tped past the exp doors or logged in there or something

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doPlayerSendTextMessage(cid, 22, "Please talk to the NPC before entering the arena.")

setPlayerStorageValue(cid,5029,-1) -- reset the player arena status (hard med easy)

setPlayerStorageValue(cid,3002,-1) -- if the player is still in the arena or not

end

elseif item.actionid == 2005 and doCheckStone(stone2pos) == 0 then -- this takes you to room 2

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-14, y = masterpos.y, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[2], npos)

if getThingfromPos(stone1pos) ~= 1354 then

doCreateItem(1354,1,stone1pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2006 and doCheckStone(stone3pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-28, y = masterpos.y, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[3], npos)

if getThingfromPos(stone2pos) ~= 1354 then

doCreateItem(1354,1,stone2pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2007 and doCheckStone(stone4pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-42, y = masterpos.y, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[4], npos)

if getThingfromPos(stone3pos) ~= 1354 then

doCreateItem(1354,1,stone3pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2008 and doCheckStone(stone5pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-36, y = masterpos.y-13, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[5], npos)

if getThingfromPos(stone4pos) ~= 1354 then

doCreateItem(1354,1,stone4pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2009 and doCheckStone(stone6pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-22, y = masterpos.y-13, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[6], npos)

if getThingfromPos(stone5pos) ~= 1354 then

doCreateItem(1354,1,stone5pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2010 and doCheckStone(stone7pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-8, y = masterpos.y-13, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[7], npos)

if getThingfromPos(stone6pos) ~= 1354 then

doCreateItem(1354,1,stone6pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2011 and doCheckStone(stone8pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-16, y = masterpos.y-26, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[8], npos)

if getThingfromPos(stone7pos) ~= 1354 then

doCreateItem(1354,1,stone7pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2012 and doCheckStone(stone9pos) == 0 then

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-30, y = masterpos.y-26, z = masterpos.z}

local mpos = {x=npos.x, y=npos.y-4, z=npos.z}

doChange(cid, mpos, monsters[9], npos)

if getThingfromPos(stone8pos) ~= 1354 then

doCreateItem(1354,1,stone8pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2013 and doCheckStone(stone10pos) == 0 then -- leads to room ten

if getPlayerStorageValue(cid,9000) == playerID then

local npos = {x = masterpos.x-24, y = masterpos.y-39, z = masterpos.z}

local mpos = {x = npos.x, y = npos.y-4, z = npos.z}

doChange(cid, mpos, monsters[10], npos)

if getThingfromPos(stone9pos) ~= 1354 then

doCreateItem(1354,1,stone9pos)

end

else

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

setPlayerStorageValue(cid,5029,-1)

setPlayerStorageValue(cid,3002,-1)

setPlayerStorageValue(cid,2999,-1)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

end

elseif item.actionid == 2014 then

local npos = {x = masterpos.x+12, y = masterpos.y-20, z = masterpos.z-1} -- exit

if getThingfromPos(stone10pos) ~= 1354 then

doCreateItem(1354,1,stone10pos)

end

if getPlayerStorageValue(cid,5029) == 1 then -- easy mode

setPlayerStorageValue(cid,3001,2)

elseif getPlayerStorageValue(cid,5029) == 2 then -- medium mode

setPlayerStorageValue(cid,3001,3)

elseif getPlayerStorageValue(cid,5029) == 3 then -- hard mode

setPlayerStorageValue(cid,3001,4)

end

doTeleportThing(cid, npos)

doPlayerSay(cid, "Respect and honor to you, champion!", 16)

doSendMagicEffect(npos,10)

arenaOver(cid)

elseif item.actionid == 3011 then -- room to the right of the NPC this will start the time limit

if isPlayer(cid) == TRUE then --make more efficient with (and) later

if getPlayerAccess(cid) < 3 then -- makes sure the player is not a monster/GM

if getPlayerStorageValue(cid, 3002) ~= 1 or getGlobalStorageValue(3000) ~= 1 then

doTeleportThing(cid, {x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doPlayerSendTextMessage(cid, 22, "You may not log into the arena.")

arenaOver(cid)

elseif getPlayerStorageValue(cid, 2998) ~= 1 then

uniqueID = getGlobalStorageValue(9000)

local passArgs = {cid = cid, monster = monster, uniqueID = uniqueID}

addEvent(afterTimeLimit,timeLimit,passArgs)

setPlayerStorageValue(cid,2998,1)

end

end

end



elseif doCheckStone(stone10pos) == 1 then -- confused yet?

roomBusy(cid, pos)

elseif doCheckStone(stone9pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone8pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone7pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone6pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone5pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone4pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone3pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone2pos) == 1 then

roomBusy(cid, pos)

elseif doCheckStone(stone1pos) == 1 then

roomBusy(cid, pos)

end

end

function onAddItem(moveitem, tileitem, pos)



local function doRemoveStone(stonepos)

repeat

local stone1 = getThingfromPos(stonepos)

if stone1.itemid == 1354 then

doRemoveItem(stone1.uid,1)

end

until stone1.itemid ~= 1354

end



local function doCheckBody(moveitem, stonepos, monster)

local stone = getThingfromPos(stonepos)

if (moveitem.itemid == 6324 and stone.itemid == 1354) then

doRemoveStone(stonepos)

doRemoveItem(moveitem.uid,1)

doSendMagicEffect(stonepos,2)

if getGlobalStorageValue(3000) == 1 then

doSendAnimatedText(pos,"Victory!",198)

else

doCheckStoneId(stone1pos)

doCheckStoneId(stone2pos)

doCheckStoneId(stone3pos)

doCheckStoneId(stone4pos)

doCheckStoneId(stone5pos)

doCheckStoneId(stone6pos)

doCheckStoneId(stone7pos)

doCheckStoneId(stone8pos)

doCheckStoneId(stone9pos)

doCheckStoneId(stone10pos)

end

elseif moveitem.itemid == 3058 or moveitem.itemid == 3065 then

--doRemoveItem(moveitem.uid,1) -- server needs time to add the bp and shit (i guess) to the body so we use addEvent to do it 1 second later otherwise - crash

local dPos = getThingPos(moveitem.uid)

local passArgs = {dPos = dPos}

addEvent(removeCorpse,1000,passArgs)

doCreatureAddHealth(monster,-10000)

--local pos = getThingPos(monster)

doCheckStoneId(stone1pos)

doCheckStoneId(stone2pos)

doCheckStoneId(stone3pos)

doCheckStoneId(stone4pos)

doCheckStoneId(stone5pos)

doCheckStoneId(stone6pos)

doCheckStoneId(stone7pos)

doCheckStoneId(stone8pos)

doCheckStoneId(stone9pos)

doCheckStoneId(stone10pos)

setGlobalStorageValue(3000,-1) -- if the arena is in use or not

doSetItemActionId(stone.uid,5999)

end

end

if tileitem.actionid == 3001 then

doCheckBody(moveitem, stone1pos, monster)

elseif tileitem.actionid == 3002 then

doCheckBody(moveitem, stone2pos, monster)

elseif tileitem.actionid == 3003 then

doCheckBody(moveitem, stone3pos, monster)

elseif tileitem.actionid == 3004 then

doCheckBody(moveitem, stone4pos, monster)

elseif tileitem.actionid == 3005 then

doCheckBody(moveitem, stone5pos, monster)

elseif tileitem.actionid == 3006 then

doCheckBody(moveitem, stone6pos, monster)

elseif tileitem.actionid == 3007 then

doCheckBody(moveitem, stone7pos, monster)

elseif tileitem.actionid == 3008 then

doCheckBody(moveitem, stone8pos, monster)

elseif tileitem.actionid == 3009 then

doCheckBody(moveitem, stone9pos, monster)

elseif tileitem.actionid == 3010 then

doCheckBody(moveitem, stone10pos, monster)

end

end



function after1second(passArgs) -- this will check the players position after the NPC has checked its storages and decided to tp it or not (i know its inefficient but it works and is flawless)

local Ppos = getPlayerPosition(passArgs.cid)

if (Ppos.x > masterpos.x+22) then -- player was not teleported by the NPC and doesnt need to be in that area.

doTeleportThing(passArgs.cid,{x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z})

doSendMagicEffect({x = masterpos.x+21, y = masterpos.y-2, z = masterpos.z},10)

doPlayerSendTextMessage(passArgs.cid, 22, "Please talk to the NPC before entering the arena.")

else

local stone = getThingfromPos(stone1pos)

doSetItemActionId(stone.uid,6000)

local pos = getThingPos(stone.uid)

monster = doSummonCreature(monsters[1], {x=pos.x+5, y=pos.y-2, z=pos.z})

doSendAnimatedText(npos,"Fight!",198)

doSendMagicEffect({x=pos.x+5, y=pos.y-2, z=pos.z},10)

end

end



function removeCorpse(passArgs)

local dPos = passArgs.dPos

local body = getThingfromPos({x=dPos.x, y=dPos.y, z=dPos.z, stackpos=255}) -- FINALLY

doRemoveItem(body.uid,1)

end



function afterTimeLimit(passArgs)

doCreatureAddHealth(passArgs.monster,-10000)

end
 
Last edited:
The script should : It's for a tower quest, making so if you say the right answer to the riddle, he asks you if you want to proceed next stage, the person says yes, and he teleports u to the coordinates I selected.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
-- OTServ event handling functions end


-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'Wind'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ah, so you do know your riddles! Wind is the correct answer, do you wish to proceed to the next stage!?'})
	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 15, cost = 0, destination = {x=1027, y=1360, z=4} })
	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'You are missing out on the mysteries of the Tower of Darkness.'})

keywordHandler:addKeyword({'Riddle'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Try to solve the riddle! If if the answer is right, I will teleport you to the next stage.'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

Weird, but there is no error, when I actually talk to the NPC.

The npc goes "Welcome -player- I have been expecting you!"
I say "Wind" for the answer of the riddle, and nothing seems to happen. I'm new to LUA so please bare with me , if it's completely wrong.

I use TFS Mystic Spirit 0.2.14 P5 , I guess the most recent one.

Please help, I have 3 other NPC's like this, in other stages of the quest, so whatever you guys help me with here, I'll apply to the other npc's as well.
 
morker how to do that if the monster in arena is killed stone is transform into teleport?
or if u kill monster the stone will move in right >>
or just the stone will dissapear
 
Last edited:
Mokerhamer Do you have any idea why characters on my ot sometimes randomly get reset to lvl 1 when they die?... it doesnt happen all the time just its random and i dono whats wrong. Lil assistance please :>
 
Mokerhamer Do you have any idea why characters on my ot sometimes randomly get reset to lvl 1 when they die?... it doesnt happen all the time just its random and i dono whats wrong. Lil assistance please :>

Nice 3-year bump brah.
 
Back
Top