Autor Wiadomość
Tutor Kuba
PostWysłany: Pią 22:25, 10 Lis 2006    Temat postu: Ciekawe na temat Więzienia

Więzienie
+ update
działanie: klikasz na gracza runką a on na pewien określony czas ląduje w kiciu. Nie może z niego przed upływem tego czasu wyjść.
Mapa
Będzie nam potrzebna mapa z:
kwadratową lub prostokątną "salą" po środku i z 7 przylegającymi bezpośrednio do niej celami. Z celi nie da się wyjść do "sali"
Actions
Skrypt runy przenoszącej do więzienia:
dodajemy do data/actions/scripts jako celarune.lua

Cytuj:
function onUse(cid, item, frompos, item2, topos)
if getPlayerAccess(cid) >=2 then
creature2pos = {x=topos.x, y=topos.y, z=topos.z, stackpos=253}
creature2 = getThingfromPos(creature2pos)
doPlayerSendTextMessage(cid,22,"Acces sprawdzony")
ileposiedziminut = item.type
if ileposiedziminut == 0 then
ileposiedziminut = 1
end
doPlayerSendTextMessage(cid,22,"Blokada O")
odktorej = os.date('%M')
doktorej = odktorej + ileposiedziminut
if doktorej >= 60 then

dogodziny = os.date('%H') + 1
dominuty = 60 - doktorej
else
dogodziny = os.date('%H')
dominuty = doktorej
end
doPlayerSendTextMessage(cid,22,"Ustalono godzine")
xxx = os.date('%d')
doPlayerSendTextMessage(cid,22,"Ustalono dzien")
if creature2.itemid > 0 then
cela1={x=161, y=220, z=8}
cela2={x=152, y=225, z=8}
cela3={x=154, y=237, z=8}
cela4={x=161, y=242, z=8}
cela5={x=170, y=236, z=8}
cela6={x=170, y=230, z=8}
cela7={x=169, y=223, z=8} doPlayerSendTextMessage(cid,22,"Wykryto obecnosc gracza")
rand = math.random(1,7)
if rand == 1 then
doTeleportThing(creature2.uid,cela1)
elseif rand == 2 then
doTeleportThing(creature2.uid,cela2)
elseif rand == 3 then
doTeleportThing(creature2.uid,cela3)
elseif rand == 4 then
doTeleportThing(creature2.uid,cela4)
elseif rand == 5 then
doTeleportThing(creature2.uid,cela5)
elseif rand == 6 then
doTeleportThing(creature2.uid,cela6)
elseif rand == 7 then
doTeleportThing(creature2.uid,cela7)
end
doPlayerSendTextMessage(cid,22,"Teleportowano")
setPlayerStorageValue(creature2.uid,328,dominuty)
setPlayerStorageValue(creature2.uid,326,dogodziny)
setPlayerStorageValue(creature2.uid,327,xxx)
doPlayerSendTextMessage(cid,22,"Kara zapisana")
doPlayerSendTextMessage(cid,22,"Poszedl siedziec na kilka minut.")
doPlayerSendTextMessage(creature2.uid,18,"Kara wynosi do 100 minut w wiezieniu, nie wiesz na ile cie GM posadzil.")
else
doPlayerSendCancel(cid,"Pudlo.")
end
else
doPlayerSendCancel(cid,"IDZ Z TYM PRZEDMIOTEM DO GM MACIEJA A DOSTANIESZ WYSOKA NAGRODE")
end
return 1
end


wartości zaznaczone na zielono wpisujemy zgodnie z tym co narysowaliśmy na swojej mapie.
(karzda z cel to jedno z pól w calach na mapie.)

a następnie dodajemy do pliku data/actions/actions.xml linijke :

Cytuj:
<action itemid="XXXX" script="celarune.lua" />


zastępując znaki XXXX dowolnym numerem RUNY !!!!!


Ilość minut spędzonych w więzieniu jest równa ILOŚCI POCISKÓW runy. Pociski nie ubywają podczas zużywania !!!!



NPC
do data/npc jako klawisz.xml

Cytuj:


focus = 0
talk_start = 0
target = 0
cname = ''
following = false
attacking = false
gopos = os.clock()
czas = 0
godzina1 = 0
dzisiaja = 0
dzisiaj = 0
way = 1
changeway = 0
vx = 0
vy = 0
vz = 0
cx = 0
cy = 0
cx = 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)
cname = creatureGetName(cid)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
czydzisiaj = getPlayerStorageValue(cid,327)
dzisiaj = os.date('%d')
setPlayerStorageValue(cid,331,dzisiaj)
dzisiaja = getPlayerStorageValue(cid,331)
if czydzisiaj == dzisiaja then

godzina = os.date('%H')
minuta = os.date('%M')
doktorejh = getPlayerStorageValue(cid,326)
doktorejm = getPlayerStorageValue(cid,328)
setPlayerStorageValue(cid,333,godzina)

ileh = godzina - doktorejh

if ileh < 2 then

godzina1 = getPlayerStorageValue(cid,333)
if doktorejh == godzina1 then

setPlayerStorageValue(cid,332,minuta)
minuta1 = getPlayerStorageValue(cid,332)
if doktorejm > minuta1 then
selfSay('Cicho tam !! Jeszcze nie wychodzisz !!! Siedzisz jeszcze pare minut')
else
selfSay('Nastepnym razem zachowuj sie poprawnie.')
selfSay('/send ' .. cname .. ', 160 54 7')
end
else
selfSay('Cicho tam !!! Jeszcze sobie posiedzisz troszke !!!!')
end





else
selfSay('Nastepnym razem zachowuj sie poprawnie, posiedziales pare godzin i widzisz jaki jestes spokojny?')
selfSay('/send ' .. cname .. ', 160 54 7')
end
else
selfSay('Nastepnym razem zachowuj sie poprawnie to nie bedziesz siedzial calego dnia.')
selfSay('/send ' .. cname .. ', 160 54 7')
end

end

end


function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Macie za swoje CHAMY !!!!!')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('I nie mysl ze nie patrze !!!!')
focus = 0
end
end


if (os.clock() - gopos) > 1 then
vx, vy, vz = selfGetPosition()
if vx == cx and vy == cy then

if way == 1 then
way = 2
ny = cy + 1
nx = cx

elseif way == 2 then
way = 3
nx = cx + 1
ny = cy

elseif way ==3 then
way = 4
nx = cx
ny = cy - 1

elseif way == 4 then
way = 1
ny = cy
nx = cx - 1

end
else
cx, cy, cz = selfGetPosition()
if way == 1 then
ny = cy
nx = cx - 1

elseif way == 2 then
ny = cy + 1
nx = cx

elseif way == 3 then
nx = cx + 1
ny = cy
elseif way == 4 then
nx = cx
ny = cy - 1
end

end
gopos = os.clock()
moveToPosition(nx, ny, cz)

end



end





gotowe

@@@@
pierwsza uwaga :
NPC zaczynać trase swą musi od gornej krawędzi trasy. Po update nie wymaga konfiguracji.@@@@
druga uwaga:
Jeśli dysponujemy czymś takim jak teleport rune albo cokolwiek co nas teleportuje to aby zablokować ucieczke z więzienia dokonujemy w skrypcie teleportera następującej modyfikacji:
zaraz po linijce:

Cytuj:
function onUse(cid, item, frompos, item2, topos)

dodajemy linijki:

Cytuj:
posp = getPlayerPosition(cid)
mozna = getTilePzInfo(posp)
if mozna == 0 then


a na końcu tuż przed linijką zawierającą słowo "end" dodajemy

Cytuj:
else
doPlayerSendCancel(cid,"Nie w Protection zone !!!.")
end


a całą powierzchnie więzienia pokrywamy "PZ"
@@
masz jakiś problem z odpaleniem tego ?? Najpier sprawdz czy nie zrobiłeś błędu a potem mi napisz wiad. prywatną !!!

Powered by phpBB © 2001, 2005 phpBB Group