Ir para conteúdo
  • Cadastre-se

(Resolvido)Por maximo level nesse script


Ir para solução Resolvido por Yan Liima,

Posts Recomendados

Galera tenho esse script de vocation vip, preciso que ele tenha um limite de lvl que seria 20 pro item poder ser usado...

Spoiler

function onThink(cid, interval)
local itemid = 13489
local outfit = {lookType = 353}

if isPlayer(cid) then
if getPlayerItemCount(cid, itemid) >= 1 then
if getPlayerStorageValue(cid,30023) == 4 then
doPlayerSetVocation(cid, 442)
else
doPlayerSetVocation(cid, 437)
end
doPlayerRemoveItem(cid, itemid, 1)
doCreatureChangeOutfit(cid, outfit)
addEvent(doRemoveCreature, 1, cid)
end
end
return true
end

 

Link para o post
Compartilhar em outros sites
  • Moderador

Tenta assim:

function onThink(cid, interval)
local itemid = 13489
local outfit = {lookType = 353}

if isPlayer(cid) then
if getPlayerLevel(cid) <= 20 then
if getPlayerItemCount(cid, itemid) >= 1 then
if getPlayerStorageValue(cid,30023) == 4 then
doPlayerSetVocation(cid, 442)
else
doPlayerSetVocation(cid, 437)
end
doPlayerRemoveItem(cid, itemid, 1)
doCreatureChangeOutfit(cid, outfit)
addEvent(doRemoveCreature, 1, cid)
end
end
end
return true
end

 

Link para o post
Compartilhar em outros sites
14 minutos atrás, movie disse:

Tenta assim:


function onThink(cid, interval)
local itemid = 13489
local outfit = {lookType = 353}

if isPlayer(cid) then
if getPlayerLevel(cid) <= 20 then
if getPlayerItemCount(cid, itemid) >= 1 then
if getPlayerStorageValue(cid,30023) == 4 then
doPlayerSetVocation(cid, 442)
else
doPlayerSetVocation(cid, 437)
end
doPlayerRemoveItem(cid, itemid, 1)
doCreatureChangeOutfit(cid, outfit)
addEvent(doRemoveCreature, 1, cid)
end
end
end
return true
end

 

 

amigo funcionou sim, porem errei em uma coisa, preciso q o npc nao venda se o player for level maior que 20, aqui esta o script do npc

Spoiler

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

local items = {
          item1 = {6544, 13489}, -- item1 item que será pedido e que será dado na primeira troca
}
local counts = {
          count1 = {25, 1}, -- count1 quantidade que será pedido e que será dado na primeira troca
}

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        if msgcontains(msg, 'kagome') then
            selfSay('Voce deseja paga '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' por'.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'?',cid)
            talkState[talkUser] = 1
        elseif talkState[talkUser] == 1 then
            if msgcontains(msg, 'yes') then
                if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                    doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                    doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                    selfSay('Obrigado! Voce acaba de paga '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' por '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
                    talkState[talkUser] = 0
                else
                    selfSay('Voce precisa de '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
                end
            end
        end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Link para o post
Compartilhar em outros sites
  • Solução
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

local items = {
          item1 = {6544, 13489}, -- item1 item que será pedido e que será dado na primeira troca
}
local counts = {
          count1 = {25, 1}, -- count1 quantidade que será pedido e que será dado na primeira troca
}

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        if msgcontains(msg, 'kagome') then
            selfSay('Voce deseja paga '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' por'.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'?',cid)
            talkState[talkUser] = 1
        elseif talkState[talkUser] == 1 then
            if msgcontains(msg, 'yes') then
			 if getPlayerLevel(cid) <= 20 then
                if getPlayerItemCount(cid, items.item1[1]) >= counts.count1[1] then
                    doPlayerRemoveItem(cid, items.item1[1], counts.count1[1])
                    doPlayerAddItem(cid, items.item1[2], counts.count1[2])
                    selfSay('Obrigado! Voce acaba de paga '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..' por '.. counts.count1[2] ..' '.. getItemNameById(items.item1[2]) ..'.', cid)
                    talkState[talkUser] = 0
                else
                    selfSay('Voce precisa de '.. counts.count1[1] ..' '.. getItemNameById(items.item1[1]) ..'.', cid)
                end
				else
				selfSay('Voce precisa ter no maximo level 20.', cid)
            end
        end
	end	
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═══╗

Te Ajudei? Rep + e ficamos Quits

166420979_logoyanliimaornight.png.33f822b8970081a5b3646e85dbfd5934.png

Precisando de ajuda?

discord.png.1ecd188791d0141f74d99db371a2e0a4.png.890d5a38d7bcde75543c72b624a65de1.pngDiscord: Yan Liima #3702

Programador Júnior de LUA, PHP e JavaScript

Juntos somos lendas, separados somos Mitos!

╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo