Ir para conteúdo

[ Fechado ] Como Fazer Um Npc Chamado Cityguard:)


braz456

Posts Recomendados

Olá vamos aprender como fazer um npc chamado city guard xD

Vá em data/npc/renomeio qual quer um arquivo para cityguard apague tudo e cole issu

 

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Cityguard" script="data/npc/scripts/cityguard.lua" walkinterval="0" floorchange="0" speed="900">
<health now="150" max="150"/>
<look type="131" head="116" body="94" legs="78" feet="19"/>

 <interaction range="3" idletime="60">

<interact keywords="hi" focus="1">
  <keywords>hello</keywords>

  <response text="Nothing to see here, move along.">
	<action name="idle" value="1"/>
  </response>
</interact>

<interact keywords="bye" focus="0">
  <keywords>farewell</keywords>

  <response text="Good bye."/>
</interact>
 </interaction>

</npc>

Agora va em data/npc/scripts renomeie qualquer arquivo para City guard apague tudo e coloque issu

 

 

[code] 

local target = 0
local prevTarget = 0
local maxChaseDistance = 20
local origPos = 0
local lastAttack = 0
local followTimeout = 10

local function isSkulled(cid)
if(getPlayerSkullType(cid) >= 3 and isPlayerPzLocked(cid) == TRUE) then
 return true
end

return false
end

local function goToOrigPos()
target = 0
lastAttack  = 0
selfFollow(0)
doTeleportThing(getNpcCid(), origPos)
end

local function updateTarget()
if(isPlayer(target) == FALSE) then
 goToOrigPos()
elseif(not isSkulled(target)) then
 selfSay("Now, behave in the future.")
 goToOrigPos()
end

if(target == 0) then
 local list = getSpectators(getNpcPos(), 9, 9, false)
 for i = 1, table.getn(list) do
  local _target = list[i]
  if(_target ~= 0) then
if(isPlayer(_target) == TRUE and isSkulled(_target)) then
 if(getTilePzInfo(getCreaturePosition(_target)) == FALSE) then
  if(selfFollow(_target)) then
   target = _target
   if(target ~= prevTarget) then
	selfSay("We do not tolerate people like you here!")
   end

   prevTarget = target
   break
  end
 end
end
  end
 end
end
end

function onCreatureAppear(cid)
if(cid == getNpcCid()) then
 origPos = getNpcPos()
end
end

function onCreatureDisappear(cid)
if(cid == target) then
 goToOrigPos()
end
end

function onCreatureMove(creature, oldPos, newPos)
--
end

function onThink()
updateTarget()

if(target == 0) then
 return
end

local playerPos = getCreaturePosition(target)
local myPos = getNpcPos()

if(myPos.z ~= playerPos.z) then
 goToOrigPos()
 return
end

if(math.abs(myPos.x - origPos.x) > maxChaseDistance or math.abs(myPos.y - origPos.y) > maxChaseDistance) then
 selfSay("I'll catch you next time.")
 goToOrigPos()
 return
end

if(lastAttack == 0) then
 lastAttack = os.clock()
end

if(os.clock() - lastAttack > followTimeout) then
 selfSay("You got me this time, but just wait.")
 goToOrigPos()
 return
end

if((math.abs(playerPos.x - myPos.x) <= 1) and (math.abs(playerPos.y - myPos.y) <= 1)) then
 doTargetCombatHealth(getNpcCid(), target, COMBAT_LIFEDRAIN, -100000, -200000, CONST_ME_EXPLOSIONAREA)
 lastAttack = os.clock()
end
end
this to the colour of the text that shows the damage when the creature gets hit
------------------end of config------------------ 
local check_clock = os.clock() ----- leave this
local focus = 0 ----- leave this 
function msgcontains(txt, str) 
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) 
end 

function onCreatureSay(cid, type, msg) 
msg = string.lower(msg)
health = getPlayerHealth(cid) - health_left
if ((string.find(msg, '(%a*)hi(%a*)'))) and getDistanceToCreature(cid) < 4 then 
selfSay('Hello ' .. creatureGetName(cid) .. '! I am a defender of '..town_name..'.') 
doNpcSetCreatureFocus(cid) 
focus = 0
end
if msgcontains(msg, 'time') then
selfSay('The time is ' .. getWorldTime() .. '.')
end
if messageIsInArray(swear_words, msg) then
if Attack_swearers == TRUE then
selfSay('' .. swear_message ..' ') 
doPlayerAddHealth(cid,-health)
doSendMagicEffect(getThingPos(cid),17) 
doSendAnimatedText(getThingPos(cid),health,180)
doNpcSetCreatureFocus(cid) 
focus = 0 
end
end
end 

function getMonstersfromArea(pos, radiusx, radiusy, stack)
local monsters = { } 
local starting = {x = (pos.x - radiusx), y = (pos.y - radiusy), z = pos.z, stackpos = stack} 
local ending = {x = (pos.x + radiusx), y = (pos.y + radiusy), z = pos.z, stackpos = stack} 
local checking = {x = starting.x, y = starting.y, z = starting.z, stackpos = starting.stackpos} 
repeat 
creature = getThingfromPos(checking) 
if creature.itemid > 0 then 
if isCreature(creature.uid) == TRUE then
if isPlayer(creature.uid) == FALSE then
if Attack_monsters == TRUE then
table.insert (monsters, creature.uid) 
check_clock = os.clock()
end
elseif isPlayer(creature.uid) == TRUE then 
if Attack_pkers == TRUE then
if getPlayerSkull(creature.uid) > 0 then
table.insert (monsters, creature.uid) 
check_clock = os.clock() 
end
end
end 
end 
end 
if checking.x == pos.x-1 and checking.y == pos.y then 
checking.x = checking.x+2 
else 
checking.x = checking.x+1 
end 
if checking.x > ending.x then 
checking.x = starting.x 
checking.y = checking.y+1 
end 
until checking.y > ending.y 
return monsters 
end 

function onThink() 
if (Attack_monsters == TRUE and Attack_pkers == TRUE) or (Attack_monsters == TRUE and Attack_pkers == FALSE) or (Attack_monsters == FALSE and Attack_pkers == TRUE) then
if (os.clock() - check_clock) > check_interval then 
monster_table = getMonstersfromArea(getCreaturePosition(getNpcCid( )), radiusx, radiusy, 253) 
if #monster_table >= 1 then
selfSay('' .. Attack_message ..' ') 
for i = 1, #monster_table do 
doNpcSetCreatureFocus(monster_table[i]) 
local damage_min = (level * 2 + maglevel * 3) * min_multiplier 
local damage_max = (level * 2 + maglevel * 3) * max_multiplier 
local damage_formula = math.random(damage_min,damage_max) 
doSendMagicEffect(getThingPos(monster_table[i]),17)
doCreatureAddHealth(monster_table[i],-damage_formula) doSendMagicEffect(getThingPos(monster_table[i]),hit_effect)
doSendAnimatedText(getThingPos(monster_table[i]),damage_formula,damage_colour) 
check_clock = os.clock() 
focus = 0 
end 
elseif table.getn(monster_table) < 1 then 
focus = 0 
check_clock = os.clock() 
end 
end
end
focus = 0
end

Agora feche salve é ligue seu ot e fale /n cityguard

Hail

 

Visite meu ot otyour.servegame.com

 

Descubra oq tem aki \/

Da mas 3 click

Mas 2 click

Mas 1 clikc plxx

Parabens vc deu 3 Click
Link para o comentário
Compartilhar em outros sites

Ahhhhhhhhhh brother

você ta de bricadeira em...

Já é a terceira ou quarta vez que posta este tipo de conteúdo no barzinho cara! Po, já não te suspendi, mas se você fizer isto mais uma vez não terei outra escolha.

 

Alertado em 10%,

:button_cancel: Tópico Fechado

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...