Postado Janeiro 6, 2018 7 anos @luanluciano93 poderia me ajuda estou tentando fazer ele informa o jogando no momento que ele loga o tempo que ele possui de vip e tbm um npc que só vende itens para jogadorers vip
Postado Janeiro 6, 2018 7 anos Autor 2 hours ago, leandrocore said: @luanluciano93 poderia me ajuda estou tentando fazer ele informa o jogando no momento que ele loga o tempo que ele possui de vip e tbm um npc que só vende itens para jogadorers vip Essa função retorna os dias de vip que ainda restam ... player:sendVipDaysMessage() Para o NPC tente esse código: Spoiler local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 tradeOffers = { -- SELL OFFERS {id=7396, buy=0, sell=20000, name='behemoth trophy'}, {id=7393, buy=0, sell=40000, name='demon trophy'}, {id=7399, buy=0, sell=10000, name='dragon lord trophy'}, -- BUY OFFERS {id=10518, buy=1000, sell=0, name='demon backpack'}, } local items, data = {} for i = 1, #tradeOffers do data = tradeOffers[i] items[data.id] = {id = data.id, buy = data.buy, sell = data.sell, name = ItemType(data.id):getName():lower()} end local function greetCallback(cid) npcHandler:setMessage(MESSAGE_GREET, 'Welcome |PLAYERNAME| ... !') return true end local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks) local player = Player(cid) if not ignoreCap and player:getFreeCapacity() < ItemType(items[item].id):getWeight(amount) then return player:sendTextMessage(MESSAGE_INFO_DESCR, 'You don\'t have enough cap.') end if items[item].buy then if player:removeMoney(amount * items[item].buy) then if player:addItem(items[item].id, amount) then return player:sendTextMessage(MESSAGE_INFO_DESCR, 'Bought '..amount..'x '..items[item].name..' for '..items[item].buy * amount..' gold coins.') end end end return true end local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks) local player = Player(cid) if items[item].sell then if player:addMoney(items[item].sell * amount) then if player:removeItem(items[item].id, amount) then return player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sold '..amount..'x '..items[item].name..' for '..items[item].sell * amount..' gold coins.') end end end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) msg = msg:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end) if msgcontains('trade', msg) then local tradeItems = {} if player:isVip() then tradeItems = tradeOffers openShopWindow(cid, tradeItems, onBuy, onSell) return npcHandler:say('It\'s my offer.', cid) else return npcHandler:say('You don\'t have vip account.', cid) end end end npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old chap!') npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Janeiro 6, 2018 7 anos 28 minutos atrás, luanluciano93 disse: Essa função retorna os dias de vip que ainda restam ... player:sendVipDaysMessage() Para o NPC tente esse código: Ocultar conteúdo local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 tradeOffers = { -- SELL OFFERS {id=7396, buy=0, sell=20000, name='behemoth trophy'}, {id=7393, buy=0, sell=40000, name='demon trophy'}, {id=7399, buy=0, sell=10000, name='dragon lord trophy'}, -- BUY OFFERS {id=10518, buy=1000, sell=0, name='demon backpack'}, } local items, data = {} for i = 1, #tradeOffers do data = tradeOffers[i] items[data.id] = {id = data.id, buy = data.buy, sell = data.sell, name = ItemType(data.id):getName():lower()} end local function greetCallback(cid) npcHandler:setMessage(MESSAGE_GREET, 'Welcome |PLAYERNAME| ... !') return true end local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks) local player = Player(cid) if not ignoreCap and player:getFreeCapacity() < ItemType(items[item].id):getWeight(amount) then return player:sendTextMessage(MESSAGE_INFO_DESCR, 'You don\'t have enough cap.') end if items[item].buy then if player:removeMoney(amount * items[item].buy) then if player:addItem(items[item].id, amount) then return player:sendTextMessage(MESSAGE_INFO_DESCR, 'Bought '..amount..'x '..items[item].name..' for '..items[item].buy * amount..' gold coins.') end end end return true end local function onSell(cid, item, subType, amount, ignoreCap, inBackpacks) local player = Player(cid) if items[item].sell then if player:addMoney(items[item].sell * amount) then if player:removeItem(items[item].id, amount) then return player:sendTextMessage(MESSAGE_INFO_DESCR, 'Sold '..amount..'x '..items[item].name..' for '..items[item].sell * amount..' gold coins.') end end end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) msg = msg:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end) if msgcontains('trade', msg) then local tradeItems = {} if player:isVip() then tradeItems = tradeOffers openShopWindow(cid, tradeItems, onBuy, onSell) return npcHandler:say('It\'s my offer.', cid) else return npcHandler:say('You don\'t have vip account.', cid) end end end npcHandler:setMessage(MESSAGE_FAREWELL, 'Happy hunting, old chap!') npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Este ele está dando trade tanto pra quem é vip quanto para quem não é Edite- esqueci de edita uma outra parte do npc haha funcionou player:sendVipDaysMessage() eu havia colocado no login mais não apareceu para o player Editado Janeiro 6, 2018 7 anos por leandrocore (veja o histórico de edições)
Postado Junho 8, 2018 6 anos como faço para usar o comando !checkvip ? tentei de tudo que é maneira e não dá kk segue o script que estou utilizando: function onSay(cid, words, param) local player = Player(cid) local days = player:getVipDays() if days == 0 then player:sendCancelMessage('You do not have any vip days.') else player:sendCancelMessage(string.format('You have %s vip day%s left.', (days == 0xFFFF and 'infinite amount of' or days), (days == 1 and '' or 's'))) end return false end Assim não funciona =/
Postado Junho 9, 2018 6 anos Autor @vine96 -- !checkvip function onSay(player, words, param) if player:isVip() then local vipTime = player:getVipTime() - os.time() local vipDays = 1 + (math.floor(vipTime / 86400)) if player:getVipTime() ~= false then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You have '.. vipDays .. ' vip day(s) in your account.') end else player:sendCancelMessage('You do not have any vip days.') end return false end
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.