[x.x][Inne]Kup los, miej szczescie, wygraj fortune :)

Status
Zamknięty.

atyll

Active User
Zarejestrowany
Dołączył
Kwiecień 8, 2008
Posty
60
Liczba reakcji
2
To nie moje , Nick autora to : Devoy
Mam nadzieje ze komus sie przyda ;).
w data/npc/scripts tworzymy lotek.lua
Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
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)
     msg = string.lower(msg)
     -- greeting phrase
if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then
        selfSay('Hello ' .. creatureGetName(cid) .. '! I lottery tickets for 1k each.\nPlease say "ticket".\nFor Help say "help"!')
        focus = cid
        selfLook(cid)
      talk_start = os.clock()
     elseif focus == cid then
      talk_start = os.clock()
      if msgcontains(msg, 'help') then
      selfSay('You must buy lottery ticket and go to lotter machine for look you win.')
      elseif msgcontains(msg, 'ticket') then
      buy(cid,2318,1,1000)
      elseif msgcontains(msg, 'second addon') then
      itemstatus = DoRemoveItem(cid,2215,1)
        if itemstatus == -1 then
       selfSay('Sorry you dont have win addon item.')
      else
      addon(cid,2)
      focus = 0
      talk_start = 0
      end
      elseif msgcontains(msg, 'first addon') then
      itemstatus = DoRemoveItem(cid,2216,1)
        if itemstatus == -1 then
       selfSay('Sorry you dont have win addon item.')
      else
      addon(cid,1)
      focus = 0
      talk_start = 0
      end
      elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
         selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
         focus = 0
         talk_start = 0
      end
     end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus == 0 then
      selfWalk(4)
   end     
if (os.clock() - talk_start) > 30 then
       if focus > 0 then
          selfSay('Next Please...')
       end
      focus = 0
    end
   if focus ~= 0 then
      if getDistanceToCreature(focus) > 3 then
         selfSay('Good bye then.')
         focus = 0
      end
   end
end
data/npc/ tworzymy plik: lottery.xml
Kod:
<?xml version="1.0"?>
<npc name="Lottery" script="data/npc/scripts/lotek.lua" access="3">
    <look type="134" head="19" body="114" legs="94" feet="94"/>
</npc>
terwaz w data/actions/scripts tworzymy plik lotek.lua :>
Kod:
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2318 then
randomeczek = math.random(500,2000)
if randomeczek >= 500 and randomeczek <= 537 then
  doPlayerAddItem(cid,2160,50)
doPlayerSendCancel(cid,"You Win 500k.")
doSendMagicEffect(topos,12)
elseif randomeczek >= 538 and randomeczek <= 539 then
  doPlayerAddItem(cid,2216,1)
doPlayerSendCancel(cid,"You Win a First Addon! go to lottery npc and give this item.")
doSendMagicEffect(topos,12)
elseif randomeczek >= 540 and randomeczek <= 541 then
  doPlayerAddItem(cid,2215,1)
doPlayerSendCancel(cid,"You Win a Second Addon! go to lottery npc and give this item.")
doSendMagicEffect(topos,12)
elseif randomeczek >= 542 and randomeczek <= 601 then
  doPlayerAddItem(cid,2160,25)
doPlayerSendCancel(cid,"You Win 250k.")
elseif randomeczek >= 602 and randomeczek <= 750 then
  doPlayerAddItem(cid,2160,12)
  doPlayerAddItem(cid,2152,50)
doPlayerSendCancel(cid,"You Win 125k.")
elseif randomeczek >= 751 and randomeczek <= 901 then
  doPlayerAddItem(cid,2160,7)
  doPlayerAddItem(cid,2152,50)
doPlayerSendCancel(cid,"You Win 75k.")
elseif randomeczek >= 902 and randomeczek <= 1152 then
  doPlayerAddItem(cid,2160,3)
doPlayerSendCancel(cid,"You Win 30k.")
elseif randomeczek >= 1153 and randomeczek <= 1294 then
  doPlayerAddItem(cid,2160,1)
  doPlayerAddItem(cid,2152,50)
doPlayerSendCancel(cid,"You Win 15k.")
elseif randomeczek >= 1295 and randomeczek <= 1500 then
  doPlayerAddItem(cid,2160,1)
doPlayerSendCancel(cid,"You Win 10k.")
elseif randomeczek >= 1501 and randomeczek <= 1701 then
  doPlayerAddItem(cid,2152,2)
doPlayerSendCancel(cid,"You Win 2k.")
elseif randomeczek >= 1702 and randomeczek <= 2000 then
doPlayerSendCancel(cid,"You lost.")
end
if item.type > 1 then
     doChangeTypeItem(item.uid,2134)
  else
     doRemoveItem(item.uid,1)
  end
end   
return 1
end
i w data/actions/actions.xml dopisujemy linijk? ;).
Kod:
<action itemid="2318" script="lotek.lua" />
 
Ostatnio edytowane przez moderatora:
Temat przenios?em. Jak dodajesz jaki? skrypt to nie kopiuj bezmy?lnie - taka moja uwaga. Co do skryptu to jest dobry.

Pozdrawiam,
Napster.

@down:
Wszystko jedno ;).
 
Ostatnia edycja:
Nick autora to : Devoy

nie prawda!

Nick autora to : Marekexp

kt?ry plagiatuje, ty czy devoy? : P
 
Pytanko, od kiedy to NPCki deklarujemy w actions.XML?? Popraw albo zostanie wywalone do kosza.
 
niezabardzo kapuje oco chodzi w tym skryptcie moze ktos mi wytlumaczyc ??
 
Chyba chodzi o to, ?e co x los wygrywa jaki? item czy co? ;)
 
Poszukaj takiego skryptu pod 8.1
Zap?ace reputem!
 
mnie si? bardzo podoba pomys? ale przydaloby sie to pod 8.0 :) tibia lotto hehe
 
Nie obchodzi mnie kto tonapisa?.Dlamnie to jest najmniej warzne.Obchodzi mnie czy to dzia?a...A tu dupa NIE DZIA?A
 
Widzia?em to samo tylko na tibii 8.0 i by? bardzo fajny fajnie ?e dale? to tutaj tylko szkoda ?e 7.6 ale i tak 8/10
 
Odp: Kup los, miej szczescie, wygraj fortune :)

Odp: Kup los, miej szczescie, wygraj fortune :)

Zgadzam sie z Roskos ...

Nie Dzia?a ! Szkoda;/:mad:
 
Odp: [x.x][Inne]Kup los, miej szczescie, wygraj fortune :)

?al co ma wsp?lnego ,,data/npc/scripts " i data/actions/actions.xml <- to do cz?owieka co skopiowa? nawet nie rzucaj?c okiem na g?upot? autora...

Zdecyduj si?... <- to do Autora skryptu
 
Odp: [x.x][Inne]Kup los, miej szczescie, wygraj fortune :)

co to za g?wno? to jest NPC kt?ry jest w actions??:confused:
loool to kitu z czym? takim a nie dzia?a bo jest ?le wykonane
(ale mnie zdziwi?a taka g?upota w pisaniu skrypt?w)
:confused:
 
Odp: [x.x][Inne]Kup los, miej szczescie, wygraj fortune :)

m?g?by? to poprawi? ?? :confused:

i nie dzia?a to na 8.4 ;|

popraw a + p?jdzie :P


Edit ; zrobi?em ale mam problem ;|

Kod:
[18/03/2009  11:34:11] Lua Script Error: [Npc interface] 
[18/03/2009  11:34:11] data/npc/scripts/lotek.lua:onThink

[18/03/2009  11:34:11] data/npc/scripts/lotek.lua:65: attempt to call global 'selfWalk' (a nil value)
[18/03/2009  11:34:11] stack traceback:
[18/03/2009  11:34:11] 	data/npc/scripts/lotek.lua:65: in function <data/npc/scripts/lotek.lua:63>


ale jak chce ktos to naprawic to prosze poprawione

pierw : data/npc/scripts/lotek
Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
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)
     msg = string.lower(msg)
     -- greeting phrase
if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then
        selfSay('Hello ' .. creatureGetName(cid) .. '! I lottery tickets for 1k each.\nPlease say "ticket".\nFor Help say "help"!')
        focus = cid
        selfLook(cid)
      talk_start = os.clock()
     elseif focus == cid then
      talk_start = os.clock()
      if msgcontains(msg, 'help') then
      selfSay('You must buy lottery ticket and go to lotter machine for look you win.')
      elseif msgcontains(msg, 'ticket') then
      buy(cid,2318,1,1000)
      elseif msgcontains(msg, 'second addon') then
      itemstatus = DoRemoveItem(cid,2215,1)
        if itemstatus == -1 then
       selfSay('Sorry you dont have win addon item.')
      else
      addon(cid,2)
      focus = 0
      talk_start = 0
      end
      elseif msgcontains(msg, 'first addon') then
      itemstatus = DoRemoveItem(cid,2216,1)
        if itemstatus == -1 then
       selfSay('Sorry you dont have win addon item.')
      else
      addon(cid,1)
      focus = 0
      talk_start = 0
      end
      elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
         selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
         focus = 0
         talk_start = 0
      end
     end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus == 0 then
      selfWalk(4)
   end     
if (os.clock() - talk_start) > 30 then
       if focus > 0 then
          selfSay('Next Please...')
       end
      focus = 0
    end
   if focus ~= 0 then
      if getDistanceToCreature(focus) > 3 then
         selfSay('Good bye then.')
         focus = 0
      end
   end
end

teraz /data/npc/robimy lottery
Kod:
<npc name="Lottery" script="data/npc/scripts/lotek.lua" access="3">
    <look type="134" head="19" body="114" legs="94" feet="94"/>
</npc>

teraz actions

data/actions/scripts/robimy lotek
Kod:
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2318 then
randomeczek = math.random(500,2000)
if randomeczek >= 500 and randomeczek <= 537 then
  doPlayerAddItem(cid,2160,50)
doPlayerSendCancel(cid,"You Win 500k.")
doSendMagicEffect(topos,12)
elseif randomeczek >= 538 and randomeczek <= 539 then
  doPlayerAddItem(cid,2216,1)
doPlayerSendCancel(cid,"You Win a First Addon! go to lottery npc and give this item.")
doSendMagicEffect(topos,12)
elseif randomeczek >= 540 and randomeczek <= 541 then
  doPlayerAddItem(cid,2215,1)
doPlayerSendCancel(cid,"You Win a Second Addon! go to lottery npc and give this item.")
doSendMagicEffect(topos,12)
elseif randomeczek >= 542 and randomeczek <= 601 then
  doPlayerAddItem(cid,2160,25)
doPlayerSendCancel(cid,"You Win 250k.")
elseif randomeczek >= 602 and randomeczek <= 750 then
  doPlayerAddItem(cid,2160,12)
  doPlayerAddItem(cid,2152,50)
doPlayerSendCancel(cid,"You Win 125k.")
elseif randomeczek >= 751 and randomeczek <= 901 then
  doPlayerAddItem(cid,2160,7)
  doPlayerAddItem(cid,2152,50)
doPlayerSendCancel(cid,"You Win 75k.")
elseif randomeczek >= 902 and randomeczek <= 1152 then
  doPlayerAddItem(cid,2160,3)
doPlayerSendCancel(cid,"You Win 30k.")
elseif randomeczek >= 1153 and randomeczek <= 1294 then
  doPlayerAddItem(cid,2160,1)
  doPlayerAddItem(cid,2152,50)
doPlayerSendCancel(cid,"You Win 15k.")
elseif randomeczek >= 1295 and randomeczek <= 1500 then
  doPlayerAddItem(cid,2160,1)
doPlayerSendCancel(cid,"You Win 10k.")
elseif randomeczek >= 1501 and randomeczek <= 1701 then
  doPlayerAddItem(cid,2152,2)
doPlayerSendCancel(cid,"You Win 2k.")
elseif randomeczek >= 1702 and randomeczek <= 2000 then
doPlayerSendCancel(cid,"You lost.")
end
if item.type > 1 then
     doChangeTypeItem(item.uid,2134)
  else
     doRemoveItem(item.uid,1)
  end
end   
return 1
end

teraz data/actions/actions i robimy
Kod:
	<action itemid="2318" script="lotek.lua" />

a ?eby to dzia?a?o to nie wiem nie bawie sie w skryptera wiec prosze kogo? ?eby to zrobi? ;))
 
Odp: [x.x][Inne]Kup los, miej szczescie, wygraj fortune :)

Nie polecam. Nie podoba mi si? skrypt. 2/10 za wysi?ek przekopiowania.
 
Odp: [x.x][Inne]Kup los, miej szczescie, wygraj fortune :)

Prosz? o edit tematu! Zosta?y sklejone dwie r??ne czynno?ci.. prosz?, w pierwszym kodzie mamy 2 r??ne:

Kod:
end
data/npc/ tworzymy plik: lottery.xml
Kod:
<?xml version="1.0"?>
<npc name="Lottery" script="data/npc/scripts/lotek.lua" access="3">
    <look type="134" head="19" body="114" legs="94" feet="94"/>
</npc>
[B]terwaz w data/actions/scripts tworzymy plik lotek.lua :>
Kod:[/B]
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 2318 then
randomeczek = math.random(500,2000)
if randomeczek >= 500 and randomeczek <= 537 then

@topic
przydatne i fajne 8/10 za posklejanie kod?w
 
Status
Zamknięty.
Back
Do góry