What's new

Skrypty & Kody Pomoc npc. 7.6 LUA

oskar1232

Advanced User
Joined
Jul 16, 2010
Messages
175
Reaction score
0
Witam wszystkichh :)
mam takie pytanie, co jest tutaj ?le zrobione, ?e jak pisze do NPC to rozpisuje mi sie tylko na temat pacc oraz czary, ale np jak napisz sorc, knight , domki albo cos innego to juz nie trybi :p:vroam:
[LUA]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('Good bye then.')
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 getDistanceToCreature(cid) < 4 then
selfSay('Siemanko ' .. creatureGetName(cid) .. '! Co bys chcial wiedziec na temat servera? /n "pacc" /n "czary /n "przedmioty" /n "przedzial" /n "domki". ')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przykro mi, ' .. creatureGetName(cid) .. '! Musisz chwileczke zaczekac.')

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

if msgcontains(msg, 'pacc') then
selfSay('Witaj! Pacc runa (60h) kosztuje sms 3.76 zl /n Pacc runa (180h) kosztuje sms 11.07 zl. /n Jezeli jestesmy w posiadaniu PACCa to mamy dostep do nowych potworow, przedmiotow, questow oraz czarow, a takze mozemy kupowac domki.')
elseif msgcontains(msg, 'czary') then
selfSay('Aby korzystac z nowych czarow, trzeba posiadac PACC! Czary dla jakiej profesji Cie interesuja? "Sorc" , "Druid" , "Pall" , "Knight" .')
elseif msgcontains(msg, 'Sorc') then
selfSay('Death sio "nick od 45 poziomu magicznego.')
elseif msgcontains(msg, 'Druid') then
selfSay('Druid posiada dostep do run paralizujacych (od 35 poz. magicznego) oraz z tzw. "krzakow" (od 35 poz. magicznego) . /n Rowniez posiada czar Death sio "nick od 45 poziomu magicznego.')
elseif msgcontains(msg, 'Pall') then
selfSay('Exura San (od 13 poz. mag.) /n Exura Gran San (od 23 poz. mag.) /n Utamo Tempo San (od 15 poz. mag.) /n Exevo Mas San (od 20 poz. mag.) /n Poison sio "nick ( od 17 poz. mag.) .')
elseif msgcontains(msg, 'Knight') then
selfSay('Exana Mort (od 3 poz. mag.) /n Utani Tempo Hur (od 5 poz. mag) /n Exori mas (od 4 poz. mag.) Exori Gran (od 7 poz. mag.) /n Explosion sio"nick (od 4 poz. mag.).')
elseif msgcontains(msg, 'Przedmioty') then
selfSay('Na serverze sa przedmioty, ktore dodaja mane/hp, rowniez sa nowe bronie, ktorych moc sie nie konczy! Sa rowniez pierscienie, ktore daja 2x wiecej expa, ale nic nie przebije EQ, ktore redukuje 25% zadawanych obrazen i drugie 25% dodaje do atakow ;)!!')
elseif msgcontains(msg, 'Przedzial') then
selfSay('Server posiada bramki PvP /n 1-50, /n 51-100, /n 101-150, /n 151-200, /n 201-300, /n 301-500, /n 501+ .')
elseif msgcontains(msg, 'Domki') then
selfSay('Domku kupujemy komenda !buyhouse. Aby kupic domek musimy posiadac pacc, jak i zarowno setny poziom.')


elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Powodzenia, ' .. 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('Zobaczymy czy wam sie uda...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
[/LUA]
 

Bruce

Active User
Joined
Dec 13, 2008
Messages
112
Reaction score
6
Age
29
Odp: Pomoc npc. 7.6 LUA

Code:
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('Good bye then.')
          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 getDistanceToCreature(cid) < 4 then
  		selfSay('Siemanko ' .. creatureGetName(cid) .. '! Co bys chcial wiedziec na temat servera? /n "pacc" /n "czary /n "przedmioty" /n "przedzial" /n "domki". ')
  		focus = cid
  		talk_start = os.clock()
 
  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Przykro mi, ' .. creatureGetName(cid) .. '! Musisz chwileczke zaczekac.')
 
	elseif focus == cid then
		talk_start = os.clock()
 
		if msgcontains(msg, 'pacc') then
			selfSay('Witaj! Pacc runa (60h) kosztuje sms 3.76 zl /n Pacc runa (180h) kosztuje sms 11.07 zl. /n Jezeli jestesmy w posiadaniu PACCa to mamy dostep do nowych potworow, przedmiotow, questow oraz czarow, a takze mozemy kupowac domki.')
		elseif msgcontains(msg, 'czary') then
			selfSay('Aby korzystac z nowych czarow, trzeba posiadac PACC! Czary dla jakiej profesji Cie interesuja? "Sorc" , "Druid" , "Pall" , "Knight" .')
		elseif msgcontains(msg, 'sorc') then
			selfSay('Death sio "nick od 45 poziomu magicznego.')
		elseif msgcontains(msg, 'druid') then
			selfSay('Druid posiada dostep do run paralizujacych (od 35 poz. magicznego) oraz z tzw. "krzakow" (od 35 poz. magicznego) . /n Rowniez posiada czar Death sio "nick od 45 poziomu magicznego.')
		elseif msgcontains(msg, 'pall') then
			selfSay('Exura San (od 13 poz. mag.) /n Exura Gran San (od 23 poz. mag.) /n Utamo Tempo San (od 15 poz. mag.) /n Exevo  Mas San (od 20 poz. mag.) /n Poison sio "nick ( od 17 poz. mag.) .')
		elseif msgcontains(msg, 'knight') then
			selfSay('Exana Mort (od 3 poz. mag.) /n Utani Tempo Hur (od 5 poz. mag) /n Exori mas (od 4 poz. mag.) Exori Gran (od 7 poz. mag.) /n Explosion sio"nick (od 4 poz. mag.).')
		elseif msgcontains(msg, 'przedmioty') then
			selfSay('Na serverze sa przedmioty, ktore dodaja mane/hp, rowniez sa nowe bronie, ktorych moc sie nie konczy! Sa rowniez pierscienie, ktore daja 2x wiecej expa, ale nic nie przebije EQ, ktore redukuje 25% zadawanych obrazen i drugie 25% dodaje do atakow ;)!!')
		elseif msgcontains(msg, 'przedzial') then
			selfSay('Server posiada bramki PvP /n 1-50, /n 51-100, /n 101-150, /n 151-200, /n 201-300, /n 301-500, /n 501+ .')
		elseif msgcontains(msg, 'domki') then
			selfSay('Domku kupujemy komenda !buyhouse. Aby kupic domek musimy posiadac pacc, jak i zarowno setny poziom.')
 
 
		elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
			selfSay('Powodzenia, ' .. 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('Zobaczymy czy wam sie uda...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
end

Ju? dzia?a, po prostu string w warunku powinien zaczyna? si? od ma?ej litery :)

Pozdrawiam
 

oskar1232

Advanced User
Joined
Jul 16, 2010
Messages
175
Reaction score
0
Odp: Pomoc npc. 7.6 LUA

Dzieki, wszystko dzia?a :) :p , mam kolejny problem z LUA

Odno?nie Acc Makera, jako npc. Mam taki skrypcik :
[LUA]---little config-----------------------------------------
maxnamelen = 10
maxpasslen = 10
startlvl = 8
startexp = 4200
vocations = 1
healthstart = 350
manastart = 50
depoitemid = 2591
promoted = 1
---------skills-------------------------
--knight-------
kmlvl = 4
kfist = 70
kclub = 70
ksword = 70
kaxe = 70
kdist = 10
kshield = 70
kfish = 10
kcap = 100
--pall------------
pmlvl = 8
pfist = 10
pclub = 10
psword = 10
paxe = 10
pdist = 70
pshield = 30
pfish = 10
pcap = 10
---drut i sorc----
mmlvl = 50
mfist = 10
mclub = 10
msword = 10
maxe = 10
mdist = 10
mshield = 10
mfish = 10
mcap = 10
---end skills -------------------------------
---end little config-----------------------------------------
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
accstatus = 0
seksik = 3
myname = ''
mypass = ''
allow_pattern = '^[a-zA-Z0-9 -]+$'
origmsg = ''
mypasscheck = ''
mynamecheck = ''
vocation = 0


function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
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)
origmsg = msg
msg = string.lower(msg)



if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj. Jestem tu aby pomoc ci stworzyc nowe konto i nowa postac. Jesli chcesz zaczac tworzenie kona to powiedz mi najpierw czy jestes facetem czy kobieta. --facet---kobieta--- ')
accstatus = 1
myname = ''
mypass = ''
myaccnumber = 0
focus = cid
talk_start = os.clock()


elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Poczekaj, porozmawiam z toba za minutke')


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

if accstatus == 1 then
if msgcontains(msg, 'facet') then selfSay('Dobrze przyjacielu. Teraz podaj mi swoje imie.')
seksik = 1
accstatus = 2
elseif msgcontains(msg, 'kobieta') then
selfSay('Dobrze moja droga, teraz podaj mi swoje imie.')
seksik = 0
accstatus = 2
end




elseif accstatus == 66 then
if msgcontains(msg, 'pall') then
vocation = 3
selfSay('Paladyn, tak ?')

elseif msgcontains(msg, 'sorc') then
vocation = 1
selfSay('Sorcerer, tak ?')

elseif msgcontains(msg, 'drut') then
vocation = 2
selfSay('Druid, tak ?')

elseif msgcontains(msg, 'knight') then
vocation = 4
selfSay('Knight, tak ?')
else
selfSay('Co tak mamroczesz, powiedz jeszcze raz.')
end

accstatus = 67


elseif accstatus == 2 then
myname = origmsg
mynamecheck = msg
if string.len(mynamecheck) <= maxnamelen then
if string.find(mynamecheck, allow_pattern) then
if io.open("data/players/"..myname..".xml" , "r") == nil then
selfSay('Chcesz miec na imie '..myname..' tak ?')
accstatus = 3
else
selfSay('To imie jest juz zarezerwowane !! Podaj inne, slucham')
end
else
selfSay('To imie zawiera niedozwolone znaki !! Podaj inne')
end
else
selfSay('To imie jest za dlugie !! Max to 10 znakow ! Podaj inne')
end
elseif msgcontains(msg, 'tak') then
if accstatus == 3 then
if vocations == 0 then
selfSay('Dobrze, teraz podaj mi haslo ktorego chcesz uzywac.')
vocation = 0
accstatus = 4
else
selfSay('Dobrze przyjacielu, teraz podaj czy chcesz byc --pall-- czy --sorc-- czy --drut-- czy --knight--.')
accstatus = 66
end
elseif accstatus == 5 then
if seksik == 0 then
selfSay('Wspaniale. Sprawdzmy jeszcze raz: Jestes kobieta o imieniu '..myname..' haslo do twojego konta brzmi '..mypass..'. Numer zostanie wylosowany na koncu. Czy wszystko sie zgadza ??')
else
selfSay('Wspaniale. Sprawdzmy jeszcze raz: Jestes facetem o imieniu '..myname..' haslo do twojego konta brzmi '..mypass..'. Numer zostanie wylosowany na koncu. Czy wszystko sie zgadza ??')
end
accstatus = 6
elseif accstatus == 6 then
selfSay('Doskonale. Czy mozemy przystapic do losowania numeru? --losowanie--bye---')
accstatus = 7
elseif accstatus == 67 then
selfSay('Doskonale. Teraz powiedz jakie chcesz miec haslo.')
accstatus = 4
end
elseif msgcontains(msg, 'nie') then
if accstatus == 3 then
selfSay('Podaj inne, slucham')
accstatus = 2
elseif accstatus == 5 then
selfSay('Podaj inne, slucham')
accstatus = 4
elseif accstatus == 6 then
selfSay('Zacznijmy od poczatku: Jestes facetem czy kobieta --facet--kobieta--')
accstatus = 1
elseif accstatus == 67 then
selfSay('Ehhh wiec powiedz jeszcze raz - jaka profesje chcesz miec ?')
accstatus = 66
end
elseif accstatus == 4 then
mypass = origmsg
mypasscheck = msg
if string.len(mypasscheck) <= maxpasslen then
if string.find(mypasscheck, allow_pattern) then
selfSay('Twoje haslo bedzie brzmialo '..mypass..' tak ?')
accstatus = 5
else
selfSay('To haslo zawiera niedozwolone znaki !! Podaj inne')
end
else
selfSay('To haslo jest za dlugie !! Max to 6 znakow ! Podaj inne')
end

elseif msgcontains(msg, 'losowanie') and accstatus == 7 then
if manastart == 0 then
manastartc = 1
else
manastartc = manastart
end
if healthstart == 0 then
healthstartc = 1
else
healthstartc = healthstart
end
if vocations == 0 then
mlvl = 1
fist = 10
club = 10
sword = 10
axe = 10
dist = 10
shield = 10
fish = 10
cap = 100
else
if vocation == 1 or vocation == 2 then
mlvl = mmlvl
fist = mfist
club = mclub
sword = msword
axe = maxe
dist = mdist
shield = mshield
fish = mfish
cap = mcap

elseif vocation == 3 then
mlvl = pmlvl
fist = pfist
club = pclub
sword = psword
axe = paxe
dist = pdist
shield = pshield
fish = pfish
cap = pcap
elseif vocation == 4 then
mlvl = kmlvl
fist = kfist
club = kclub
sword = ksword
axe = kaxe
dist = kdist
shield = kshield
fish = kfish
cap = kcap

end
end

myaccnumber = math.random(100000,999999)
if io.open("data/accounts/"..myaccnumber..".xml" , "r") == nil then
selfSay('wylosowano poprawny numer '..myaccnumber..' Powedz --dalej--')
accstatus = 8
f = assert(io.open("./data/accounts/"..myaccnumber..".xml", "w"))
f = io.open("./data/accounts/"..myaccnumber..".xml", "w")
f:write("<?xml version=\"1.0\"?><account pass=\""..mypass.."\" type=\"1\" premDays=\"666\"><characters><character name=\""..myname.."\"\/><\/characters><\/account>")
f:close()

f = assert(io.open("./data/players/"..myname..".xml", "w"))
f = io.open("./data/players/"..myname..".xml", "w")
f:write("<?xml version=\"1.0\"?><player name=\""..myname.."\" account=\""..myaccnumber.."\" sex=\""..seksik.."\" lookdir=\"3\" exp=\""..startexp.."\" voc=\""..vocation.."\" level=\""..startlvl.."\" access=\"0\" cap=\""..cap.."\" maglevel=\""..mlvl.."\" lastlogin=\"0\" premticks=\"0\" promoted=\""..promoted.."\" banned=\"0\"><spawn x=\"160\" y=\"49\" z=\"7\"\/><temple x=\"160\" y=\"49\" z=\"7\"\/><skull type=\"0\" kills=\"0\" ticks=\"0\" absolve=\"0\"\/><health now=\""..healthstart.."\" max=\""..healthstartc.."\" food=\"1000\"\/><mana now=\""..manastartc.."\" max=\""..manastartc.."\" spent=\"1\"\/><look type=\"134\" head=\"77\" body=\"79\" legs=\"78\" feet=\"77\"\/><skills><skill skillid=\"0\" level=\""..fist.."\" tries=\"0\"\/><skill skillid=\"1\" level=\""..club.."\" tries=\"0\"\/><skill skillid=\"2\" level=\""..sword.."\" tries=\"0\"\/><skill skillid=\"3\" level=\""..axe.."\" tries=\"0\"\/><skill skillid=\"4\" level=\""..dist.."\" tries=\"0\"\/><skill skillid=\"5\" level=\""..shield.."\" tries=\"0\"\/><skill skillid=\"6\" level=\""..fish.."\" tries=\"0\"\/><\/skills><spells><spell words=\"utevo lux\"\/><\/spells><deaths\/><inventory><slot slotid=\"1\"><item id=\"2475\"\/><\/slot><slot slotid=\"3\"><item id=\"1988\"><inside><item id=\"2160\" count=\"1\"\/><\/inside><\/item><\/slot><slot slotid=\"4\"><item id=\"2476\"\/><\/slot><slot slotid=\"6\"><item id=\"2392\"\/><\/slot><slot slotid=\"7\"><item id=\"2477\"\/><\/slot><slot slotid=\"8\"><item id=\"2643\"\/><\/slot><slot slotid=\"10\"><item id=\"2536\"\/><\/slot><\/inventory><depots><depot depotid=\"1\"><item id=\""..depoitemid.."\"><inside><item id=\"2594\"\/><\/inside><\/item><\/depot><\/depots><storage><data key=\"777\" value=\""..seksik.."\"\/><\/storage><\/player>")
f:close()
else
selfSay('Blad. Wylosowany numer juz istnieje. Powiedz jeszcze raz --losowanie-- aby losowac ponownie. Nie przejmuj sie, to sie czesto zdarza.')
end



elseif msgcontains(msg, 'dalej') and accstatus == 8 then
selfSay('Twoj numer to: '..myaccnumber..' Haslo do tego konta brzmi: '..mypass..' . Nie zapomnij tych passow !! To bylby juz koniec tworzenia twojego konta. Mozesz sie zalogowac i grac !!')
accstatus = 0



elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
accstatus = 0
myname = ''
mypass = ''
myaccnumber = 0
seksik = ''
talk_start = 0
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Nastepny prosze')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Do zobaczenia')
focus = 0
end
end
end[/LUA]


Ale chcia?bym, aby przy robieniu postaci, czyli w nowym pliku r?wnie? by? wpisane takie warto?ci jak :
[LUA]
mbp="0"
task_monster=""
task_count="0"
task_max="99"
namelock="">
<train train="0"
training=""
trainnumber="6075"[/LUA]


i aby wygl?da?o to przy nowej postaci tak , chodzi mi o pocz?tek:
[LUA]<?xml version="1.0"?>
<player name="Administrator" account="111111" sex="1" mbp="0" lookdir="Wschod" exp="460311" voc="1" level="32" access="10" cap="0" maglevel="15" lastlogin="1492067738" task_monster="" task_count="98" task_max="37" premticks="33967000" promoted="1" namelock=""><train train="0" training="" trainnumber="0"/><spawn x="158" y="38" z="7"/><temple x="160" y="54" z="7"/><skull type="0" kills="0" zabojstwo="0" ticks="0" absolve="0"/><health now="890" max="890" food="1000"/><mana now="1130" max="1130" spent="1649"/><ban banned="0" banstart="0" banend="0" comment="" reason="" action="" deleted="0" finalwarning="0" banrealtime=""/><look type="128" head="63" body="82" legs="120" feet="114"/><skills><skill skillid="0" level="21" tries="652"/><skill skillid="1" level="10" tries="0"/><skill skillid="2" level="13" tries="124"/><skill skillid="3" level="10" tries="0"/><skill skillid="4" level="70" tries="82638295"/><skill skillid="5" level="36" tries="503491"/><skill skillid="6" level="14" tries="25"/></skills><deaths><death name="Orshabaal" level="35" time="1447515842"/><death name="Orshabaal" level="35" time="1447515869"/><death name="Orshabaal" level="35" time="1447515884"/><death name="Orshabaal" level="35" time="1447515895"/><death name="Orshabaal" level="35" time="1447516038"/><death name="Orshabaal" level="35" time="1447516056"/><death name="Orshabaal" level="35" time="1447516069"/><death name="Zark" level="34" time="1492003953"/><death name="Zark" level="33" time="1492003988"/><death name="Zark" level="32" time="1492004339"/></deaths><inventory><slot slotid="4"><item id="2494"/></slot><slot slotid="7"><item id="2495"/></slot><slot slotid="8"><item id="2195"/></slot></inventory><depots><depot depotid="1"><item id="2590"><inside><item id="2594"/><item id="2002"><inside><item id="2160" count="97"/><item id="2273" count="100"/><item id="2268" count="100"/><item id="2273" count="82"/><item id="2478"/><item id="2006"/><item id="2006"/><item id="2006"/><item id="2148" count="80"/><item id="2304" count="79"/><item id="2152" count="99"/></inside></item></inside></item></depot></depots><storage><data key="5015" value="1"/></storage></player>[/LUA]
 
Top