Skrypty & Kody Ma?y problem ze skryptem.

Status
Zamknięty.

Najst997

User
Zarejestrowany
Dołączył
Lipiec 1, 2010
Posty
10
Liczba reakcji
0
Witajcie. Jestem dopiero pocz?tkuj?cym skrypterem, wi?c nie bijcie, bo wiem, ?e to zapewne bardzo proste.
A wi?c stworzy?em NPC, kt?ry gdy do niego powiemy 'plotki' powie nam co? ciekawego, ale chcia?em zrobi?, ?e je?li LVL naszej postaci jest wi?kszy od np. 40 to m?wi co innego, jednak mi to nie wysz?o.

Tutaj podaje skrypt:
Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Do widzenia!')
          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, 'witaj') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Witaj, ' .. creatureGetName(cid) .. '! Co moge dla ciebie zrobic? Chcialbys poznac jakies ciekawe plotki?')
  		focus = cid
  		talk_start = os.clock()

  			elseif msgcontains(msg, 'witaj') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  			selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! Jestem zajety, przyjdz za chwilke.')
		
			elseif focus == cid then
			talk_start = os.clock()

			if msgcontains(msg, 'plotki') and getPlayerLevel(cid) <= 40 then
			selfSay('Slyszalem, ze na szczycie ktorejs wiezy w swiatyni znajduje sie jakis cenny przedmiot. Sprawdz to, jesli chcesz.')
			
			elseif msgcontains(msg, 'plotki') and getPlayerLevel(cid) >= 40 then
			selfSay('Niestety, nie mam Ci nic waznego do powiedzenia.')
			focus = cid

			

			elseif msgcontains(msg, 'zegnaj') and getDistanceToCreature(cid) < 4 then
			selfSay('Zegnaj, ' .. creatureGetName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('A ty co tak stoisz i sie gapisz?')
  		end
  			focus = 0
  	end

 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Do widzenia, przyjacielu!')
 			focus = 0
 		end
 	end
end
Mo?ecie mi pom?c?
 
Odp: Ma?y problem ze skryptem.

Spr?buj tak:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Do widzenia!')
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, 'witaj') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj, ' .. creatureGetName(cid) .. '! Co moge dla ciebie zrobic? Chcialbys poznac jakies ciekawe plotki?')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'witaj') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! Jestem zajety, przyjdz za chwilke.')

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

if msgcontains(msg, 'plotki') then
if getPlayerLevel(cid) <= 40 then
selfSay('Slyszalem, ze na szczycie ktorejs wiezy w swiatyni znajduje sie jakis cenny przedmiot. Sprawdz to, jesli chcesz.')

else
selfSay('Niestety, nie mam Ci nic waznego do powiedzenia.')
focus = cid
end


elseif msgcontains(msg, 'zegnaj') and getDistanceToCreature(cid) < 4 then
selfSay('Zegnaj, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('A ty co tak stoisz i sie gapisz?')
end
focus = 0
end

if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Do widzenia, przyjacielu!')
focus = 0
end
end
end
 
Odp: Ma?y problem ze skryptem.

Niestety. Spr?bowa?em 37LVLem, to samo, spr?bowa?em 100, to samo...

---Aktualizacja---

Przypominam, i? jest to 7.6!

Tutaj drugi problem.
Gdy pisze do niego 'victim' to nie reaguje. W silniku ?adnych b??d?w. W czym problem?
Tutaj skrypt.

Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Do zobaczenia!')
          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, 'witaj') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
			selfSay('Witaj, ' .. creatureGetName(cid) .. '! Jesli jestes juz gotowy to moge zabrac Cie na wyspe Victim.')
			focus = cid
			talk_start = os.clock()


  	elseif msgcontains(msg, 'witaj') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Jestem zajety, ' .. creatureGetName(cid) .. '! Poczekaj chwilke.')

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

		if msgcontains(msg, 'victim') then
			if getPlayerLevel(cid) == 8 then
		   	 if getPlayerVocation(cid) == 1 then
				selfSay('No to plyniemy!')
				selfSay('/send ' .. creatureGetName(cid) .. ', 122 119 7')
				focus = 0
				talk_start = 0

			else
				selfSay('Nie jestes jeszcze gotowy!')

			end
		end


			elseif msgcontains(msg, 'zegnaj') and getDistanceToCreature(cid) < 4 then
			selfSay('Do widzenia, ' .. creatureGetName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Zaniemowiles?')
  		end
  			focus = 0
  	end
	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Do zobaczenia!')
 			focus = 0
 		end
 	end
end
 
Ostatnia edycja:
Status
Zamknięty.
Back
Do góry