darcioantonio
www.adventurerpg.com.br
- Joined
- Jul 30, 2013
- Messages
- 165
- Solutions
- 1
- Reaction score
- 4
- Location
- Brasil
- Twitch
- darcio_
- YouTube
- UCEXCOEw_dYchojHNz
Hello everyone, good evening. I used to have a TFS 0.4 server and had a talkaction "!exiva" for NPCs. However, I'm currently migrating the server to version 10.98 TFS 1.4, and I would like to know if it's possible to adapt the "exiva" spell to use for NPCs. I used this talkaction in version 0.4.
Lua:
<talkaction words="!EXIVA" event="script" value="find_npc.lua"/>
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, "Você não tem dinheiro.")
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 = "sul"
elseif(playerPos.x == npcPos.x) and (playerPos.y > npcPos.y) then
px = 1
py = playerPos.y - npcPos.y
pS = "norte"
elseif(playerPos.x < npcPos.x) and (playerPos.y == npcPos.y) then
px = npcPos.x - playerPos.x
py = 1
pS = "direita"
elseif(playerPos.x > npcPos.x) and (playerPos.y == npcPos.y) then
px = playerPos.x - npcPos.x
py = 1
pS = "esquerda"
elseif(playerPos.x > npcPos.x) and (playerPos.y > npcPos.y) then
px = playerPos.x - npcPos.x
py = playerPos.y - npcPos.y
pS = "norte-esquerda"
elseif(playerPos.x > npcPos.x) and (playerPos.y < npcPos.y) then
px = playerPos.x - npcPos.x
py = npcPos.y - playerPos.y
pS = "sul-esquerda"
elseif(playerPos.x < npcPos.x) and (playerPos.y < npcPos.y) then
px = npcPos.x - playerPos.x
py = npcPos.y - playerPos.y
pS = "sul-direita"
elseif(playerPos.x < npcPos.x) and (playerPos.y > npcPos.y) then
px = npcPos.x - playerPos.x
ps = playerPos.y - npcPos.y
pS = "norte-direita"
end
if(px <= 4 and py <= 4) then
text = "" .. getCreatureName(getNpc) .. " esta ao seu lado."
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) .. " esta a " .. 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) .. " esta muito longe para " .. 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) .. " esta muito longe para " .. pS .. "."
elseif(px > 280 and py > 280) or (px > 280 and py < 280) or (px < 280 and py > 280) then
text = "" .. getCreatureName(getNpc) .. " para o " .. pS .. "."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
return false
else
doPlayerSendCancel(cid, "O NPC não existe.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return true
end
end