Administrator
Administrator
Dołączył: 16 Gru 2006
Posty: 33
Przeczytał: 0 tematów
Ostrzeżeń: 0/5
|
Wysłany: Śro 23:14, 27 Gru 2006 Temat postu: NPC Bankier |
|
|
w data/npc robimy plik Bankier.xml i wpisujemy tam
Kod:
<?xml version="1.0"?>
<npc name="Bankier" script="data/npc/scripts/bank.lua" access="3">
<look type="128" head="24" body="77" legs="10" feet="20"/>
</npc>
Puzniej wchodzimy w data/npc/scripts i robimy plik Bank.lua i wpisujemy tam
Kod:
---bank system by GM Maciej---
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talkstate = 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
talkstate = 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
queststatus = getPlayerStorageValue(cid,1234)
if queststatus == 1 then
selfSay('CZCIGODNY... w czym ja, twoj unizony sluga moge ci pomoc ??')
focus = cid
talk_start = os.clock()
else
selfSay('Witam w moim banku ' .. creatureGetName(cid) .. '! Chcesz "wplacic" czy "pobrac" pieniadze ?? Wplaty dokonujemy po 10k. Codziennie zyskasz 4% tego co wplaciles !! Odsetki naliczamy od ostatniej wplaty !!!')
focus = cid
talk_start = os.clock()
end
end
if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Wybacz, ' .. creatureGetName(cid) .. '! rozmawiam juz z kims.')
end
if msgcontains(msg, 'wplacic') and focus == cid then
bankstatus = getPlayerStorageValue(cid,104)
if bankstatus == -1 then
if pay(cid,10000) then
miesiac = os.date('%m')
rok = os.date('%Y')
dzien = os.date('%d')
---created by GM Maciej---
setPlayerStorageValue(cid,101,rok)
setPlayerStorageValue(cid,102,miesiac)
setPlayerStorageValue(cid,103,dzien)
setPlayerStorageValue(cid,104,1)
setPlayerStorageValue(cid,105,10000)
selfSay('Zalorzyles konto, masz na nim 10k')
else
selfSay('Brak ci pieniedzy aby zalorzyc konto !!')
end
talk_start = os.clock()
else
kapital = getPlayerStorageValue(cid,105)
miesiac = os.date('%m')
rok = os.date('%Y')
dzien = os.date('%d')
kr = getPlayerStorageValue(cid,101)
km = getPlayerStorageValue(cid,102)
kd = getPlayerStorageValue(cid,103)
ilelat = kr - rok
if ilelat == 0 then
ilemiesiecy = miesiac - km
else
mdk = 12 - km
ilemiesiecy = mdk + miesiac
end
if ilemiesiecy == 0 then
iledni = dzien - kd
else
ddk = 30 - kd
ilemieswdniach = ilemiesiecy * 30
iledni = ddk + ilemieswdniach
end
createdbygmmaciej = iledni * kapital * 4
ilekasyd = createdbygmmaciej / 100
ilekasy = kapital + ilekasyd
setPlayerStorageValue(cid,105,ilekasy)
selfSay('Na koncie masz teraz '..ilekasy..' chcesz wplacic kolejne 10k ? "tak" "nie"')
talkstate = 1
end
end
if msgcontains(msg, 'tak') and talkstate == 1 then
if pay(cid,10000) then
miesiac = os.date('%m')
rok = os.date('%Y')
dzien = os.date('%d')
---created by GM Maciej---
setPlayerStorageValue(cid,101,rok)
setPlayerStorageValue(cid,102,miesiac)
setPlayerStorageValue(cid,103,dzien)
ile = getPlayerStorageValue(cid,105)
createdbygmmaciej = ile + 10000
setPlayerStorageValue(cid,105,createdbygmmaciej)
selfSay('Wplaciles kase.')
else
selfSay('Nie masz 10k!!')
end
talk_start = os.clock()
end
if msgcontains(msg, 'nie') and talkstate == 1 then
selfSay('To co mi glowe zawracasz ?.')
talk_start = os.clock()
end
if msgcontains(msg, 'pobrac') and focus == cid then
kapital = getPlayerStorageValue(cid,105)
miesiac = os.date('%m')
rok = os.date('%Y')
dzien = os.date('%d')
kr = getPlayerStorageValue(cid,101)
km = getPlayerStorageValue(cid,102)
kd = getPlayerStorageValue(cid,103)
ilelat = kr - rok
if ilelat == 0 then
ilemiesiecy = km - miesiac
else
mdk = 12 - km
ilemiesiecy = mdk + miesiac
end
if ilemiesiecy == 0 then
iledni = kd - dzien
else
ddk = 30 - kd
ilemieswdniach = ilemiesiecy * 30
iledni = ddk + ilemieswdniach
end
ilepr = iledni * kapital * 4
ilekasyd = ilepr / 100
ilekasy = kapital + ilekasyd
setPlayerStorageValue(cid,105,ilekasy)
selfSay('Masz na koncie '..ilekasy..' ile chcesz wyplacic? "10k" czy "1k" ??')
talkstate = 2
talk_start = os.clock()
end
if msgcontains(msg, '10k') and talkstate == 2 then
ile = getPlayerStorageValue(cid,105)
if ile >= 10000 then
buy(cid,2160,1,0)
ilekasyteraz = ile - 10000
setPlayerStorageValue(cid,105,ilekasyteraz)
talk_start = os.clock()
else
selfSay('Nie masz tyle na koncie')
talk_start = os.clock()
end
end
if msgcontains(msg, '1k') and talkstate == 2 then
ile = getPlayerStorageValue(cid,105)
if ile >= 1000 then
buy(cid,2152,10,0)
ilekasyteraz = ile - 1000
setPlayerStorageValue(cid,105,ilekasyteraz)
talk_start = os.clock()
else
selfSay('Nie masz tyle na koncie')
talk_start = os.clock()
end
end
if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Miles zabawy , ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Nastepny!!!')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Do zobaczenia.')
focus = 0
end
end
end
Post został pochwalony 0 razy
|
|