• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

[8.1] Kowal :>

Status
Zamknięty.

Happyde

User
Dołączył
Kwiecień 6, 2008
Posty
43
Liczba reakcji
0
Otoz poniewaz nie umiem robic skryptow lua itp. wiec pisze ten temat. Chcialbym prosic aby ktos pomogl mi zrobic Npc o nazwie kowal. Ten npc zamnialby pare itemkow na inne. No wiec:
1. 300 Demonic Essence (id:6500) na Nightmare Shield (id:6391)
2. dracola's eye (id:6546), countess sorrow's frozen tear (id:6536), 100 entached small sapphire (id:7759), 10 blue poc (id:5912) na Magician Hat (id:2662).
Z gory dziekuje.
 
Otoz poniewaz nie umiem robic skryptow lua itp. wiec pisze ten temat. Chcialbym prosic aby ktos pomogl mi zrobic Npc o nazwie kowal. Ten npc zamnialby pare itemkow na inne. No wiec:
1. 300 Demonic Essence (id:6500) na Nightmare Shield (id:6391)
2. dracola's eye (id:6546), countess sorrow's frozen tear (id:6536), 100 entached small sapphire (id:7759), 10 blue poc (id:5912) na Magician Hat (id:2662).
Z gory dziekuje.

Przy??czam sie to tego ;D
 
Nie wiem czy zadzia?a, mam nadziej? i? tak. Oto skrypt:

B??dny skrypt.
// Kelo
Reszt? chyba sam zrobisz.
Skrypt by me!
 
Ostatnia edycja:
mi nie chodzi :// nie odpisuje i pokazuje si? b??d w silniku
 
ok zajarzy?em b??d, poprawi?em teraz powinno zadzia?a?...
 
pierwszy skrypt jaki tu poda?em poprawi?em, sprawd? czy dzia?a
 
juz pis?em ze NIE chodzi, gdy pisze do niego hi -> ~shield -> yes, on nie odpisuje i pokazuje sie blad w silnkiu
 
chyba wiem jaki jest b??d... a masz przy sobie wszystkie wymagane rzeczy, aby wymieni??? daj screena co ci wyskakuje w konsoli - od niedawna bawi? si? na serio w lua
 
teraz gdy pisze do niego, on daje mi shield'a nawed gdy nie mam potrzebych item?w:

 
Kod:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end

addon_need_premium = 'Sorry, you need a premium account to get addons.'
addon_have_already = 'Sorry, you already have this addon.'
addon_have_not_items = 'Sorry, you don\'t have these items.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys

        if msgcontains(msg, 'hi') then
        selfSay('Change item for "nightmare shield".')

            elseif msgcontains(msg, 'shield') then
            if getPlayerItemCount(cid,6500) >= 300 then
                selfSay('Did you bring me the 300 demonic essence?')
                talk_state = 1
            else
                selfSay('I need a 300 demonic essence, to give you the nightmare shield. Come back when you have them.')
                talk_state = 0
            end

            elseif msgcontains(msg, 'yes') and talk_state == 1 then
            talk_state = 0
            if getPlayerItemCount(cid,6500) >= 300 then
            if doPlayerRemoveItem(cid,6500, 300) == TRUE then
            doPlayerAddItem(cid, 6391, 1)
                        selfSay('Here u are.')
            end
            else
                selfSay(havent_item)
            end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Ok than.')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())




takie cuz u mnie dziala i mysle ze u ciebie tez powinno dzialac
sory ze nie dalem sytatu ale nie wiem jak to zrobic xD(zal.pl)wiecie nowe forum:P
 
Ostatnio edytowane przez moderatora:
Jezeli nie umiesz zrobi? podstawowego NPC to wogole nie bierz sie za "OTS"


no skoro jestes taki genialny to czemu sam nie zrobiles tego skryptu, chlopak ma problem a forum jest od tego zeby pomagac ale widac zawsze beda tacy ludzie jak ty sam nie umie a smieje sie z innych
 
Sharky dziekuje, zaraz przetestuje i dam edita :> a dalbys rade zrobic z ta 2 wymiana? Jesli jest to sie nie doczytalem :p

edit
Nie dziala :) Jest napisane "keyword Hander" < cos takiego, no w kazdym razie blad.
 
Ostatnia edycja:
jaki masz silnik
ale jeszcze dla pewnosci
1 muszisz zrobic npc Kowal.xml
Kod:
<npc name="Kowal" script="data/npc/scripts/wymieniacz.lua" lookdir="3" autowalk="25">
    <health now="500" max="500"/>
    <look type="130" head="20" body="100" legs="50" feet="99"/>
</npc>

potem tworzysz plik wymieniacz.lua
Kod:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end

addon_need_premium = 'Sorry, you need a premium account to get addons.'
addon_have_already = 'Sorry, you already have this addon.'
addon_have_not_items = 'Sorry, you don\'t have these items.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys

        if msgcontains(msg, 'hi') then
        selfSay('Change item for "nightmare shield".')

            elseif msgcontains(msg, 'shield') then
            if getPlayerItemCount(cid,6500) >= 300 then
                selfSay('Did you bring me the 300 demonic essence?')
                talk_state = 1
            else
                selfSay('I need a 300 demonic essence, to give you the nightmare shield. Come back when you have them.')
                talk_state = 0
            end

            elseif msgcontains(msg, 'yes') and talk_state == 1 then
            talk_state = 0
            if getPlayerItemCount(cid,6500) >= 300 then
            if doPlayerRemoveItem(cid,6500, 300) == TRUE then
            doPlayerAddItem(cid, 6391, 1)
                        selfSay('Here u are.')
            end
            else
                selfSay(havent_item)
            end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Ok than.')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Problem po 1 le?y w tym, ?e w zdaniach u?ywasz tego znaku: '.
Jest on brany jako zaznaczenie, wi?c zamiast dracola's eye powinno by? dracolas eye.
2 problem to taki, ?e gdy nawet nie posiadam item?w NPC i tak daje mi to o co prosz?... :)

@Dopiero teraz zauwa?y?em inne posty - przepraszam ;)
 
Nie wiem czy poprzenie NPC dzia?a?y, ale ja zrobi?em w?asnego, na evo dzia?a, bo testowa?em.
data/npc/Kowal.xml
Kod:
<?xml version="1.0"?>

<npc name="Kowal" script="data/npc/scripts/kowal.lua" access="3" lookdir="2" autowalk="25">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="134" head="78" body="88" legs="0" feet="88"/>
</npc>
data/npc/scripts/kowal.lua
Kod:
local focus = 0
local talk_start = 0
local target = 0
local days = 0

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Nara, ' .. creatureGetName(cid) .. '!')
          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('Elo ' .. creatureGetName(cid) .. '! zamieniam itemy.')
 		focus = cid
 		talk_start = os.clock()

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

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

		if msgcontains(msg, 'nightmare shield') or msgcontains(msg, 'shield') then
			selfSay('Chcesz zamienic 300 demonic essence na Nightmare Shield?')
			talk_state = 1

		elseif msgcontains(msg, 'magican hat') or msgcontains(msg, 'hat') then
			selfSay('Chcesz zamienic dracolas eye, countess sorrows frozen tear, 100 entached small sapphire i 10 blue poc na magican hat?')
			talk_state = 2

		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
                                if getPlayerItemCount(cid, 6500) > 299 then			
                                        doPlayerRemoveItem(cid, 6500, 300)
                                        doPlayerAddItem(cid, 6391, 1)
				        selfSay('Dzieki! Oto twoja tarcza!')
                                else
				        selfSay('Nie masz itemow!')
                                end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if msgcontains(msg, 'yes') or msgcontains(msg, 'tak') then
                                if getPlayerItemCount(cid, 6549) > 0 and getPlayerItemCount(cid, 6536) > 0 and getPlayerItemCount(cid, 7759) > 99 and getPlayerItemCount(cid, 5912) > 9 then
				        doPlayerRemoveItem(cid, 6546, 1)
				        doPlayerRemoveItem(cid, 6536, 1)
				        doPlayerRemoveItem(cid, 7759, 100)
				        doPlayerRemoveItem(cid, 5912, 10)
                                        doPlayerAddItem(cid, 2662, 1)
				        selfSay('Dzieki! Oto twoj magican hat!')
                                else
				        selfSay('Nie masz itemow!')
                                end
 			end
			talk_state = 0


  		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()
	doNpcSetCreatureFocus(focus)
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Nastepny noob...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Spadaj.')
 			focus = 0
 		end
 	end
end
Mam nadziej?, ?e si? przyda.
 
Ostatnio edytowane przez moderatora:
@up
Aby by?o dobrze trzeba zmieni?:
and getPlayerItemCount(cid, 5912) > 10 then
na:
and getPlayerItemCount(cid, 5912) > 9 then
lub:
and etPlayerItemCount(cid, 5912) >= 10 then
oraz pozmienia? troch? teksty :P wczoraj by?em zm?czony to nie umia?em zrobi?, a teraz zrobi?em tylko ty zamie?ci?e?, wi?c po co ja mia?bym te?. :)
 
Ostatnia edycja:
Racja, ale ty te? si? pomyli?e? Kelo:
Kod:
and getPlayerItemCount(cid, 5912) > 9 then
A nie:
Kod:
and etPlayerItemCount(cid, 5912) > 9 then
A to 2 up ju? jest ok.
 
Status
Zamknięty.
Do góry