TalkAction !exiva "Npc Name

Joined
Apr 17, 2008
Messages
1,922
Best answers
0
Reaction score
181
Location
Venezuela
Some times, when i'm doing a quest, i need to talk with a NPC, but sometimes i don't know where is that NPC. So i decided to create a "Find Npc" Spell like "Find Person".

This spell-talkaction have a cost of 100 gold coins.

..data/talkactions/scripts/find_npc.lua

Lua:
local config =
{
	cost = 100
}

function onSay(cid, words, param, channel)
	if(param == "" or param == nil) then
		return false
	end

	if doPlayerRemoveMoney(cid, config.cost) == FALSE then
		doPlayerSendCancel(cid, "You do not have enough money.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return true
	end

	local getNpc = getCreatureByName(param)
	if isNpc(getNpc) == TRUE then

	local playerPos, npcPos = getCreaturePosition(cid), getCreaturePosition(getNpc)
	local px, py = 0, 0
	local pS = ""
	local text = ""

		if(playerPos.x == npcPos.x) and (playerPos.y < npcPos.y) then
			px = 1
			py = npcPos.y - playerPos.y
			pS = "south"
		elseif(playerPos.x == npcPos.x) and (playerPos.y > npcPos.y) then
			px = 1
			py = playerPos.y - npcPos.y
			pS = "north"
		elseif(playerPos.x < npcPos.x) and (playerPos.y == npcPos.y) then
			px = npcPos.x - playerPos.x
			py = 1
			pS = "east"
		elseif(playerPos.x > npcPos.x) and (playerPos.y == npcPos.y) then
			px = playerPos.x - npcPos.x
			py = 1
			pS = "west"
		elseif(playerPos.x > npcPos.x) and (playerPos.y > npcPos.y) then
			px = playerPos.x - npcPos.x
			py = playerPos.y - npcPos.y
			pS = "north-west"
		elseif(playerPos.x > npcPos.x) and (playerPos.y < npcPos.y) then
			px = playerPos.x - npcPos.x
			py = npcPos.y - playerPos.y
			pS = "south-west"
		elseif(playerPos.x < npcPos.x) and (playerPos.y < npcPos.y) then
			px = npcPos.x - playerPos.x
			py = npcPos.y - playerPos.y
			pS = "south-east"
		elseif(playerPos.x < npcPos.x) and (playerPos.y > npcPos.y) then
			px = npcPos.x - playerPos.x
			ps = playerPos.y - npcPos.y
			pS = "north-east"
		end

		if(px <= 4 and py <= 4) then
			text = "" .. getCreatureName(getNpc) .. " is standing next you."
		elseif((px > 4 and px <= 100) and (py > 4 and py <= 100)) or ((px > 4 and px <= 100) and (py <= 4)) or ((px <= 4) and (py > 4 and py <= 100)) then
			text = "" .. getCreatureName(getNpc) .. " is to the " .. pS .. "."
		elseif((px > 100 and px <= 274) and (py > 100 and py <= 274)) or ((px > 100 and px <= 274) and (py <= 100)) or ((px <= 100) and (py > 100 and py <= 274)) then
			text = "" .. getCreatureName(getNpc) .. " is far to the " .. pS .. "."
		elseif((px > 274 and px <= 280) and (py > 274 and py <= 280)) or ((px > 274 and px <= 280) and (py < 274)) or ((px < 274) and (py > 274 and py <= 280)) then
			text = "" .. getCreatureName(getNpc) .. " is very far to the " .. pS .. "."
		elseif(px > 280 and py > 280) or (px > 280 and py < 280) or (px < 280 and py > 280) then
			text = "" .. getCreatureName(getNpc) .. " is to the " .. pS .. "."
		end

		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
		return false
	else
		doPlayerSendCancel(cid, "A npc with that name does not exist.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
		return true
	end
end
..data/talkactions/talkactions.xml
Lua:
	<talkaction words="!exiva" filter="quotation" event="script" value="find_npc.lua"/>
Note: if your server have two or more NPCs with the same name, the spell will find one of these npcs.
 

Zisly

Intermediate OT User
Joined
Jun 9, 2008
Messages
7,352
Best answers
0
Reaction score
119
Nice idea but I really prefer a server without it, thats the fun, getting frustrated because you can't find the damn NPC :D
 

Wezza

lua nOOb
Joined
May 31, 2008
Messages
2,278
Best answers
0
Reaction score
30
@ up, I totally agree you, lmao.
 

Slatera

Member
Joined
Mar 6, 2009
Messages
442
Best answers
0
Reaction score
8
Location
Sweden
Nice for those who needs :) keep up the good work mate :D
 

Colandus

Advanced OT User
Joined
Jun 6, 2007
Messages
2,424
Best answers
18
Reaction score
165
Location
Sweden
better use function "getSearchString", it will tell you that "south-east" etc just by positions :)
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
852
Location
Caribbean Sea
better make a quest-search device that can be sold at donations
 

wojtek1990

New Member
Joined
Mar 24, 2010
Messages
46
Best answers
0
Reaction score
0
Location
Poland
Hey mate, maybe u know how to make !exiva "HouseName script ?
Will be nice :)
 

Seminari

Banned User
Joined
Dec 13, 2009
Messages
1,496
Best answers
0
Reaction score
34
Location
Poland
sorry for refresh but i saw new thread "exiva npc" with this script..

btw. what is "filter="quotation"" ?
 
Top