Hakeq
Banned
- Joined
- Mar 23, 2013
- Messages
- 103
- Reaction score
- 6
Witajcie
Jest to nie sensacja lecz okazja
Taki skrypt to 2 min. roboty jak kto? wie gdzie co le?y ale ja wam to uproszcz? i wy tylko dacie ctrl + v i ju? po strachu.
To nale?y wklei? w scripts/npc/data i w guild, i po strachu:ka_huh:
Autor: Sidd
Pozdrawiam,
Hakeq.
Jest to nie sensacja lecz okazja
Taki skrypt to 2 min. roboty jak kto? wie gdzie co le?y ale ja wam to uproszcz? i wy tylko dacie ctrl + v i ju? po strachu.
Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
local talk_state = 0
local gstat = 0 -- guild status
local grank = '' -- guild rank
local gname = '' -- guild name
local cname = '' -- name of player who talks to us
local pname = '' -- name of some other player
local maxnamelen = 30
local maxranklen = 20
local maxnicklen = 20
local leaderlevel = 50
local NONE = 0
local INVITED = 1
local MEMBER = 2
local VICE = 3
local LEADER = 4
local 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('Zegnaj.')
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 (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witam ' .. cname .. '! W czym ci moge pomoc?')
talk_state = 0
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Poczekaj, ' .. cname .. '! Zaraz sie toba zajme.')
elseif msgcontains(msg, 'bye') and (focus == cid) and getDistanceToCreature(cid) < 4 then
selfSay('Zegnaj, ' .. 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, 'found') then -- found a new guild
level = getPlayerLevel(cname)
if level >= leaderlevel then
gstat = getPlayerGuildStatus(cname)
if gstat == NONE or gstat == INVITED then
selfSay('Ja ma sie nazywac twoja gildia?')
talk_state = 1
elseif gstat == MEMBER or gstat == VICE or gstat == LEADER then
selfSay('Przykro mi, ale juz nalezysz do jakies gildii.')
talk_state = 0
end
else
selfSay('Sorry, ale potrzebujesz level ' .. leaderlevel .. ' zeby zalozyc gildie.')
end
talk_start = os.clock()
elseif msgcontains(msg, 'join') then -- join a guild when invited
gstat = getPlayerGuildStatus(cname)
if gstat == NONE then
selfSay('Sorry, ale nie jestes zaproszony do zadnej gildii.')
talk_state = 0
elseif gstat == INVITED then
gname = getPlayerGuildName(cname)
selfSay('Chcesz dolaczyc do gildii ' .. gname .. '?')
talk_state = 3
elseif gstat == MEMBER or gstat == VICE or gstat == LEADER then
selfSay('Przykro mi, ale juz nalezysz do jakies gildii.')
talk_state = 0
end
talk_start = os.clock()
elseif msgcontains(msg, 'exclude') or msgcontains(msg, 'kick') then -- kick player from a guild
gstat = getPlayerGuildStatus(cname)
if gstat == VICE or gstat == LEADER then
selfSay('Kogo chcesz wyrzucic z gildii dzisiaj?')
talk_state = 4
else
selfSay('Sorry, ale tylko lider i vice-lider moze wyrzucac z gildii.')
talk_state = 0
end
talk_start = os.clock()
elseif msgcontains(msg, 'invite') then -- invite player to a guild
gstat = getPlayerGuildStatus(cname)
if gstat == VICE or gstat == LEADER then
selfSay('Kogo chcesz zaprosic do gildii?')
talk_state = 5
else
selfSay('Sorry, ale tylko lider i vice-lider moze zapraszac graczy do gildii.')
talk_state = 0
end
talk_start = os.clock()
elseif msgcontains(msg, 'leave') then -- leave a guild
gstat = getPlayerGuildStatus(cname)
if gstat == NONE or gstat == INVITED then
selfSay('Nie jestes w zadnej gildii.')
talk_state = 0
elseif gstat == MEMBER or gstat == VICE then
gname = getPlayerGuildName(cname)
selfSay('Chcesz odejsc z gildii ' .. gname .. '?')
talk_state = 7
elseif gstat == LEADER then
selfSay('Jestes liderem gildii. Jezeli odejdziesz, nie bedziesz mogl zapraszac nowych graczy do niej. Jestes tego pewny?')
talk_state = 7
end
elseif msgcontains(msg, 'pass') then -- pass leadership
gstat = getPlayerGuildStatus(cname)
if gstat == LEADER then
selfSay('Kto ma zostac nowy liderem?')
talk_state = 8
else
selfSay('Sorry, ale tylko lider moze zrezygnowac ze swojej pozycji.')
talk_state = 0
end
elseif msgcontains(msg, 'vice') 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, ale tylko lider moze promowac na vice-lidera.')
talk_state = 0
end
elseif msgcontains(msg, 'member') then -- remove vice-leader
gstat = getPlayerGuildStatus(cname)
if gstat == LEADER then
selfSay('Ktorego vice-lidera chcesz usunac ze swojej gildii?')
talk_state = 10
else
selfSay('Sorry,ale tylko lider moze usuwac vice-liderow.')
talk_state = 0
end
elseif msgcontains(msg, 'nick') or msgcontains(msg, 'title') then -- set nick
gstat = getPlayerGuildStatus(cname);
if gstat == LEADER then
selfSay('Ktoremu graczowi z gildii chcesz zmienic przypis?')
talk_state = 11
else
selfSay('Sorry, tylko lider moze zmieniac przypisy.')
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, ale juz jest gildia o tej nazwie.')
talk_state = 0
else
selfSay('Jaka range chcialbys miec?')
talk_state = 2
end
else
selfSay('Sorry, ale nazwa gildii jest niepoprawna.')
talk_state = 0
end
else
selfSay('Sorry, nazwa gildii nie moze byc dluzsza niz ' .. maxnamelen .. ' .')
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('Jestes teraz liderem nowej gildii.')
talk_state = 0
else
selfSay('Sorry, ale nazwa rangi jest niepoprawna.')
talk_state = 0
end
else
selfSay('Sorry, ale nazwa rangi nie moze byc dluzsza niz ' .. maxranklen .. ' .')
talk_state = 0
end
elseif talk_state == 3 then -- join a guild
if msg == 'yes' then
setPlayerGuildStatus(cname, MEMBER)
selfSay('Jestes teraz nowym czlonkiem w gildii.')
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('Jak chcesz odejsc powiedz leave.')
talk_state = 0
elseif gname == gname2 then
gstat2 = getPlayerGuildStatus(pname)
if gstat > gstat2 then
clearPlayerGuild(pname)
selfSay('Wyrzuciles ' .. pname .. ' ze swojej gildii.')
talk_state = 0
else
selfSay('Sorry, tylko vice-lider moze wyrzucac czlonkow gildii.')
talk_state = 0
end
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildii.')
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 .. ' jest w innej gildii.')
talk_state = 0
else
selfSay('Jaka range chcesz dac dla niej lub dla niego?')
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('Przyjeles ' .. pname .. ' do swojej gildii.')
talk_state = 0
else
selfSay('Sorry, ale nazwa rangi jest niepoprawna.')
talk_state = 0
end
else
selfSay('Sorry, ale nazwa rangi nie moze byc dluzsza niz ' .. maxranklen .. ' .')
talk_state = 0
end
elseif talk_state == 7 then -- leave a guild
if msg == 'yes' then
clearPlayerGuild(cname)
selfSay('Opusciles swoja gildie.')
talk_state = 0
else
selfSay('Co jeszcze 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 .. ' jest nowym liderem ' .. gname .. '.')
talk_state = 0
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildii.')
talk_state = 0;
end
else
selfSay('Sorry, ' .. pname .. ' nie jest online.')
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('Jezeli rezygnujesz z liderostwa w swojej gildii powiedz pass.')
talk_state = 0
elseif gname == gname2 then
gstat = getPlayerGuildStatus(pname)
if gstat == INVITED then
selfSay('Sorry, ' .. pname .. ' jeszcze nie dolaczyl do twojej gildii.');
talk_state = 0
elseif gstat == VICE then
selfSay(pname .. ' jest obecnie vice-liderem.')
talk_state = 0
elseif gstat == MEMBER then
setPlayerGuildStatus(pname, VICE)
selfSay(pname .. ' jest teraz vice-liderem twojej gildii.')
talk_state = 0
end
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildii.')
talk_state = 0
end
elseif talk_state == 10 then -- set member
pname = msg
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if cname == pname then
selfSay('Zeby zrezygnowac z liderostwa powiedz pass.')
talk_state = 0
elseif gname == gname2 then
gstat = getPlayerGuildStatus(pname)
if gstat == INVITED then
selfSay('Sorry, ' .. pname .. ' nie dolaczyl jeszcze do twojej gildii.');
talk_state = 0
elseif gstat == VICE then
setPlayerGuildStatus(pname, MEMBER)
selfSay(pname .. ' jest teraz regularnym czlonkiem twojej gildii.')
talk_state = 0
elseif gstat == MEMBER then
selfSay(pname .. ' jest teraz tylko czlonkiem gildii.')
talk_state = 0
end
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildii.')
talk_state = 0
end
elseif talk_state == 11 then -- get name of player to change nick
pname = msg
gname = getPlayerGuildName(cname)
gname2 = getPlayerGuildName(pname)
if gname == gname2 then
selfSay('Jaki chcesz dac mu przypis (powiedz none aby bylo puste)?')
talk_state = 12
else
selfSay('Sorry, ' .. pname .. ' nie jest w twojej gildii.')
talk_state = 0
end
elseif talk_state == 12 then -- get nick
if msg == 'none' then
setPlayerGuildNick(pname, '')
selfSay(pname .. ' obecnie nie ma przypisu.')
talk_state = 0
else
if string.len(msg) <= maxnicklen then
if string.find(msg, allow_pattern) then
setPlayerGuildNick(pname, msg)
selfSay('Zmieniles ' .. pname .. '\'s przypis.')
talk_state = 0
else
selfSay('Sorry, ale przypis jest niepoprawny.')
talk_state = 0
end
else
selfSay('Sorry, ale przypis nie moze byc dluzszy niz ' .. maxnicklen .. ' charakter.')
talk_state = 0
end
end
end
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 45 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
To nale?y wklei? w scripts/npc/data i w guild, i po strachu:ka_huh:
Autor: Sidd
Pozdrawiam,
Hakeq.