Master Sorcer |
Moderator |
|
|
Dołączył: 19 Sie 2005 |
Posty: 36 |
Przeczytał: 0 tematów
Ostrzeżeń: 0/8
|
Skąd: Łódź |
|
|
|
|
|
|
|
|
Tutaj zamieszczam nie dokonca spolszczonego NPC ktory zaklada gildie na YurOTSie (pracuje caly czas nad calkowitym spolszceniem GO)
Kod: | focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
gstat = 0 -- guild status
grank = '' -- guild rank
gname = '' -- guild name
cname = '' -- name of player who talks to us
pname = '' -- name of some other player
maxnamelen = 30
maxranklen = 20
maxtitlelen = 20
leaderlevel = 50
NONE = 0
INVITED = 1
MEMBER = 2
VICE = 3
LEADER = 4
allow_pattern = '^[a-zA-Z0-9 -]+$'
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)
cname = creatureGetName(cid)
if ((string.find(msg, '(%a*)czesc(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj ' .. cname .. '! W czym moge ci pomoc?')
talk_state = 0
focus = cid
talk_start = os.clock()
elseif string.find(msg, '(%a*)czesc(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. cname .. '! Nie widzisz ze jest kolejka!? Zaraz do ciebie podejde.')
elseif string.find(msg, '(%a*)nara(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Do zobaczenia, ' .. cname .. '!')
talk_state = 0
focus = 0
talk_start = 0
elseif focus == cid then
if talk_state == 0 then
msg = string.lower(msg)
if msgcontains(msg, 'nowa gildia') then -- found a new guild
level = getPlayerLevel(cname)
if level >= leaderlevel then
gstat = getPlayerGuildStatus(cname)
if gstat == NONE or gstat == INVITED then
selfSay('Jaka chcesz miec nazwe gildii?')
talk_state = 1
elseif gstat == MEMBER or gstat == VICE or gstat == LEADER then
selfSay('Sorry, jestes juz czlonkiem innej gildii.')
talk_state = 0
end
else
selfSay('Sorry, potrzebujesz levlu ' .. leaderlevel .. ' zeby zalozyc gildie.')
end
talk_start = os.clock()
elseif msgcontains(msg, 'wejdz') then -- join a guild when invited
gstat = getPlayerGuildStatus(cname)
if gstat == NONE then
selfSay('Sorry, Nie jestes zaproszony do gildii.')
talk_state = 0
elseif gstat == INVITED then
gname = getPlayerGuildName(cname)
selfSay('Do you want to join ' .. gname .. '?')
talk_state = 3
elseif gstat == MEMBER or gstat == VICE or gstat == LEADER then
selfSay('Sorry, jestes juz czlonkiem innej gildii.')
talk_state = 0
end
talk_start = os.clock()
elseif msgcontains(msg, 'wyrzuc') or msgcontains(msg, 'kick') then -- kick player from a guild
gstat = getPlayerGuildStatus(cname)
if gstat == VICE or gstat == LEADER then
selfSay('Kogo chcesz dzisiaj wyrzucic z gildi?')
talk_state = 4
else
selfSay('Sorry, tylko lider lub vice-lider moze wyrzucac z gildi.')
talk_state = 0
end
talk_start = os.clock()
elseif msgcontains(msg, 'zapros') then -- invite player to a guild
gstat = getPlayerGuildStatus(cname)
if gstat == VICE or gstat == LEADER then
selfSay('Kogo chcesz zaprosic do gildi?')
talk_state = 5
else
selfSay('Sorry, tylko lider lub vice-lider moze dawac zaproszenia do gildii.')
talk_state = 0
end
talk_start = os.clock()
elseif msgcontains(msg, 'opusc') then -- leave a guild
gstat = getPlayerGuildStatus(cname)
if gstat == NONE or gstat == INVITED then
selfSay('Juz nie jestes w gildii.')
talk_state = 0
elseif gstat == MEMBER or gstat == VICE then
gname = getPlayerGuildName(cname)
selfSay('Czy chcesz opuscic ta gildie ' .. gname .. '?')
talk_state = 7
elseif gstat == LEADER then
selfSay('Jestes liderm gildi, jesli ja opuscisz nikt nie bedzie mogl zapraszac nowych czlonkow. Czy jestes pewien?')
talk_state = 7
end
elseif msgcontains(msg, 'oddaj lidera') then -- pass leadership
gstat = getPlayerGuildStatus(cname)
if gstat == LEADER then
selfSay('Kto ma byc nowym liderem?')
talk_state = 8
else
selfSay('Sorry, tylko lider moze dac lidera innemu czlonkowi gildii.')
talk_state = 0
end
elseif msgcontains(msg, 'zastepca') then -- set vice leader
gstat = getPlayerGuildStatus(cname)
if gstat == LEADER then
selfSay('Which member do you want to promote to vice-leader?')
talk_state = 9
else
selfSay('Sorry, tylko lider moze mianowac czlonka na zastepce-lidera.')
talk_state = 0
end
elseif msgcontains(msg, 'czlonek') then -- remove vice-leader
gstat = getPlayerGuildStatus(cname)
if gstat == LEADER then
selfSay('Kotorego zastepce-lidera chcesz degradowac do zwyklego gracza?')
talk_state = 10
else
selfSay('Sorry, tylko lider mzoe degradowac zastepce-lidera.')
talk_state = 0
end
elseif msgcontains(msg, 'podpis') then
gstat = getPlayerGuildStatus(cname);
if gstat == LEADER then
selfSay('Ktoremu czlonkowi chcesz zmienic podpis?')
talk_state = 11
else
selfSay('Sorry, tylko lider moze zmieniac podpisy czlonkom gildii.')
talk_state = 0
end
end
else -- talk_state != 0
talk_start = os.clock()
if talk_state == 1 then -- get name of new guild
gname = msg
if string.len(gname) <= maxnamelen then
if string.find(gname, allow_pattern) then
if foundNewGuild(gname) == 0 then
selfSay('Sorry, there is already a guild with that name.')
talk_state = 0
else
selfSay('Co ma sie znajdowac w podpisie?')
talk_state = 2
end
else
selfSay('Sorry, guild name contains illegal characters.')
talk_state = 0
end
else
selfSay('Sorry, guild name cannot be longer than ' .. maxnamelen .. ' characters.')
talk_state = 0
end
elseif talk_state == 2 then -- get rank of leader
grank = msg
if string.len(grank) <= maxranklen then
if string.find(grank, allow_pattern) then
setPlayerGuild(cname,LEADER,grank,gname)
selfSay('You are now leader of your new guild.')
talk_state = 0
else
selfSay('Sorry, rank name contains illegal characters.')
talk_state = 0
end
else
selfSay('Sorry, rank name cannot be longer than ' .. maxranklen .. ' characters.')
talk_state = 0
end
elseif talk_state == 3 then -- join a guild
if msg == 'yes' then
setPlayerGuildStatus(cname, MEMBER)
selfSay('You are now member of a guild.')
talk_state = 0
else
selfSay('Co jeszcze moge dla ciebie zrobic?')
talk_state = 0
end
elseif talk_state == 4 then -- kick player
pname = msg
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if cname == pname then
selfSay('By wyrzucic siebi z gildii powiedz: OPUSC.')
talk_state = 0
elseif gname == gname2 then
gstat2 = getPlayerGuildStatus(pname)
if gstat > gstat2 then
clearPlayerGuild(pname)
selfSay('Opuscciles ' .. pname .. 'sowja gildie .')
talk_state = 0
else
selfSay('Sorry, zastepcy-lidera moga wyrzucac jedynie zwyklych czlonkow gildi.')
talk_state = 0
end
else
selfSay('Sorry, ' .. pname .. ' on/ona nie jest w towjej gildi.')
talk_state = 0
end
elseif talk_state == 5 then -- get invited name
pname = msg
gstat = getPlayerGuildStatus(pname)
if gstat == MEMBER or gstat == VICE or gstat == LEADER then
selfSay('Sorry, ' .. pname .. ' is in another guild.')
talk_state = 0
else
selfSay('Jaki podpis chcesz dac jej lub jemu?')
talk_state = 6
end
elseif talk_state == 6 then -- get invited rank
grank = msg
if string.len(grank) <= maxranklen then
if string.find(grank, allow_pattern) then
gname = getPlayerGuildName(cname)
setPlayerGuild(pname, INVITED, grank, gname)
selfSay('Zostales zaproszony ' .. pname .. ' do twojej gildii.')
talk_state = 0
else
selfSay('Sorry, rank name contains illegal characters.')
talk_state = 0
end
else
selfSay('Sorry, rank name cannot be longer than ' .. maxranklen .. ' characters.')
talk_state = 0
end
elseif talk_state == 7 then -- leave a guild
if msg == 'yes' then
clearPlayerGuild(cname)
selfSay('Opsuciles swoja gildie.')
talk_state = 0
else
selfSay('Co jescze moge dla ciebie zrobic?')
talk_state = 0
end
elseif talk_state == 8 then -- pass leadership
pname = msg
level = getPlayerLevel(pname)
if level >= leaderlevel then
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if gname == gname2 then
setPlayerGuildStatus(cname,MEMBER)
setPlayerGuildStatus(pname,LEADER)
gname = getPlayerGuildName(cname)
selfSay(pname .. ' zostal nowym liderem ' .. gname .. '.')
talk_state = 0
else
selfSay('Sorry, ' .. pname .. ' nie jest to twoja gildia.')
talk_state = 0;
end
else
selfSay('Sorry, ' .. pname .. ' on/ona nie jest dostepna.')
talk_state = 0
end
elseif talk_state == 9 then -- set vice-leader
pname = msg
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if cname == pname then
selfSay('To resign from leadership say pass.')
talk_state = 0
elseif gname == gname2 then
gstat = getPlayerGuildStatus(pname)
if gstat == INVITED then
selfSay('Sorry, ' .. pname .. ' nie zostal jeszcze zaproszony do twojej gildi.');
talk_state = 0
elseif gstat == VICE then
selfSay(pname .. ' jest juz zastepca-lidera.')
talk_state = 0
elseif gstat == MEMBER then
setPlayerGuildStatus(pname, VICE)
selfSay(pname .. ' jest juz zastepca-lidera.')
talk_state = 0
end
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildi.')
talk_state = 0
end
elseif talk_state == 10 then -- set member
pname = msg
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if cname == pname then
selfSay('BY zmienic lidera powiedz: oddaj lidera.')
talk_state = 0
elseif gname == gname2 then
gstat = getPlayerGuildStatus(pname)
if gstat == INVITED then
selfSay('Sorry, ' .. pname .. ' nie jest zaproszony do gildi.');
talk_state = 0
elseif gstat == VICE then
setPlayerGuildStatus(pname, MEMBER)
selfSay(pname .. ' jest teraz wyklym czlonkiem twojej gildi.')
talk_state = 0
elseif gstat == MEMBER then
selfSay(pname .. ' jest juz zwyklym czlonkiem.')
talk_state = 0
end
else
selfSay('Sorry, ' .. pname .. ' nie jest to w twojej gildi.')
talk_state = 0
end
elseif talk_state == 11 then -- get name of player to change title
pname = msg
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if gname == gname2 then
selfSay('Jaki podpis chcesz wpisac jej lub jemu (pwowiedz nic, a bedzie pusto)')
talk_state = 12
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildii.')
talk_state = 0
end
elseif talk_state == 12 then -- get title
if msg == 'none' then
setPlayerGuildTitle(pname, '')
selfSay(pname .. ' teraz ma swoj podpis.')
talk_state = 0
else
if string.len(msg) <= maxtitlelen then
if string.find(msg, allow_pattern) then
setPlayerGuildTitle(pname, msg)
selfSay('Zmieniles podpis ' .. pname .. 'jej/jemu .')
talk_state = 0
else
selfSay('Sorry, title contains illegal characters.')
talk_state = 0
end
else
selfSay('Sorry, Podpis jest za dlugi. Nie moze miec wiecej niz ' .. maxtitlelen .. ' znakow.')
talk_state = 0
end
end
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('Good bye then.')
focus = 0
end
end
end
|
Porsze o komentarze dotyczace tego NPCa i mojej pracy |
|