Skrypty & Kody Npc

mafa123

User
Zarejestrowany
Dołączył
Luty 16, 2015
Posty
48
Liczba reakcji
0
Witam potrzebuje ma?ej pomocy w ustawieniu funkcji getDistanceToCreature bo ?apie z ko?ca ekranu jak si? pisze hi oraz te? aby npcety nie chodzi?y. Wersja silnika to 1.2
[LUA]local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Hey!.')
focus = 0
talk_start = 0
end
end


function onCreatureTurn(creature)

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


function onCreatureSay(cid, type, msg)
msg = string.lower(msg)

if (msgcontains(msg, 'hi') and (focus == 0)) and (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then

selfSay('I Can Teleport you to Yama')
focus = cid
talk_start = os.clock()


elseif msgcontains(msg, 'hi') and (focus ~= cid) then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! ????????.')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'yes') then
travel(cid, 306, 40, 6)
selfSay('Ok!')
focus = 0
talk_start = 0

elseif msgcontains(msg, 'asdasdasdasdasdasa') then
if pay(cid,100) then
travel(cid, 117, 101, 7)
selfSay('Let\'s go!')
focus = 0
talk_start = 0
else
selfSay('Sorry You Dont have that item.')
end




elseif msgcontains(msg, 'bye') then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end

function onThink()
if focus > 0 then
x, y, z = creatureGetPosition(focus)
myx, myy, myz = selfGetPosition()

if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
selfTurn(1)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(3)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(0)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(2)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(0)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(3)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(1)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(2)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(0)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(3)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(1)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(2)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(0)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(3)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(1)
end
end

if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Well, bye then.')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Well, bye then.')
focus = 0
end
end
end

[/LUA]
 
Odp: Npc

dzi?ki teraz musz? doda? w ka?dym npc walkinterval bo nie mia?em
 
Odp: Npc

Kto? co? ??

---------- Tre?? dodana o 17:12 ----------

ref....
 
Back
Do góry