What's new

Skrypty & Kody Lekka przer?bka Skryptu [7.6]

Status
Not open for further replies.

Budowlan

Advanced User
Joined
Feb 10, 2011
Messages
286
Reaction score
0
Siemka =D Dawno ju? nie bawi?em si? z Tibi? ani z lua/xml i ju? nie pami?tam dosy? du?o.. A wi?c m?j problem polega na tym, ?e chce aby w NPC "Oracle", kt?ry teleportuje z RookGardu na MainLand do 6 levela. Czyli je?li kto? ma 5 level przejdzie na main i tak samo z 6 ale je?li b?dzie mia? 7 to ju? nie :p

M?g?by kto? go tak przerobi??? Poleci rep.

Skrypt:

[LUA]focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
cname = ''
vocation = 0
mainlevel = 5


function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


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

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witam ' .. cname .. '! Jestes gotowy na przeznaczenie?')
talk_state = 0
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Momento rozmawiam z ' .. cname .. '!')

elseif msgcontains(msg, 'bye') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Narazie ' .. cname .. '!')
talk_state = 0
focus = 0
talk_start = 0 elseif focus == cid then
talk_start = os.clock() if talk_state == 0 then
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then wanna go to mainland
level = getPlayerLevel(cname)

if level >= mainlevel then
selfSay('To swietnie kim chcesz byc na MainLand Sorcerer, Druid, Paladin czy moze Knight?')
talk_state = 1
else
selfSay('Ej noo ziomek na main idzie sie od ' .. mainlevel .. ' poziomu!')
talk_state = 0
end
else
selfSay('Przyjdz jak bedziesz gotowy.')
talk_state = 0
end

elseif talk_state == 1 then telling vocation
talk_state = 2

if msgcontains(msg, 'sorcerer') then
selfSay('Na pewno sorcerer! Jestes tego pewien?')
vocation = 1
elseif msgcontains(msg, 'druid') then
selfSay('Na pewno druid! Jestes tego pewien?')
vocation = 2
elseif msgcontains(msg, 'paladin') then
selfSay('Na pewno paladin! Jestes tego pewien?')
vocation = 3
elseif msgcontains(msg, 'knight') then
selfSay('Na pewno knight! Jestes tego pewien?')
vocation = 4
else
selfSay('Wybacz, ale mamy tylko tu 4 profesje.')
vocation = 0
talk_state = 1
end

elseif talk_state == 2 then confirming vocation
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
selfSay('No to git mamy juz profesje teraz mozemy isc na MainLand? Czy jestes tego pewien?')
talk_state = 3
else
selfSay('Jaka bys chcial zostac profesja na MainLand?')
talk_state = 1
end

elseif talk_state == 3 then telling city name
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
selfSay('Powodzenia na MainLand!')
setPlayerVocation(cid,vocation)
setPlayerMasterPos(cid,160,54,7)
selfSay('/send ' .. cname .. ', 160 54 7')

talk_state = 0
focus = 0
talk_start = 0
else
selfSay('Wybacz albo chcesz isc na MainLand albo nie? Decyduj [tak] lub [nie].')
talk_state = 3
end
end
end
end


function onCreatureChangeOutfit(creature)

end


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

Z g?ry dzi?kuje :D
 

Ciamciaj Bigos

&#3585;&#3657;&#3657;&#3657;&#3657;&#3657;&#3657;&
Joined
Jun 6, 2013
Messages
2,081
Reaction score
192
Odp: Lekka przer?bka Skryptu [7.6]

[lua]focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
cname = ''
vocation = 0
mainlevel = 6


function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


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

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witam ' .. cname .. '! Jestes gotowy na przeznaczenie?')
talk_state = 0
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Momento rozmawiam z ' .. cname .. '!')

elseif msgcontains(msg, 'bye') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Narazie ' .. cname .. '!')
talk_state = 0
focus = 0
talk_start = 0 elseif focus == cid then
talk_start = os.clock() if talk_state == 0 then
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then wanna go to mainland
level = getPlayerLevel(cname)

if level <= mainlevel then
selfSay('To swietnie kim chcesz byc na MainLand Sorcerer, Druid, Paladin czy moze Knight?')
talk_state = 1
else
selfSay('Aby przejsc dalej musisz miec poziom mniejszy badz rowny ' .. mainlevel .. '!')
talk_state = 0
end
else
selfSay('Przyjdz jak bedziesz gotowy.')
talk_state = 0
end

elseif talk_state == 1 then telling vocation
talk_state = 2

if msgcontains(msg, 'sorcerer') then
selfSay('Na pewno sorcerer! Jestes tego pewien?')
vocation = 1
elseif msgcontains(msg, 'druid') then
selfSay('Na pewno druid! Jestes tego pewien?')
vocation = 2
elseif msgcontains(msg, 'paladin') then
selfSay('Na pewno paladin! Jestes tego pewien?')
vocation = 3
elseif msgcontains(msg, 'knight') then
selfSay('Na pewno knight! Jestes tego pewien?')
vocation = 4
else
selfSay('Wybacz, ale mamy tylko tu 4 profesje.')
vocation = 0
talk_state = 1
end

elseif talk_state == 2 then confirming vocation
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
selfSay('No to git mamy juz profesje teraz mozemy isc na MainLand? Czy jestes tego pewien?')
talk_state = 3
else
selfSay('Jaka bys chcial zostac profesja na MainLand?')
talk_state = 1
end

elseif talk_state == 3 then telling city name
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
selfSay('Powodzenia na MainLand!')
setPlayerVocation(cid,vocation)
setPlayerMasterPos(cid,160,54,7)
selfSay('/send ' .. cname .. ', 160 54 7')

talk_state = 0
focus = 0
talk_start = 0
else
selfSay('Wybacz albo chcesz isc na MainLand albo nie? Decyduj [tak] lub [nie].')
talk_state = 3
end
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() talk_start) > 45 then
if focus > 0 then
selfSay('Nastepny prosze...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Narazie.')
focus = 0
end
end
end[/lua]
 

Budowlan

Advanced User
Joined
Feb 10, 2011
Messages
286
Reaction score
0
Odp: Lekka przer?bka Skryptu [7.6]

Dzi?ki! ;D

#Refresh
Nie dzia?a, wyskakuje b??d w silniku


[LUA]Backstrace:
NpcScript: onThink: blad lua: attempt to call a nil value
[/LUA]
Pomo?e kto??
 
Last edited:

Azuusiek

Advanced User
Joined
May 11, 2015
Messages
258
Reaction score
36
Odp: Lekka przer?bka Skryptu [7.6]

[lua] focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
cname = ''
vocation = 0
mainlevel = 5
maxlevel = 7

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


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

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witam ' .. cname .. '! Jestes gotowy na przeznaczenie?')
talk_state = 0
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Momento rozmawiam z ' .. cname .. '!')

elseif msgcontains(msg, 'bye') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Narazie ' .. cname .. '!')
talk_state = 0
focus = 0
talk_start = 0 elseif focus == cid then
talk_start = os.clock() if talk_state == 0 then
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then -- wanna go to mainland
level = getPlayerLevel(cname)

if level >= mainlevel and level <= maxlevel then
selfSay('To swietnie kim chcesz byc na MainLand Sorcerer, Druid, Paladin czy moze Knight?')
talk_state = 1
else
selfSay('Ej noo ziomek na main mozesz isc od ' .. mainlevel .. ' do ' .. maxlevel .. ' poziomu !')
talk_state = 0
end
else
selfSay('Przyjdz jak bedziesz gotowy.')
talk_state = 0
end

elseif talk_state == 1 then -- telling vocation
talk_state = 2

if msgcontains(msg, 'sorcerer') then
selfSay('Na pewno sorcerer! Jestes tego pewien?')
vocation = 1
elseif msgcontains(msg, 'druid') then
selfSay('Na pewno druid! Jestes tego pewien?')
vocation = 2
elseif msgcontains(msg, 'paladin') then
selfSay('Na pewno paladin! Jestes tego pewien?')
vocation = 3
elseif msgcontains(msg, 'knight') then
selfSay('Na pewno knight! Jestes tego pewien?')
vocation = 4
else
selfSay('Wybacz, ale mamy tylko tu 4 profesje.')
vocation = 0
talk_state = 1
end

elseif talk_state == 2 then -- confirming vocation
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
selfSay('No to git mamy juz profesje teraz mozemy isc na MainLand? Czy jestes tego pewien?')
talk_state = 3
else
selfSay('Jaka bys chcial zostac profesja na MainLand?')
talk_state = 1
end

elseif talk_state == 3 then -- telling city name
if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
selfSay('Powodzenia na MainLand!')
setPlayerVocation(cid,vocation)
setPlayerMasterPos(cid,160,54,7)
selfSay('/send ' .. cname .. ', 160 54 7')

talk_state = 0
focus = 0
talk_start = 0
else
selfSay('Wybacz albo chcesz isc na MainLand albo nie? Decyduj [tak] lub [nie].')
talk_state = 3
end
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() talk_start) > 45 then
if focus > 0 then
selfSay('Nastepny prosze...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Narazie.')
focus = 0
end
end
end[/lua]
maxlevel - maksymalny level do wyjscia
 

Budowlan

Advanced User
Joined
Feb 10, 2011
Messages
286
Reaction score
0
Odp: Lekka przer?bka Skryptu [7.6]

Dzi?ki zaraz zobacz? :p
 
Status
Not open for further replies.
Top