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

TalkAction Exiva "NPC

Status
Not open for further replies.

Cyro

Intermediate OT User
Joined
May 24, 2011
Messages
1,293
Reaction score
110
Location
Egypt
How it Works ?
It will help players to find the Npc with exiva like if they are searching for a player (cost 0 gold coins.)

data/talkactions/scripts/find_npc.lua

Code:
local config =
{
	cost = 0
}
 
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

Code:
<talkaction words="!exiva" filter="quotation" event="script" value="find_npc.lua"/>


Now u are done. "Credits to Gezox!" and u can edit the cost to whatever :)
 
How it Works ?
It will help players to find the Npc with exiva like if they are searching for a player (cost 0 gold coins.)

data/talkactions/scripts/find_npc.lua

Code:
local config =
{
	cost = 0
}
 
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

Code:
<talkaction words="!exiva" filter="quotation" event="script" value="find_npc.lua"/>


Now u are done. "Credits to Gezox!" and u can edit the cost to whatever :)

Nice for releasing my script ;)
http://otland.net/f81/exiva-npc-name-49396/
 
Last comment was on 2010 before I even enter the forum....... I will tell a mod to delete the thread anyway
 
Status
Not open for further replies.
Back
Top