Postado Junho 24, 2015 9 anos Primeiramente boa noite galera do tk, tudo bem? Vamos la. Pessoal eu queria um script para que os NPC em vez de cobra item pelo serviço cobra dias de Premium account. (não todos os npc so os que eu quiser pra ser mais especifico esse NPC a baixo) local item_id = {2160,1} -- edita aqui local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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) local msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "sex change") then if doPlayerRemoveItem(cid,item_id[1],item_id[2]) then doPlayerSetSex(cid,getPlayerSex(cid) == 1 and 0 or 1) doPlayerSendTextMessage(cid,22,"pronto troquei o seu sexo") doSendMagicEffect(getCreaturePosition(cid),28) else selfSay("você não tem dinheiro", cid) talkState[talkUser] = 0 end return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Deis de ja muito obrigado pela a atenção galera.
Postado Junho 24, 2015 9 anos local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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) local msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "sex change") then if(getPlayerPremiumDays(cid) > 2) then if(getPlayerPremiumDays(cid) < 65535) then doPlayerAddPremiumDays(cid, -3) end if(getPlayerSex(cid) == 0) then doPlayerSetSex(cid, 1) else doPlayerSetSex(cid, 0) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você mudou o seu sexo e perdeu três dias de premium account.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN) else selfSay("Desculpe, você não possui três dias de premium account para trocar seu sexo.", cid) talkState[talkUser] = 0 end return TRUE end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) The medieval RpG Server [RpG] OLDWORLD OPEN TIBIA
Postado Junho 24, 2015 9 anos Solução local p_days = 1 -- edita aqui local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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) local msg = msg:lower() local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, "sex change") then if getPlayerPremiumDays(cid) >= p_days then doPlayerSetSex(cid,getPlayerSex(cid) == 1 and 0 or 1) doPlayerSendTextMessage(cid,22,"pronto troquei o seu sexo") doSendMagicEffect(getCreaturePosition(cid),28) doPlayerAddPremiumDays(cid, -p_days) else selfSay("você precisa ter no minimo "..p_days.." dias de premium para trocar de sexo", cid) talkState[talkUser] = 0 end return true end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.