What's new

A wie? nan PRO?BE DO SKRYPTER?W !

Status
Not open for further replies.

jeanek

Advanced User
Joined
Sep 8, 2008
Messages
162
Reaction score
22
Witam, prosi? bym o skrypt na NPC's . POD 8.10 !
Mia?o by to wygl?da? tak :

Name :GM Shop

Co sprzdaje : Demon legs(id2495)<>Demon armor(id:2494)<>demon helmet<>super sd(id:2263)<>super uh(id:2275)<>super explosion(id:2314)<>super mr (po 100 u?y? id:2292)<>super sword (id :7420)<>super axe(id:7411)<>super club(id:7422)<>crystal wand (id:2184)<>golden helmet (id:2471)<>assassin star(id:7368).

Z g?ry dzi?kuje !
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Wchodzimy w data/npc/ i robimy plik o nazwie GM Shop.XML, po czym w niego wpisujemy:
Code:
<?xml version="1.0"?>

<npc name="GM Shop" script="data/npc/scripts/gmshop.lua" access="3" lookdir="2" autowalk="25">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="130" head="0" body="88" legs="88" feet="88" addons="1"/>
</npc>

Nast?pnie w data/npc/scripts robimy plik gmshop.lua i uzupe?niamy:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('' .. creatureGetName(cid) .. 'Witaj w GM Shopie!')
  		focus = cid
  		talk_start = os.clock()

  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! POrozmiawiam z toba za minute.')

	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'demon legs') then
			buy(cid,2495,getCount(msg),CENA)
		elseif msgcontains(msg, 'demon armor') then
			buy(cid,2494,getCount(msg),CENA)

		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('Do widzenia.')
			focus = 0
			talk_start = 0
		end
	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('Jak chcesz..')
 			focus = 0
 		end
 	end
end
Doda?em tylko 2 itemki, bo przecie? sam, mo?esz to zrobi?, i przy okazji naby? jakiego? Do?wiadczenia, w LUA ;)

Jak doda? nast?pny itemek?
Wystarczy doda? linijk? pod ostatnim itemkiem:
Code:
		elseif msgcontains(msg, '[B]nazwa itemka[/B]') then
			buy(cid,[B]id itemka[/B],getCount(msg),[B]cena[/B])

Pierwszy itemek musi si? zaczyna? z if.
Nie u?ywaj Polskich znak?w, pisz?c skrypt.

Pozdrawiam, Jastro.
 

jeanek

Advanced User
Joined
Sep 8, 2008
Messages
162
Reaction score
22
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Witam, nie dzia?a ;/ b??dy same wyskakuj?
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Daj skrypt LUA tutaj.

Pozdrawiam, Jastro.
 

jeanek

Advanced User
Joined
Sep 8, 2008
Messages
162
Reaction score
22
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

oto i on

local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('' .. creatureGetName(cid) .. 'Witaj w GM Shopie!')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! POrozmiawiam z toba za minute.')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'demon legs') then
buy(cid,2495,getCount(msg),100cc)
elseif msgcontains(msg, 'demon armor') then
buy(cid,2494,getCount(msg),50cc)
elseif msgcontains(msg, 'golden helmet') then
buy(cid,2471,getCount(msg),300cc)
elseif msgcontains(msg, 'super axe') then
buy(cid,7411,getCount(msg),500cc)
elseif msgcontains(msg, 'super sword') then
buy(cid,74201,getCount(msg),500cc)
elseif msgcontains(msg, 'super club') then
buy(cid,7422,getCount(msg),500cc)
elseif msgcontains(msg, 'death wand') then
buy(cid,2184,getCount(msg),50cc)
elseif msgcontains(msg, 'golden bow') then
buy(cid,7438,getCount(msg),200cc)
elseif msgcontains(msg, 'assassin star') then
buy(cid,7368,getCount(msg),25cc)
elseif msgcontains(msg, 'super sd') then
buy(cid,2263,getCount(msg),300cc)
elseif msgcontains(msg, 'super uh') then
buy(cid,2275,getCount(msg),200cc)
elseif msgcontains(msg, 'super uh') then
buy(cid,2275,getCount(msg),200cc)
elseif msgcontains(msg, 'super explosion') then
buy(cid,2314,getCount(msg),200cc)
elseif msgcontains(msg, 'super manarune') then
buy(cid,2292 100,getCount(msg),200cc)


elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Do widzenia.')
focus = 0
talk_start = 0
end
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('Jak chcesz..')
focus = 0
end
end
end
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Zamie?:
Code:
selfSay('' .. creatureGetName(cid) .. 'Witaj w GM Shopie!')
na
Code:
  		selfSay('Witaj, ' .. creatureGetName(cid) .. 'w GM Shopie!')

Popraw Ceny!
W LUA nie stosujemy skr?t?w Pieni??nych :D (GP, CC, SC..)
Ceny podajemy w GP, przyk?adowo
Code:
			buy(cid,2554,getCount(msg),[B]20[/B])

I najlepiej r?b odst?py mi?dzi ka?dym Itemkiem.

Pozdrawiam, Jastro,
 

jeanek

Advanced User
Joined
Sep 8, 2008
Messages
162
Reaction score
22
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

MAM TAK I DALEJ NIE DZIA?A :/

local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj, ' .. creatureGetName(cid) .. 'w GM Shopie!')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! POrozmiawiam z toba za minute.')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'demon legs') then
buy(cid,2495,getCount(msg),10000)
elseif msgcontains(msg, 'demon armor') then
buy(cid,2494,getCount(msg),)
elseif msgcontains(msg, 'golden helmet') then
buy(cid,2471,getCount(msg),10000)
elseif msgcontains(msg, 'super axe') then
buy(cid,7411,getCount(msg),10000)
elseif msgcontains(msg, 'super sword') then
buy(cid,74201,getCount(msg),10000)
elseif msgcontains(msg, 'super club') then
buy(cid,7422,getCount(msg),50000)
elseif msgcontains(msg, 'death wand') then
buy(cid,2184,getCount(msg),10000
elseif msgcontains(msg, 'golden bow') then
buy(cid,7438,getCount(msg),10000)
elseif msgcontains(msg, 'assassin star') then
buy(cid,7368,getCount(msg),10000)
elseif msgcontains(msg, 'super sd') then
buy(cid,2263,getCount(msg),30000)
elseif msgcontains(msg, 'super uh') then
buy(cid,2275,getCount(msg),10000)
elseif msgcontains(msg, 'super uh') then
buy(cid,2275,getCount(msg),10000)
elseif msgcontains(msg, 'super explosion') then
buy(cid,2314,getCount(msg),10000)
elseif msgcontains(msg, 'super manarune') then
buy(cid,2292 100,getCount(msg),10000)


elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Do widzenia.')
focus = 0
talk_start = 0
end
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('Jak chcesz..')
focus = 0
end
end
end
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Nasadzi?e? b??d?w i si? dziwisz:
Masz, powinno dzia?a?:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj, ' .. creatureGetName(cid) .. 'w GM Shopie!')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! POrozmiawiam z toba za minute.')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'demon legs') then
buy(cid,2495,getCount(msg),10000)

elseif msgcontains(msg, 'demon armor') then
buy(cid,2494,getCount(msg),10000)

elseif msgcontains(msg, 'golden helmet') then
buy(cid,2471,getCount(msg),10000)

elseif msgcontains(msg, 'super axe') then
buy(cid,7411,getCount(msg),10000)

elseif msgcontains(msg, 'super sword') then
buy(cid,7420,getCount(msg),10000)

elseif msgcontains(msg, 'super club') then
buy(cid,7422,getCount(msg),50000)

elseif msgcontains(msg, 'death wand') then
buy(cid,2184,getCount(msg),10000)

elseif msgcontains(msg, 'golden bow') then
buy(cid,7438,getCount(msg),10000)

elseif msgcontains(msg, 'assassin star') then
buy(cid,7368,getCount(msg),10000)

elseif msgcontains(msg, 'super sd') then
buy(cid,2263,getCount(msg),30000)

elseif msgcontains(msg, 'super uh') then
buy(cid,2270,getCount(msg),10000)

elseif msgcontains(msg, 'super explosion') then
buy(cid,2314,getCount(msg),10000)

elseif msgcontains(msg, 'super manarune') then
buy(cid,2292,getCount(msg),10000)


elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Do widzenia.')
focus = 0
talk_start = 0
end
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('Jak chcesz..')
focus = 0
end
end
end

Je?eli co? nie dzia?a, to tylko z twojej winy.

Pozdrawiam, Jastro.
 

jeanek

Advanced User
Joined
Sep 8, 2008
Messages
162
Reaction score
22
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

dalej pisze not loaded ;/ (testowales to ? )
 
Last edited:

jeanek

Advanced User
Joined
Sep 8, 2008
Messages
162
Reaction score
22
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Halo halo od?wierzam !!
 

Fikusek

Banned
Joined
May 17, 2010
Messages
248
Reaction score
9
Odp: A wie? nan PRO?BE DO SKRYPTER?W !

Wejdz w data/npc/ i zr?b plik o nazwie gm shop.xml i wklej do niego:

<xml version="1.0"?>
<npc name="GM Shop" script="data/npc/scripts/gmshop.lua" access="5" lookdir="2" autowalk="25">
<mana now="500" max="500"/>
<health now="200" max="200"/>
<look type="135" head="0" body="88" legs="88" feet="88" addons="1"/>
</npc>

Nast?pnie w data/npc/scripts zr?b plik gmshop.lua i wklej:

local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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)

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj, ' .. creatureGetName(cid) .. 'w GM Shopie!')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! POrozmiawiam z toba za minute.')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'demon legs') then
buy(cid,2495,getCount(msg),10000)

elseif msgcontains(msg, 'demon armor') then
buy(cid,2494,getCount(msg),10000)

elseif msgcontains(msg, 'golden helmet') then
buy(cid,2471,getCount(msg),10000)

elseif msgcontains(msg, 'super axe') then
buy(cid,7411,getCount(msg),10000)

elseif msgcontains(msg, 'super sword') then
buy(cid,7420,getCount(msg),10000)

elseif msgcontains(msg, 'super club') then
buy(cid,7422,getCount(msg),50000)

elseif msgcontains(msg, 'death wand') then
buy(cid,2184,getCount(msg),10000)

elseif msgcontains(msg, 'golden bow') then
buy(cid,7438,getCount(msg),10000)

elseif msgcontains(msg, 'assassin star') then
buy(cid,7368,getCount(msg),10000)

elseif msgcontains(msg, 'super sd') then
buy(cid,2263,getCount(msg),30000)

elseif msgcontains(msg, 'super uh') then
buy(cid,2270,getCount(msg),10000)

elseif msgcontains(msg, 'super explosion') then
buy(cid,2314,getCount(msg),10000)

elseif msgcontains(msg, 'super manarune') then
buy(cid,2292,getCount(msg),10000)


elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Do widzenia.')
focus = 0
talk_start = 0
end
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('Jak chcesz..')
focus = 0
end
end
end

Powino Dzia?a? !!! Je?li Nie BD Dzia?a? To Pewnie Zle Cos Zrobi?e?
 
Status
Not open for further replies.
Top