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

If anyone needs help with a lua script just request it here.

LuaScripter

Scripter -Lua-
Joined
Jan 16, 2012
Messages
40
Reaction score
1
I will respond to the request as soon as possible, I will fix the problem. The best part about it is that this service is free for you! :D
 
Help!

Hi LuaScripter, I hope you can help me with my script...

I have this problem with all of my NPCs, and would really like to fix it. I am putting the simplest NPC I got.

The problem is as follows:

If I run the code shown below, the NPC is able to do everything specified in this code, EXCEPT for what is inside the onThinkCallback() function. So basically the NPC does not talk or say any of the two messages specified. It just waits for a player to normally greet him.

Now, if I change that function to onThink() (just removing the "Callback" part), the NPC is now able to talk and display any of the two messages, BUT now the NPC does not seem to execute the npcHandler messages for MESSAGE_WALKAWAY and MESSAGE_IDLETIMEOUT. Basically, the player can walk far away from the NPC without saying "bye", and the NPC will stay focused!!

I would really like to have both of these working, but after several trial and errors I ended up having no idea what should I do. I would really appreciate if you could help me!

Thank you! :)

I am using TFS 0.2.14 (Mystic)




Lua:
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 onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid) end

--------------------------------------------------------------------

local talk = {}

local num = 0
local messages =
{

	[1] = "Que estupendo dia para pescar!",
	[2] = "Espero pescar un tiburon!"
}


------------------------------------------------------------------

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'fishing rod'}, 2580, 32, 'fishing rod')
shopModule:addBuyableItem({'fish'}, 2667, 8, 'fish')


------------------------------------------------------------------

npcHandler:setMessage(MESSAGE_GREET, 'Buenasss |PLAYERNAME|!!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Adios |PLAYERNAME|!!')

npcHandler:setMessage(MESSAGE_WALKAWAY, 'Mmm, adios!')
npcHandler:setMessage(MESSAGE_IDLETIMEOUT, 'Mmmm, te quedaste mudo?')

npcHandler:setMessage(MESSAGE_SENDTRADE, 'Te puedo vender una cana de pescar para que te unas a tan apasionante deporteeee! Lo que si es que te faltarian los gusanitos de carnada.. no te pienso dar los mios!')
npcHandler:setMessage(MESSAGE_ONCLOSESHOP, 'Jejeje graciasss!')

-------------------------------------------------------------------

function creatureSayCallback(cid, type, msg)


	if(not npcHandler:isFocused(cid)) then
	
		return false
		
	end
 
	talk[cid] = talk[cid] or 0

	if talk[cid] == 0 and (msgcontains(msg, "info") or msgcontains(msg, "news")) then
	
		selfSay("Esta es la playa, y mi hobbie en ella es, por supuesto, pasarmela aqui de pesca. :)", cid)
		return true
		
	end
	
	if talk[cid] == 0 and (msgcontains(msg, "quest") or msgcontains(msg, "mission")) then
	
		selfSay("Yo no necesito nada, gracias!", cid)
		return true
		
	end
	
	if talk[cid] == 0 and msgcontains(msg, "job") then
	
		selfSay("Soy un pescador apasionado!", cid)
		return true
		
	end
 
 
	return true
end


------*************************************************************************************-------------


function onThinkCallback()

	num = num + 1

	if num >= math.random(25, 30) then
		local random = math.random(1, #messages)

			doCreatureSay(getNpcCid(), messages[random], TALKTYPE_SAY)

		num = 0
	end

return true
end



------*************************************************************************************-------------



 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Lua:
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(cid, interval) 							npcHandler:onThink(interval) end
function onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid) end
 
--------------------------------------------------------------------
 
local talk = {}
 
local num = 0
local messages =
{
 
	[1] = "Que estupendo dia para pescar!",
	[2] = "Espero pescar un tiburon!"
}
 
 
------------------------------------------------------------------
 
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
shopModule:addBuyableItem({'fishing rod'}, 2580, 32, 'fishing rod')
shopModule:addBuyableItem({'fish'}, 2667, 8, 'fish')
 
 
------------------------------------------------------------------
 
npcHandler:setMessage(MESSAGE_GREET, 'Buenasss |PLAYERNAME|!!')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Adios |PLAYERNAME|!!')
 
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Mmm, adios!')
npcHandler:setMessage(MESSAGE_IDLETIMEOUT, 'Mmmm, te quedaste mudo?')
 
npcHandler:setMessage(MESSAGE_SENDTRADE, 'Te puedo vender una cana de pescar para que te unas a tan apasionante deporteeee! Lo que si es que te faltarian los gusanitos de carnada.. no te pienso dar los mios!')
npcHandler:setMessage(MESSAGE_ONCLOSESHOP, 'Jejeje graciasss!')
 
-------------------------------------------------------------------
 
function creatureSayCallback(cid, type, msg)
 
 
	if(not npcHandler:isFocused(cid)) then
 
		return false
 
	end
 
	talk[cid] = talk[cid] or 0
 
	if talk[cid] == 0 and (msgcontains(msg, "info") or msgcontains(msg, "news")) then
 
		selfSay("Esta es la playa, y mi hobbie en ella es, por supuesto, pasarmela aqui de pesca. :)", cid)
		return true
 
	end
 
	if talk[cid] == 0 and (msgcontains(msg, "quest") or msgcontains(msg, "mission")) then
 
		selfSay("Yo no necesito nada, gracias!", cid)
		return true
 
	end
 
	if talk[cid] == 0 and msgcontains(msg, "job") then
 
		selfSay("Soy un pescador apasionado!", cid)
		return true
 
	end
 
 
	return true
end
 
 
------*************************************************************************************-------------
 
 
function onThinkCallback()
 
	num = num + 1
 
	if num >= math.random(25, 30) then
		local random = math.random(1, #messages)
 
			doCreatureSay(getNpcCid(), messages[random], TALKTYPE_SAY)
 
		num = 0
	end
 
return true
end
 
 
 
------*************************************************************************************-------------
 
 
 
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

try this, I'm pretty sure it'll work. If not tell me
 
Here's one to start.. Missing the part that changes it back ..maybe more not really sure or wouldn't need help :D

running on tfs 0.3.6

This is just for kicks should be simple.. but my mind is froze here
Lua:
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 4006 then
doTransformItem(item.uid,4008)
doSummonMonster(cid, "Crazy Monkey")
-- need the countdown function?
doDecayItem(item.uid,4006) 
end
return 1 
end


Basically what I want this one to do is open a hole in sand and take a treasure map from the player like Tibia's Treasure Island

Lua:
function onUse(cid, item, frompos, item2, topos)
if item.actionid == 33333 and getPlayerItemCount(cid, 10123) >= 1 then
doRemoveItem(cid,10123,1)
doTransformItem(item.uid,489)

Need the countdown part...can't seem to find the function for it

doDecayItem(item.uid,231)
end
return 1 
end

And if you or someone else could point me to a function list.. that would be great. But, preferably not the one in docs since they are limited... or it may just be my eye sight. :cool:

Thank you much in advance.
 
Last edited:
Hi I would like to know whats wrong with my anni script, I'm using a real map, and what should my tiles be for the players to stand on?

function onUse(cid, item, frompos, item2, topos)

if item.uid == 7100 and item.itemid == 1945 then
player1pos = {x=33225, y=31671, z=13, stackpos=253}
player1 = getThingfromPos(player1pos)

player2pos = {x=33224, y=31671, z=13, stackpos=253}
player2 = getThingfromPos(player2pos)

player3pos = {x=33223, y=31671, z=13, stackpos=253}
player3 = getThingfromPos(player3pos)

player4pos = {x=33222, y=31671, z=13, stackpos=253}
player4 = getThingfromPos(player4pos)


if player1.itemid > 0 and player2.itemid > 0 and player3.itemid > 0 and player4.itemid > 0 then
queststatus1 = getPlayerStorageValue(player1.uid,7100)
queststatus2 = getPlayerStorageValue(player2.uid,7100)
queststatus3 = getPlayerStorageValue(player3.uid,7100)
queststatus4 = getPlayerStorageValue(player4.uid,7100)

if queststatus1 == -1 and queststatus2 == -1 and queststatus3 == -1 and queststatus4 == -1 then
nplayer1pos = {x=33222, y=31659, z=13}
nplayer2pos = {x=33221, y=31659, z=13}
nplayer3pos = {x=33220, y=31659, z=13}
nplayer4pos = {x=33219, y=31659, z=13}

doSendMagicEffect(player1pos,2)
doSendMagicEffect(player2pos,2)
doSendMagicEffect(player3pos,2)
doSendMagicEffect(player4pos,2)

doTeleportThing(player1.uid,nplayer1pos)
doTeleportThing(player2.uid,nplayer2pos)
doTeleportThing(player3.uid,nplayer3pos)
doTeleportThing(player4.uid,nplayer4pos)

doSendMagicEffect(nplayer1pos,10)
doSendMagicEffect(nplayer2pos,10)
doSendMagicEffect(nplayer3pos,10)
doSendMagicEffect(nplayer4pos,10)

doTransformItem(item.uid,item.itemid+1)
else
doPlayerSendCancel(cid,"Somebody in your team has already done this quest.")
end
else
doPlayerSendCancel(cid,"You need four players for this quest.")
end

elseif item.uid ==7100 and item.itemid == 1946 then
if getPlayerAccess(cid) > 0 then
doTransformItem(item.uid,item.itemid-1)
else
doPlayerSendCancel(cid,"Sorry, not possible.")
end
else
return 0
end

return 1
end
 
im looking for a scripter that can make a few scripts for me, i understand some scripting (like the npc's) but the command scripts and action scripts are very hard..
please help :D
 
Hi,

I do not know where to post it.

In case it is in wrong sub-forum please remove it or move it to correct one.

Basically, what I am trying to achieve is a best traning system. I have created lots of rooms for players which nice surroundings. To get to the training room which is located at coordinates mention below he has to step onto special tile, or teleport. I do not have a clue how to do this. Each room can be used by only 1 player! Each player gets different room. If I have to type in each coordinate of 400 rooms - no problem, I will do that. I just want to have a script which will teleport player to the training room, and before teleport check which coordinates are free.

x: 1000
y: 1000
z: 7

Any of you have idea how to do it?
 
Here a very basic script for it..

Lua:
local trainingRoom = {
[1] = {x = 1000, y = 1000, z = 7, stackpos = 255},
[2] = {x = 1000, y = 1000, z = 7, stackpos = 255},
[2] = {x = 1000, y = 1000, z = 7, stackpos = 255},
[4] = {x = 1000, y = 1000, z = 7, stackpos = 255}
}

local level_to_train = 10

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if getPlayerLevel(cid) >= level_to_train then
	if isInArray(trainingRoom) then
	
	---------------------Room 1----------------------
		if (not isPlayer(trainingRoom[1])) then
			doTeleportThing(cid, trainingRoom[1])
			doPlayerSendTextMessage(cid, "Welcome to you're training room.")
		else
		---------------------Room 2----------------------
		if (not isPlayer(trainingRoom[2])) then
			doTeleportThing(cid, trainingRoom[2])
			doPlayerSendTextMessage(cid, "Welcome to you're training room.")
			
			else
		---------------------Room 3----------------------
		if (not isPlayer(trainingRoom[3])) then
			doTeleportThing(cid, trainingRoom[3])
			doPlayerSendTextMessage(cid, "Welcome to you're training room.")
			
			else
		---------------------Room 4----------------------
		if (not isPlayer(trainingRoom[4])) then
			doTeleportThing(cid, trainingRoom[4])
			doPlayerSendTextMessage(cid, "Welcome to you're training room.")
			else
			doPlayerSendCancel(cid, "all training rooms are full!")
			doTeleportThing(cid, fromPos, true)
		return false
		end
		end
		end
		end
		end
		else
				doPlayerSendCancel(cid, "You are not high enough level to train!")
			doTeleportThing(cid, fromPos, true)
		return false	
		end
		end
 
I need a script
well i dont know if its a script but , i want to put an event on an item, like i want to put the blue arrow in a chest or a tree burning when i throw a GFB or something
like that
someone?
 
Back
Top