DR

Dúvida Script Npc

Por dragonfight, 01 de mar. de 2012 em Scripts

script
6
1.1k
dragonfightD
01 de março de 2012 às 22:00

Segue script:

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=577,y=192,z=7} -------------- Pos para onde o player sera levado

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
function creatureSayCallback(cid, type, msg)
   if(not npcHandler:isFocused(cid)) then
    return false
   end
   if msgcontains(msg, "hi") or msgcontains(msg, "help") then
    selfSay("Finish?", cid)
    talkState[cid] = 0
 elseif msgcontains(msg, 'yes') then
 if doPlayerAddItem(cid,2673,1) then
 selfSay("Ok!", cid)
 doTeleportThing(cid, pos)
 else
 selfSay("?????.", cid)
 end
 end
 return TRUE  
 end

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

 

Este script está bugado, caso o player esteja com bag cheia e não tenha lugar pro item, ele teleporta e o item cai no chão.

 

Como posso fazer para teleportar apenas se ele ganhar o item?(na bag ou na mão)

VodkartV
01 de março de 2012 às 22:06

põe para checar a cap do player...

e acho que da para mandar pro depot do player '-'

Editado Março 1 por Vodkart

dragonfightD
01 de março de 2012 às 22:08

Ah, não sabia que comando usar, vou editar o script e posto aki

VodkartV
01 de março de 2012 às 22:14
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=577,y=192,z=7} -------------- Pos para onde o player sera levado
local item = 2673

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
function creatureSayCallback(cid, type, msg)
   if(not npcHandler:isFocused(cid)) then
           return false
   end
   if msgcontains(msg, "hi") or msgcontains(msg, "help") then
           selfSay("Finish?", cid)
           talkState[cid] = 0
        elseif msgcontains(msg, 'yes') then
        if getPlayerFreeCap(cid) >= getItemWeightById(item) then  
        doPlayerAddItem(cid,item,1) 
        selfSay("Ok!", cid)
        doTeleportThing(cid, pos)
        else
        selfSay("You need " .. getItemWeightById(item) .. " capacity in order to get the item", cid)
        end
        end
        return TRUE  
        end

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

dragonfightD
01 de março de 2012 às 22:33

kkk, tava quebrando a cabeça aki, vlw.

 

obs: deu um errinho aki na distro mais já arrumei

Editado Março 1 por dragonfight

VodkartV
01 de março de 2012 às 22:35

de nada kk