• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Npc request

azzkaban

Monster Maker
Joined
Feb 23, 2010
Messages
1,101
Reaction score
195
Location
Iquique Chile
Hi! I need NPC.

Example:

player= Hi
NPC= Hi [PLAYER NAME], Whats effects you need see?
player= 57
NPC= (NPC SEND EFFECT)

Can you help me?

REP MAS 002.png
 
LUA:
local focuses = {}
local playerInfos = {}
 
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end
 
local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
 
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
 
end
 
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v) == TRUE) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
end
 
function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Good bye...")
		removeFocus(cid)
		if(isPlayer(cid) == TRUE) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
end
 
function msgContains(txt, str)
	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

 
 local magicEffects = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46}
 
function onCreatureSay(cid, type, msg)
	local msg = string.lower(msg)
	
	
-----------MESSAGE START-----------------	
if (not isFocused(cid)) and getDistanceTo(cid) < 4 and msgContains(msg, "hi") then
	selfSay("Welcome " .. getPlayerName(cid) .. " what magic effect would you like to see?", cid)
	addFocus(cid)
end
	
if isFocused(cid) and getDistanceTo(cid) < 4 and msgContains(msg, ..isInArray(magicEffects).."") then
	selfSay("That magic effect looks like this.", cid)
	for i, str in ipairs(msgContains()) do
		doPlayerSendMagicEffect(getPlayerPosition(cid), str)
	end
end
end


function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Take care.")
		closeShopWindow(cid)
		removeFocus(cid)
		removeInfo(cid)
	end
end
 
function onThink()
	for i, focus in pairs(focuses) do
		if(isCreature(focus) == FALSE) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Good Bye.", cid)
				closeShopWindow(focus)
				removeFocus(focus)
				removeInfo(cid)
			end
		end
	end
	lookAtFocus()
end

- - - Updated - - -

try this
 
Last edited:
I need all effects, same 9.81, is possible?

LUA:
CONST_ME_DRAWBLOOD = 0
CONST_ME_LOSEENERGY = 1
CONST_ME_POFF = 2
CONST_ME_BLOCKHIT = 3
CONST_ME_EXPLOSIONAREA = 4
CONST_ME_EXPLOSIONHIT = 5
CONST_ME_FIREAREA = 6
CONST_ME_YELLOW_RINGS = 7
CONST_ME_GREEN_RINGS = 8
CONST_ME_HITAREA = 9
CONST_ME_TELEPORT = 10
CONST_ME_ENERGYHIT = 11
CONST_ME_MAGIC_BLUE = 12
CONST_ME_MAGIC_RED = 13
CONST_ME_MAGIC_GREEN = 14
CONST_ME_HITBYFIRE = 15
CONST_ME_HITBYPOISON = 16
CONST_ME_MORTAREA = 17
CONST_ME_SOUND_GREEN = 18
CONST_ME_SOUND_RED = 19
CONST_ME_POISONAREA = 20
CONST_ME_SOUND_YELLOW = 21
CONST_ME_SOUND_PURPLE = 22
CONST_ME_SOUND_BLUE = 23
CONST_ME_SOUND_WHITE = 24
CONST_ME_BUBBLES = 25
CONST_ME_CRAPS = 26
CONST_ME_GIFT_WRAPS = 27
CONST_ME_FIREWORK_YELLOW = 28
CONST_ME_FIREWORK_RED = 29
CONST_ME_FIREWORK_BLUE = 30
CONST_ME_STUN = 31
CONST_ME_SLEEP = 32
CONST_ME_WATERCREATURE = 33
CONST_ME_GROUNDSHAKER = 34
CONST_ME_HEARTS = 35
CONST_ME_FIREATTACK = 36
CONST_ME_ENERGYAREA = 37
CONST_ME_SMALLCLOUDS = 38
CONST_ME_HOLYDAMAGE = 39
CONST_ME_BIGCLOUDS = 40
CONST_ME_ICEAREA = 41
CONST_ME_ICETORNADO = 42
CONST_ME_ICEATTACK = 43
CONST_ME_STONES = 44
CONST_ME_SMALLPLANTS = 45
CONST_ME_CARNIPHILA = 46
CONST_ME_PURPLEENERGY = 47
CONST_ME_YELLOWENERGY = 48
CONST_ME_HOLYAREA = 49
CONST_ME_BIGPLANTS = 50
CONST_ME_CAKE = 51
CONST_ME_GIANTICE = 52
CONST_ME_WATERSPLASH = 53
CONST_ME_PLANTATTACK = 54
CONST_ME_TUTORIALARROW = 55
CONST_ME_TUTORIALSQUARE = 56
CONST_ME_MIRRORHORIZONTAL = 57
CONST_ME_MIRRORVERTICAL = 58
CONST_ME_SKULLHORIZONTAL = 59
CONST_ME_SKULLVERTICAL = 60
CONST_ME_ASSASSIN = 61
CONST_ME_STEPSHORIZONTAL = 62
CONST_ME_BLOODYSTEPS = 63
CONST_ME_STEPSVERTICAL = 64
CONST_ME_YALAHARIGHOST = 65
CONST_ME_BATS = 66
CONST_ME_SMOKE = 67
CONST_ME_INSECTS = 68
CONST_ME_DRAGONHEAD = 69
CONST_ME_ORCSHAMAN = 70
CONST_ME_ORCSHAMAN_FIRE = 71
CONST_ME_THUNDER = 72
CONST_ME_FERUMBRAS = 73
CONST_ME_CONFETTIHORIZONTAL = 74
CONST_ME_CONFETTIVERTICAL = 75
CONST_ME_BLACK_SMOKE = 157
 
Im sure this scirpt still works for 9.81. If not....ugh....send me you're lib-string
50-functions

data>lib>lib-string.lua
server>doc>lua_functions

But if it does work, just replace this local where you see it in script. Then it should work.

LUA:
 local magicEffects = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 157}
 
Error in:

[Error - LuaInterface::loadFile] data/npc/scripts/efecto.lua:65: unexpected symbol near '..'
[18/1/2013 16:39:26] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/efecto.lua
[18/1/2013 16:39:26] data/npc/scripts/efecto.lua:65: unexpected symbol near '..'

- - - Updated - - -

Bump!
 
LUA:
local focuses = {}
local playerInfos = {}
 
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end
 
local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
 
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
 
end
 
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v) == TRUE) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
end
 
function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Good bye...")
		removeFocus(cid)
		if(isPlayer(cid) == TRUE) then --Be sure he's online
			closeShopWindow(cid)
		end
	end
end
 
function msgContains(txt, str)
	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
 
 
  local magicEffects = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 157}
 
function onCreatureSay(cid, type, msg)
	local msg = string.lower(msg)
 
 
-----------MESSAGE START-----------------	
if (not isFocused(cid)) and getDistanceTo(cid) < 4 and msgContains(msg, "hi") then
	selfSay("Welcome " .. getPlayerName(cid) .. " what magic effect would you like to see?", cid)
	addFocus(cid)
end
 
if isFocused(cid) and getDistanceTo(cid) < 4 and msgContains(msg, ..isInArray(magicEffects)..) then
	selfSay("That magic effect looks like this.", cid)
	for i, str in ipairs(msgContains()) do
		doPlayerSendMagicEffect(getPlayerPosition(cid), str)
	end
end
end
 
 
function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Take care.")
		closeShopWindow(cid)
		removeFocus(cid)
		removeInfo(cid)
	end
end
 
function onThink()
	for i, focus in pairs(focuses) do
		if(isCreature(focus) == FALSE) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Good Bye.", cid)
				closeShopWindow(focus)
				removeFocus(focus)
				removeInfo(cid)
			end
		end
	end
	lookAtFocus()
end
 
[19/1/2013 14:23:3] [Error - LuaInterface::loadFile] data/npc/scripts/efecto.lua:65: unexpected symbol near '..'
[19/1/2013 14:23:3] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/efecto.lua
[19/1/2013 14:23:4] data/npc/scripts/efecto.lua:65: unexpected symbol near '..'
 
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	local x = 0
	for v = 1, 75 do
		if(msgcontains(msg, ''..v..'')) then
			x = 1
		end
	end
 
	local last = (msgcontains(msg, '157'))
	if last or x == 1 then
		doSendMagicEffect(getThingPos(cid), msg)
	end
 
	if x ~= 1 and not last then
		selfSay('This isn\'t a magic effect, please choose a number between 1 and 75 or 157.', cid)
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top