Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Ola galera, bom dia.

 

Estou com um erro aqui no item para adicionar 30 dias vips ao player.

Ele diz que adicionou os 30 dias, o item é usado mas não adiciona os 30 dias de vip a conta.

Creio que seja o número da storage, porém não consegui achar qual seria o número da storage de vip do pda. Em qual script posso acha-lo?

 

E também estou querendo um Saffari card, com ele o player terá acesso ao Saffari zone por 30 dias (Npc e item já criados) porém me falta o script para que esse item dure 30 dias na bag, e depois suma. E se possível, ao player dar lock neste item ele verá quantos dias ainda lhe restam para usa-lo.

 

A quem puder me ajudar estarei grato. Rep+

 

Sistema do item vip.

function onUse(cid, item, fromPosition, itemEx, toPosition)



local days,removeOnUse = 30,true

local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13540)
local timenow = os.time()
local time = getPlayerStorageValue(cid, 13540) - os.time() <= 0 and timenow + daysvalue or storageplayer + daysvalue

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP na sua conta.")
setPlayerStorageValue(cid, 13540, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(13,14))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
if removeOnUse == true then doRemoveItem(item.uid, 1) end
return true
end

Editado por eliaspalermo (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Tente usar esse :

local days = 30 * 24 * 60 * 60 -- 30 Dias
local storage = 12301

function onUse(player, item)

	local daysRest = math.floor((getPlayerStorageValue(player, storage) - os.time())/(24 * 60 * 60))

	if daysRest == 0 then
		doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados 30 dias de VIP na sua conta.")
		setPlayerStorageValue(player, storage, os.time() + days)
		doSendMagicEffect(getThingPos(player), math.random(13,14))
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você tem ".. daysRest .." dias de VIP restantes.")
	end

	return true
end

I must not fear. Fear is the mind killer.

Link para o post
Compartilhar em outros sites

Erro meu tente agora :


local days = 30 * 24 * 60 * 60 -- 30 Dias
local storage = 44641

function onUse(player, item)

	local daysRest = os.date("%d", getPlayerStorageValue(player, storage) - os.time())

	if daysRest == 0 or daysRest == nil then
		doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados 30 dias de VIP na sua conta.")
		setPlayerStorageValue(player, storage, os.time() + days)
		doSendMagicEffect(getThingPos(player), math.random(13,14))
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você tem ".. daysRest .." dias de VIP restantes.")
	end

	return true
end

I must not fear. Fear is the mind killer.

Link para o post
Compartilhar em outros sites

Por acaso, o PDA que você baixou tem mesmo sistema de VIP? Geralmente, há apenas o sistema de premium account.
Sobre o segundo pedido, desta maneira que você quer seriam necessárias as sources do servidor. Se preferir, o código pode ser feito da seguinte forma: o cartão não sumiria da bag, mas sim teria um prazo de validade. Assim, o sistema seria viável em PDA.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Nossa então VIP não é a mesma coisa que P.Account? 

Caraca, dessa eu fui saber agora, me desculpem hahahaha

 

Então mano se tu souber fazer dessa maneira da validade também me serve, eu só preciso mesmo que sejam ulteis por 30 dias. 

E muito obrigado por me informar essa diferença que eu realmente não sabia.

 

Então sim, meu servidor contém apenas P.Account.

Link para o post
Compartilhar em outros sites

Primeiro pedido:

local days = 30            --Dias premium que serão adicionados.
function onUse(cid, item)
    doPlayerSendTextMessage(cid, 27, days.." premium days added to your account.")
    doPlayerAddPremiumDays(cid, days)
    doRemoveItem(item.uid, 1)
    return true
end

O segundo, caso eu tenha acesso a meu notebook, faço amanhã.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Poderia dar mais detalhes sobre o segundo pedido? Por exemplo, como o jogador irá obter o cartão e o código do NPC que garante acesso a Saffari Zone.

E, se possível, seu código de look também (data/creaturescripts/scripts, look.lua).

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Certo.

 

O Saffari card poderá ser obtido em um npc que vende itens em troca de moedas (As moedas que os players ganharão caso doarem)

 

Script do look

 

function onLook(cid, thing, position, lookDistance)


local str = ""

if not isCreature(thing.uid) then
local iname = getItemInfo(thing.itemid)
if isPokeball(thing.itemid) then
local lock = getItemAttribute(thing.uid, "lock") --alterado v2.8
local pokename = getItemAttribute(thing.uid, "poke")
local item = getItemInfo(thing.itemid)
str = "You see "..item.article.." "..item.name.."." --alterado v2.6
if getItemAttribute(thing.uid, "unique") then --alterado v2.8
str = str.." It's an unique item." --alterado v2.6
end
str = str.."\nIt contains "..getArticle(pokename).." "..pokename.." [level "..getItemAttribute(thing.uid, "level").."].\n" --alterado v2.6
if lock and lock > 0 then
str = str.."It will unlock in ".. os.date("%d/%m/%y %X", lock)..".\n" --alterado v2.8
end
local boost = getItemAttribute(thing.uid, "boost") or 0
local boostshow = ""
if boost > 0 then
str = str.."Boost level: +"..boost..".\n"
end
if getItemAttribute(thing.uid, "nick") then
str = str.."It's nickname is: "..getItemAttribute(thing.uid, "nick")..".\n"
end
if getItemAttribute(thing.uid, "gender") == SEX_MALE then
str = str.."It is male."
elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then
str = str.."It is female."
else
str = str.."It is genderless."
end
str = str.."\n--- Status ---"
str = str.."\nOffense: "..math.floor(getItemAttribute(thing.uid, "offense")).." Defense: "..math.floor(getItemAttribute(thing.uid, "defense")).."\n"
str = str.."Agility: "..math.floor(getItemAttribute(thing.uid, "speed")).." Sp. Attack: "..math.floor(getItemAttribute(thing.uid, "specialattack")).."\n"
str = str.."Vitality: "..math.floor(getItemAttribute(thing.uid, "vitality"))..""
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif string.find(iname.name, "fainted") or string.find(iname.name, "defeated") then

str = "You see a "..string.lower(iname.name).." ["..getItemAttribute(thing.uid, "level").."]. " --alterado v2.8 \/
if isContainer(thing.uid) then
str = str.."(Vol: "..getContainerCap(thing.uid)..")"
end
str = str.."\n"

if getItemAttribute(thing.uid, "gender") == SEX_MALE then
str = str.."It is male."
elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then
str = str.."It is female."
else
str = str.."It is genderless."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif isContainer(thing.uid) then --containers

local info = getItemInfo(thing.itemid) --alterado v2.7
if info.name == "dead human" and getItemAttribute(thing.uid, "pName") then
str = "You see a dead human (Vol:"..getContainerCap(thing.uid).."). "
str = str.."You recognize ".. getItemAttribute(thing.uid, "pName")..". ".. getItemAttribute(thing.uid, "article").." was killed by a "
str = str.."".. getItemAttribute(thing.uid, "attacker").."."
else
str = "You see "..info.article.." "..info.name..". (Vol:"..getContainerCap(thing.uid)..")."
end
if getPlayerGroupId(cid) >= 4 and getPlayerGroupId(cid) <= 6 then
str = str.."\nItemID: ["..thing.itemid.."]" --alterado v2.8
local pos = getThingPos(thing.uid)
str = str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]" --alterado v2.8
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif getItemAttribute(thing.uid, "unique") then --alterado v2.8 \/
local info = getItemInfo(thing.itemid)
local p = getThingPos(thing.uid)

local str = "You see "
if thing.type > 0 then
str = str..thing.type.." "..info.plural.."."
else
str = str..info.article.." "..info.name.."."
end
str = str.." It's an unique item.\n"

str = str..info.description.."\nItemID: ["..thing.itemid.."]"
str = str.."\nPosition: ["..p.x.."]["..p.y.."]["..p.z.."]"

sendMsgToPlayer(cid, MESSAGE_INFO_DESCR, str)
return false
else
return true
end
end

local NPCBattle = {
["Brock"] = {artig = "He is", cidbat = "Pewter"},
["Misty"] = {artig = "She is", cidbat = "Cerulean"},
["Blaine"] = {artig = "He is", cidbat = "Cinnabar"},
["Sabrina"] = {artig = "She is", cidbat = "Saffron"}, --alterado v2.7
["Kira"] = {artig = "She is", cidbat = "Viridian"},
["Koga"] = {artig = "He is", cidbat = "Fushcia"},
["Erika"] = {artig = "She is", cidbat = "Celadon"},
["Surge"] = {artig = "He is", cidbat = "Vermilion"},
}

local npcname = getCreatureName(thing.uid)
if ehNPC(thing.uid) and NPCBattle[npcname] then --npcs duel
str = "You see "..npcname..". "..NPCBattle[npcname].artig.." leader of the gym from "..NPCBattle[npcname].cidbat.."." --alterado v2.7
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif ehNPC(thing.uid) and getPlayerStorageValue(thing.uid, 697548) ~= -1 then --npcs de TV
local str = getPlayerStorageValue(thing.uid, 697548) --alterado v2.7
local pos = getThingPos(thing.uid)
str = youAre[getPlayerGroupId(cid)] and str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]." or str
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
end

if not isPlayer(thing.uid) and not isMonster(thing.uid) then
str = "You see "..getCreatureName(thing.uid).."."
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
end

if isPlayer(thing.uid) then --player
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getPlayerDesc(cid, thing.uid, false)) --alterado v2.7
return false
end

if getCreatureName(thing.uid) == "Evolution" then return false end

if not isSummon(thing.uid) then
local str = "You see a wild "..string.lower(getCreatureName(thing.uid)).." [level "..getPokemonLevel(thing.uid).."].\n"
if getPokemonGender(thing.uid) == SEX_MALE then
str = str.."It is male."
elseif getPokemonGender(thing.uid) == SEX_FEMALE then
str = str.."It is female."
else
str = str.."It is genderless."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif isSummon(thing.uid) and not isPlayer(thing.uid) then
local boostlevel = getItemAttribute(getPlayerSlotItem(getCreatureMaster(thing.uid), 8).uid, "boost") or 0
local boostshow = " + "..boostlevel.."]"
if showBoostSeparated then
boostshow = "] [+"..boostlevel.."]"
end
local levelinfo = "["..getPokemonLevel(thing.uid)..""..boostshow..""
if getCreatureMaster(thing.uid) == cid then
local myball = getPlayerSlotItem(cid, 8).uid
local nexp = getItemAttribute(myball, "nextlevelexp")
local string = "You see your "..string.lower(getCreatureName(thing.uid)).." "..levelinfo.."."
string = string.."\nHit points: "..getCreatureHealth(thing.uid).."/"..getCreatureMaxHealth(thing.uid).."."
string = string.."\n"..getPokemonHappinessDescription(thing.uid)
if getItemAttribute(myball, "level") <= 99 then
string = string.."\nExperience needed to level up: "..nexp.."."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You see a "..string.lower(getCreatureName(thing.uid)).." "..levelinfo..".\nIt belongs to "..getCreatureName(getCreatureMaster(thing.uid))..".")
end
return false
end
return true
end

 

 

Script do npc que da acesso a saffari caso o player tenha o card.

 

local tab = {


pos = {x = 768, y = 1007, z = 8}, -- posição x, y, z do local a teleportar o player
item = {26771, 1}, -- {itemID, count}
price = 0 -- 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('Voce esta certo disso?', cid)
selfSay('Lembre-se..voce precisa de '..tab.item[2]..' '..getItemNameById(tab.item[1])..' para prosseguir.', 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)
doPlayerRemoveMoney(cid, tab.price * 10000)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
selfSay('Boa sorte no Saffari Zone.', cid)
else
talkState[talkUser] = 0
selfSay('Voce nao tem o Saffari Card, entao nao poderei move-lo para la.', cid)
end
elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then
talkState[talkUser] = 0
selfSay('Okay, Talvez em outra hora.', cid)
end

return true
end

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

Link para o post
Compartilhar em outros sites

Desculpe a demora. Como lhe disse por PM, estava em semana de provas e não tive como scriptear.

Look:

local cardId = xxx       --ID do cartão.
function onLook(cid, thing, position, lookDistance)
    local str = ""
    if not isCreature(thing.uid) then
        if thing.itemid == cardId then
            str = "You see "..getItemInfo(thing.itemid).article.." "..getItemInfo(thing.itemid).name.."."
            if getItemInfo(thing.itemid).description then
                str = str.."\n"..getItemInfo(thing.itemid).description
            end
            local vality = getItemAttribute(thing.uid, "vality")
            if vality then
                if vality < os.time() then
                    str = str.."\nThis card isn't valid anymore."
                else
                    str = str.."\nValid until "..os.date("%d/%m/%y %X", vality)
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
            return false
        end
        local iname = getItemInfo(thing.itemid)
        if isPokeball(thing.itemid) then
            local lock = getItemAttribute(thing.uid, "lock") --alterado v2.8
            local pokename = getItemAttribute(thing.uid, "poke")
            local item = getItemInfo(thing.itemid)
            str = "You see "..item.article.." "..item.name.."." --alterado v2.6
            if getItemAttribute(thing.uid, "unique") then --alterado v2.8
                str = str.." It's an unique item." --alterado v2.6
            end
            str = str.."\nIt contains "..getArticle(pokename).." "..pokename.." [level "..getItemAttribute(thing.uid, "level").."].\n" --alterado v2.6
            if lock and lock > 0 then
                str = str.."It will unlock in ".. os.date("%d/%m/%y %X", lock)..".\n" --alterado v2.8
            end
            local boost = getItemAttribute(thing.uid, "boost") or 0
            local boostshow = ""
            if boost > 0 then
                str = str.."Boost level: +"..boost..".\n"
            end
            if getItemAttribute(thing.uid, "nick") then
                str = str.."It's nickname is: "..getItemAttribute(thing.uid, "nick")..".\n"
            end
            if getItemAttribute(thing.uid, "gender") == SEX_MALE then
                str = str.."It is male."
            elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then
                str = str.."It is female."
            else
                str = str.."It is genderless."
            end
            str = str.."\n--- Status ---"
            str = str.."\nOffense: "..math.floor(getItemAttribute(thing.uid, "offense")).." Defense: "..math.floor(getItemAttribute(thing.uid, "defense")).."\n"
            str = str.."Agility: "..math.floor(getItemAttribute(thing.uid, "speed")).." Sp. Attack: "..math.floor(getItemAttribute(thing.uid, "specialattack")).."\n"
            str = str.."Vitality: "..math.floor(getItemAttribute(thing.uid, "vitality"))..""
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
            return false
        elseif string.find(iname.name, "fainted") or string.find(iname.name, "defeated") then
            str = "You see a "..string.lower(iname.name).." ["..getItemAttribute(thing.uid, "level").."]. " --alterado v2.8 \/
            if isContainer(thing.uid) then
                str = str.."(Vol: "..getContainerCap(thing.uid)..")"
            end
            str = str.."\n"
 
            if getItemAttribute(thing.uid, "gender") == SEX_MALE then
                str = str.."It is male."
            elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then
                str = str.."It is female."
            else
                str = str.."It is genderless."
            end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
            return false
        elseif isContainer(thing.uid) then --containers
            local info = getItemInfo(thing.itemid) --alterado v2.7
            if info.name == "dead human" and getItemAttribute(thing.uid, "pName") then
                str = "You see a dead human (Vol:"..getContainerCap(thing.uid).."). "
                str = str.."You recognize ".. getItemAttribute(thing.uid, "pName")..". ".. getItemAttribute(thing.uid, "article").." was killed by a "
                str = str.."".. getItemAttribute(thing.uid, "attacker").."."
            else
                str = "You see "..info.article.." "..info.name..". (Vol:"..getContainerCap(thing.uid)..")."
            end
            if getPlayerGroupId(cid) >= 4 and getPlayerGroupId(cid) <= 6 then
                str = str.."\nItemID: ["..thing.itemid.."]" --alterado v2.8
                local pos = getThingPos(thing.uid)
                str = str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]" --alterado v2.8
            end
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
            return false
        elseif getItemAttribute(thing.uid, "unique") then --alterado v2.8 \/
            local info = getItemInfo(thing.itemid)
            local p = getThingPos(thing.uid)
            local str = "You see "
            if thing.type > 0 then
                str = str..thing.type.." "..info.plural.."."
            else
                str = str..info.article.." "..info.name.."."
            end
            str = str.." It's an unique item.\n"
 
            str = str..info.description.."\nItemID: ["..thing.itemid.."]"
            str = str.."\nPosition: ["..p.x.."]["..p.y.."]["..p.z.."]"
 
            sendMsgToPlayer(cid, MESSAGE_INFO_DESCR, str)
            return false
        else
            return true
        end
    end
 
local NPCBattle = {
["Brock"] = {artig = "He is", cidbat = "Pewter"},
["Misty"] = {artig = "She is", cidbat = "Cerulean"},
["Blaine"] = {artig = "He is", cidbat = "Cinnabar"},
["Sabrina"] = {artig = "She is", cidbat = "Saffron"}, --alterado v2.7
["Kira"] = {artig = "She is", cidbat = "Viridian"},
["Koga"] = {artig = "He is", cidbat = "Fushcia"},
["Erika"] = {artig = "She is", cidbat = "Celadon"},
["Surge"] = {artig = "He is", cidbat = "Vermilion"},
}
 
local npcname = getCreatureName(thing.uid)
if ehNPC(thing.uid) and NPCBattle[npcname] then --npcs duel
str = "You see "..npcname..". "..NPCBattle[npcname].artig.." leader of the gym from "..NPCBattle[npcname].cidbat.."." --alterado v2.7
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif ehNPC(thing.uid) and getPlayerStorageValue(thing.uid, 697548) ~= -1 then --npcs de TV
local str = getPlayerStorageValue(thing.uid, 697548) --alterado v2.7
local pos = getThingPos(thing.uid)
str = youAre[getPlayerGroupId(cid)] and str.."\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]." or str
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
end
 
if not isPlayer(thing.uid) and not isMonster(thing.uid) then
str = "You see "..getCreatureName(thing.uid).."."
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
end
 
if isPlayer(thing.uid) then --player
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getPlayerDesc(cid, thing.uid, false)) --alterado v2.7
return false
end
 
if getCreatureName(thing.uid) == "Evolution" then return false end
 
if not isSummon(thing.uid) then
local str = "You see a wild "..string.lower(getCreatureName(thing.uid)).." [level "..getPokemonLevel(thing.uid).."].\n"
if getPokemonGender(thing.uid) == SEX_MALE then
str = str.."It is male."
elseif getPokemonGender(thing.uid) == SEX_FEMALE then
str = str.."It is female."
else
str = str.."It is genderless."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str)
return false
elseif isSummon(thing.uid) and not isPlayer(thing.uid) then
local boostlevel = getItemAttribute(getPlayerSlotItem(getCreatureMaster(thing.uid), 8).uid, "boost") or 0
local boostshow = " + "..boostlevel.."]"
if showBoostSeparated then
boostshow = "] [+"..boostlevel.."]"
end
local levelinfo = "["..getPokemonLevel(thing.uid)..""..boostshow..""
if getCreatureMaster(thing.uid) == cid then
local myball = getPlayerSlotItem(cid, 8).uid
local nexp = getItemAttribute(myball, "nextlevelexp")
local string = "You see your "..string.lower(getCreatureName(thing.uid)).." "..levelinfo.."."
string = string.."\nHit points: "..getCreatureHealth(thing.uid).."/"..getCreatureMaxHealth(thing.uid).."."
string = string.."\n"..getPokemonHappinessDescription(thing.uid)
if getItemAttribute(myball, "level") <= 99 then
string = string.."\nExperience needed to level up: "..nexp.."."
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You see a "..string.lower(getCreatureName(thing.uid)).." "..levelinfo..".\nIt belongs to "..getCreatureName(getCreatureMaster(thing.uid))..".")
end
return false
end
return true
end

NPC que garante entrada a Saffari Zone:

local tab = {
    pos = {x = 768, y = 1007, z = 8}, -- posição x, y, z do local a teleportar o player
    cardId = xxx,        --ID do Saffari Card.
}
 
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? To enter in the Saffari Zone, you need a valid Saffari Card.", cid)
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        local items = getItemsInContainerById(getPlayerSlotItem(cid, 3).uid, tab.cardId)
        if #items == 0 then
            selfSay("You do not have any Saffari Card in your bag.", cid)
            talkState[talkUser] = 0
        else
            local checkPlayer = false
            for i = 1, #items do
                if getItemAttribute(items[i], "vality") and getItemAttribute(items[i], "vality") > os.time() then
                    checkPlayer = true
                    break
                end
            end
            if checkPlayer then
                doTeleportThing(cid, tab.pos)
                doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
                selfSay('Boa sorte no Saffari Zone.', cid)
            else
                selfSay("You do not have any valid Saffari Card in your bag.", cid)
            end
        end
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        talkState[talkUser] = 0
        selfSay('Okay, Talvez em outra hora.', cid)
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
NPC que vende o Saffari Card:
local config = {
    cardId = xxx,                --ID do Saffari Card.
    price = {itemid, count},     --Preço do Saffari Card. {ID_do_item, quantidade}
    days = 30,                   --Validade, em dias, do Saffari Card.
}
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:lower(), "buy") or msgcontains(msg:lower(), "trade") then
        selfSay("You wanna buy a Saffari Card for "..config.price[2].."x "..getItemNameById(config.price[1]).."? Vality: "..config.days.." days.", cid)
        talkState[talkUser] = 1
        return true
    elseif msgcontains(msg:lower(), "yes") and talkState[talkUser] == 1 then
        if doPlayerRemoveItem(cid, config.price[1], config.price[2]) then
            selfSay("Here's your Saffari Card!", cid)
            local item = doPlayerAddItem(cid, config.cardId, 1)
            doItemSetAttribute(item, "vality", os.time() + (config.days * 24 * 60 * 60))
            talkState[talkUser] = 0
            return true
        else
            selfSay("You do not have the items.", cid)
            talkState[talkUser] = 0
            return true
        end
    elseif msgcontains(msg:lower(), "no") and talkState[talkUser] == 1 then
        selfSay("OK, bye!", cid)
        talkState[talkUser] = 0
        return true
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Ops, escrevi o código correndo e nem reparei neste erro. Script corrigido (NPC que vende o Saffari Card).

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Mano não esta funcionando.

 

Ao comprar o card do Zelador(O npc que vende o card) da um erro no console.

 

Ao tentar entrar no Saffari, a npc diz que o card não é valido, e quando dou look no card não mostra a validade.

 

Segue as imagens:

post-74390-0-26549300-1430570008_thumb.p

post-74390-0-91550500-1430570011_thumb.p

Link para o post
Compartilhar em outros sites

Funcionou, agora o npc aceita o saffari, e ao dar look nele aparece a data que o player comprou, Muito obrigado mano !!!! Estou adorando seu trabalho, parabéns Rep+

 

Uma pergunta, caso eu queira usar esse sistema para outro item, eu devo apenas copiar os scripts e trocar o id do item?

Link para o post
Compartilhar em outros sites

Depende. Seriam items diferentes para o mesmo propósito? Digo, os items teriam a mesma função de garantir acesso a Saffari Zone?

não respondo pms solicitando suporte em programação/scripting

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.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo