Postado Fevereiro 3, 2015 10 anos Bom seguinte, tenho um NPC que cobra 10kk + 500 white pearls e queria coloca-lo tbm para somente player nivel 2k+ posso utiliza-lõ para se teletransportado, Segue a baixo a script do NPC: local tab = { pos = {x = 275, y = 73, z = 7}, -- posição x, y, z do local a teleportar o player item = {2143, 500}, -- {itemID, count} price = 1000 -- quantidade em crystal coins } 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) if (not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if (msgcontains(msg, 'teleport')) then talkState[talkUser] = 1 selfSay('Are you sure?', cid) selfSay('Remember..you need '..tab.item[2]..' '..getItemNameById(tab.item[1])..' and '..tab.price..' crystal coins to be teleported.', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and doPlayerRemoveMoney(cid, tab.price * 10000)) then doTeleportThing(cid, tab.pos) doPlayerRemoveItem(cid, tab.item[1], tab.item[2]) doPlayerRemoveMoney(cid, tab.price * 10000) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) selfSay('Have a good trip.', cid) else talkState[talkUser] = 0 selfSay('I can not teleport you. You do not have the required items.', cid) end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Okay, maybe another time.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 3, 2015 10 anos Solução Boa noite. Teste assim. local tab = { pos = {x = 275, y = 73, z = 7}, -- posição x, y, z do local a teleportar o player item = {2143, 500}, -- {itemID, count} level = 2000, -- level mínimo price = 1000 -- quantidade em crystal coins } 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) if (not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if (msgcontains(msg, 'teleport')) then talkState[talkUser] = 1 selfSay('Are you sure?', cid) selfSay('Remember..you need '..tab.item[2]..' '..getItemNameById(tab.item[1])..' and '..tab.price..' crystal coins to be teleported.', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerLevel(cid) >= tab.level then if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and doPlayerRemoveMoney(cid, tab.price * 10000)) then doTeleportThing(cid, tab.pos) doPlayerRemoveItem(cid, tab.item[1], tab.item[2]) doPlayerRemoveMoney(cid, tab.price * 10000) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) selfSay('Have a good trip.', cid) else talkState[talkUser] = 0 selfSay('I can not teleport you. You do not have the required items.', cid) end else selfSay('You need level '..tab.level..' to be teleported.', cid) end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Okay, maybe another time.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Boa sorte. Editado Fevereiro 3, 2015 10 anos por Adriano SwaTT (veja o histórico de edições) Gosta do meu trabalho? Curta e siga a página do meu projeto de 2016 e 2017 (Lab Z Games) que trará vários servidores OTServs. Atenciosamente,Adriano Swatt' Para ver meus tutoriais acesse meu perfil.
Postado Fevereiro 3, 2015 10 anos local tab = { pos = {x = 275, y = 73, z = 7}, -- posição x, y, z do local a teleportar o player item = {2143, 500}, -- {itemID, count} price = 1000, -- quantidade em crystal coins level = 2000 -- level necessario } 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) if (not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if (msgcontains(msg, 'teleport')) then talkState[talkUser] = 1 selfSay('Are you sure?', cid) selfSay('Remember..you need '..tab.item[2]..' '..getItemNameById(tab.item[1])..' and '..tab.price..' crystal coins to be teleported.', cid) elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerLevel(cid) >= tab.level then if (getPlayerItemCount(cid, tab.item[1]) >= tab.item[2] and doPlayerRemoveMoney(cid, tab.price * 10000)) then doTeleportThing(cid, tab.pos) doPlayerRemoveItem(cid, tab.item[1], tab.item[2]) doPlayerRemoveMoney(cid, tab.price * 10000) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) selfSay('Have a good trip.', cid) else talkState[talkUser] = 0 selfSay('I can not teleport you. You do not have the required items.', cid) end else selfSay('Sorry you dont has level necessary.', cid) talkState[talkUser] = 0 end elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then talkState[talkUser] = 0 selfSay('Okay, maybe another time.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Fevereiro 3, 2015 10 anos por fywell (veja o histórico de edições)
Postado Fevereiro 3, 2015 10 anos Por nada. Faça bom aproveito do script. Abraços. Gosta do meu trabalho? Curta e siga a página do meu projeto de 2016 e 2017 (Lab Z Games) que trará vários servidores OTServs. Atenciosamente,Adriano Swatt' Para ver meus tutoriais acesse meu perfil.
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.