• 01-04.05.2026 - DOUBLE EXP / SKILL EVENT!

Promocja za item u NPC

Batonek

Senior User
Zarejestrowany
Dołączył
Kwiecień 26, 2008
Posty
605
Liczba reakcji
25
Witam. Ot?? pr?buje przerobi? m?j skrypt ?eby NPC zamiast kasy zabiera? item o id xxxx zamiast kasy.
Kod:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
Ew. Mo?e by? item o id xxxx, po klikni?ciu na niego dostajemy promocje (wszystkie skrypty kt?re tu znalaz?em nie zapisuj? promocji bo relogu.)
Z g?ry :thx:
Pozdro.
 
Odp: Promocja za item u NPC

Prosz? powinno zadzia?a?:

King.lua
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)
local player_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_money = player_gold + player_plat + player_crys
local playerCap = getPlayerFreeCap(cid)
local itemweight = getItemWeight(item, 1)
local lvl = getPlayerLevel(cid)
msg = string.lower(msg)

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hi. I sell Promotion.')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('You will have to wait, I have other client.')

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

if msgcontains(msg, 'promotion') then
if getPlayerVocation(cid) <=4 then
if lvl >= Jaki ma mie? lvl then
if getPlayerItemCount(cid,5878) >= Ile ma mie? przynajmiej item?w np: 1 then
selfSay('Well okey. Now you are promoted')
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MORTAREA)
doPlayerRemoveItem(cid,Id Itemu jaki ma wzi???,Ilo?? Item?w jakie ma wzi???)
else
selfSay('Sorry, but you havent got item.')
end
else
selfSay('Sorry, but you are havent 20 lvl.')
end
else
selfSay('Sorry, but you are promoted.')
end

end

if msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getPlayerName(cid) .. '!')
focus = 0
end
end
end


function onThink()

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) > 2 then
selfSay('Good bye then.')
focus = 0
end
end
end


King.xml
<?xml version="1.0"?>
<npc name="King" script="data/npc/scripts/King_Shop.lua" speed="40" access="3" floorchange="0" walkinterval="2000">
<health now="100" max="100"/>
<look type="133" head="114" body="114" legs="114" feet="114" addons="1"/>
</npc>
 
Ostatnia edycja:
Odp: Promocja za item u NPC

Co? mi ten NPC nie dzia?a ;/ Sporo b??d?w w konsoli - 34 i 57 linijka...
 
Odp: Promocja za item u NPC

Upewnij si? czy na pewno zmieni?e? wszystko co jest na czerwono... I napisz jakie ci b??dy wyskakuj?...

I spr?buj tera bo zauwa?y?em kilka b??d?w wi?c mo?e przez to...
 
Ostatnia edycja:
Odp: Promocja za item u NPC

Nie dzia?a:
Musia?em zmini? if getPlayerItemCount(cid,2366) >= 1 then - tu by? inny id. (zmieni?em na m?j)
1: Masa b??d?w w konsoli co? o onCreatuereSay i nie wiem czemu nie m?wi? w chanel npc tylko na ???to i jeszcze 1 b??d luaGetItemWeight item not found.
2: zabiera itema a promo w og?le nie daje.
 
Back
Do góry