Postado Agosto 19, 2017 7 anos Autor 3 minutos atrás, vankk disse: Passa a sua lib do sistema de VIP. --[[ Name: Vip System by Account Version: 1.0 Author: Kydrai Forum: http://www.xtibia.com/forum/topic/136543-vip-system-by-account-v10/ [Functions] -- Install installVip() -- By Account doTeleportPlayersByAccount(acc, topos) getVipTimeByAccount(acc) setVipTimeByAccount(acc, time) getVipDaysByAccount(acc) isVipAccount(acc) addVipDaysByAccount(acc, days) doRemoveVipDaysByAccount(acc, days) getVipDateByAccount(acc) -- By Player doTeleportPlayers(cid, topos) getVipTime(cid) setVipTime(cid, time) getVipDays(cid) isVip(cid) addVipDays(cid, days) doRemoveVipDays(cid, days) getVipDate(cid) ]]-- -- Install function installVip() if db.executeQuery("ALTER TABLE `accounts` ADD viptime INT(15) NOT NULL DEFAULT 0;") then print("[Vip System] Vip System instalado com sucesso!") return TRUE end print("[Vip System] Não foi possível instalar o Vip System!") return FALSE end -- By Account function doTeleportPlayersByAccount(acc, topos) if db.executeQuery("UPDATE `players` SET `posx` = "..topos.x..", `posy` = "..topos.y..", `posz` = "..topos.z.." WHERE `account_id` = "..acc..";") then return TRUE end return FALSE end function getVipTimeByAccount(acc) local vip = db.getResult("SELECT `viptime` FROM `accounts` WHERE `id` = "..acc..";") if vip:getID() == -1 then print("[Vip System] Account not found!") return FALSE end return vip:getDataInt("viptime") end function setVipTimeByAccount(acc, time) if db.executeQuery("UPDATE `accounts` SET `viptime` = "..time.." WHERE `id` = "..acc..";") then return TRUE end return FALSE end function getVipDaysByAccount(acc) local vipTime = getVipTimeByAccount(acc) local timeNow = os.time() local days = math.ceil((vipTime - timeNow)/(24 * 60 * 60)) return days <= 0 and 0 or days end function isVipAccount(acc) return getVipDaysByAccount(acc) > 0 and TRUE or FALSE end function addVipDaysByAccount(acc, days) if days > 0 then local daysValue = days * 24 * 60 * 60 local vipTime = getVipTimeByAccount(acc) local timeNow = os.time() local time = getVipDaysByAccount(acc) == 0 and (timeNow + daysValue) or (vipTime + daysValue) setVipTimeByAccount(acc, time) return TRUE end return FALSE end function doRemoveVipDaysByAccount(acc, days) if days > 0 then local daysValue = days * 24 * 60 * 60 local vipTime = getVipTimeByAccount(acc) local time = vipTime - daysValue setVipTimeByAccount(acc, (time <= 0 and 1 or time)) return TRUE end return FALSE end function getVipDateByAccount(acc) if isVipAccount(acc) then local vipTime = getVipTimeByAccount(acc) return os.date("%d/%m/%y %X", vipTime) end return FALSE end -- By Player function doTeleportPlayers(cid, topos) doTeleportPlayersByAccount(getPlayerAccountId(cid), topos) end function getVipTime(cid) return getVipTimeByAccount(getPlayerAccountId(cid)) end function setVipTime(cid, time) return setVipTimeByAccount(getPlayerAccountId(cid), time) end function getVipDays(cid) return getVipDaysByAccount(getPlayerAccountId(cid)) end function isVip(cid) return isVipAccount(getPlayerAccountId(cid)) end function addVipDays(cid, days) return addVipDaysByAccount(getPlayerAccountId(cid), days) end function doRemoveVipDays(cid, days) return doRemoveVipDaysByAccount(getPlayerAccountId(cid), days) end function getVipDate(cid) return getVipDateByAccount(getPlayerAccountId(cid)) end 2 minutos atrás, ZikaLord disse: function onUse(cid, item, frompos, item2, topos) local config={ dias="O TANTO DE DIAS QUE ELE VAI RECEBER" } vip.addVipByAccount(getPlayerAccount(getPlayerByName(name)) ,vip.getDays(id) doPlayerSendTextMessage(cid,22,"MENSAGEM AO RECEBER O VIP") doRemoveItem(item.uid,1) return TRUE end vê se assim vai Não vai ,pois nao esta declarado a variavel id e nem name , no codigo da minha talkactions esta declarado ,porem mesmo declarando não vai o item não chega nem a sumir. Ajudei ? Clique em GOSTEI! Skype : neoowned
Postado Agosto 19, 2017 7 anos local config = { days = 30, message = 'Você recebeu 30 dias de VIP. Parabéns!' } function onUse(cid, item, frompos, item2, topos) addVipDays(cid, config.days) doPlayerSendTextMessage(cid, 22, config.message) doRemoveItem(item.uid, 1) return true end Discord: vankk #7765 Precisando de ajuda? Entre em contato comigo via Discord. Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.
Postado Agosto 19, 2017 7 anos Autor 44 minutos atrás, vankk disse: local config = { days = 30, message = 'Você recebeu 30 dias de VIP. Parabéns!' } function onUse(cid, item, frompos, item2, topos) addVipDays(cid, config.days) doPlayerSendTextMessage(cid, 22, config.message) doRemoveItem(item.uid, 1) return true end Funcionou em partes,ao relogar aparece a msg 14:59 Você possui 30 dia(s) de vip. Ela irá durar até 18/09/17 14:59:11. Porem eu não consigo passar no tile. e quando dou o comando !vipdays 15:02 You're not a vip player. You naver has a vip. Citar isto @vankk Te passei a lib errada ,a correta é : vip = { name = "Vip system"; author = "Mock"; version = "1.0.0.0"; query="ALTER TABLE `accounts` ADD `vip_time` INTEGER"; query2="ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL" } function vip.setTable() dofile('config.lua') if sqlType == "sqlite" then db.executeQuery(vip.query) else db.executeQuery(vip.query2) end end function vip.getVip(cid) assert(tonumber(cid),'Parameter must be a number') if isPlayer(cid) == FALSE then error('Player don\'t find') end; ae = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';") if ae:getID() == -1 then return 0 end local retee = ae:getDataInt("vip_time") or 0 ae:free() return retee end function vip.getVipByAcc(acc) assert(acc,'Account is nil') local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';") if a:getID() ~= -1 then return a:getDataInt("vip_time") or 0, a:free() else error('Account don\'t find.') end end function vip.setVip(cid,time) dofile("config.lua") assert(tonumber(cid),'Parameter must be a number') assert(tonumber(time),'Parameter must be a number') if isPlayer(cid) == FALSE then error('Player don\'t find') end; db.executeQuery("UPDATE `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';") end function vip.getVipByAccount(acc) assert(acc,'Account is nil') return db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';"):getDataInt("vip_time") or 0 end function vip.hasVip(cid) assert(tonumber(cid),'Parameter must be a number') if isPlayer(cid) == FALSE then return end; local t = vip.getVip(cid) or 0 if os.time(day) < t then return TRUE else return FALSE end end function vip.hasVips(cid) assert(tonumber(cid),'Parameter must be a number') if isPlayer(cid) == FALSE then return end; local t = vip.getVip(cid) if os.time(day) < t then return TRUE else return FALSE end end function vip.accountHasVip(acc) assert(acc,'Account is nil') if os.time() < vip.getVipByAccount(acc) then return TRUE else return FALSE end end function vip.getDays(days) return (3600 * 24 * days) end function vip.addVipByAccount(acc,time) --assert(acc,'Account is nil') --assert(tonumber(time),'Parameter must be a number') local a = vip.getVipByAcc(acc) a = os.difftime(a,os.time()) if a < 0 then a = 0 end; a = a+time return vip.setVipByAccount(acc,a) end function vip.setVipByAccount(acc,time) dofile("config.lua") assert(acc,'Account is nil') assert(tonumber(time),'Parameter must be a number') db.executeQuery("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';") return TRUE end function vip.returnVipString(cid) assert(tonumber(cid),'Parameter must be a number') if isPlayer(cid) == TRUE then return os.date("%d %B %Y %X ", vip.getVip(cid)) end end Alterei o codigo para : local config = { days = 30, message = 'Você recebeu 30 dias de VIP. Parabéns!' } function onUse(cid, item, frompos, item2, topos) vip.addVipByAccount(acc, config.days) doPlayerSendTextMessage(cid, 22, config.message) doRemoveItem(item.uid, 1) return true end Só que esta me retornando erro no console Existe alguma função alem da OnUse ,que ao inves de ser CID ,seja acc ? Editado Agosto 19, 2017 7 anos por sxeinjected (veja o histórico de edições) Ajudei ? Clique em GOSTEI! Skype : neoowned
Postado Agosto 20, 2017 7 anos Solução local config = { days = 30, message = 'Você recebeu 30 dias de VIP.' } function onUse(cid, item, frompos, item2, topos) vip.setVip(cid,config.days) doPlayerSendTextMessage(cid, 22, config.message) doRemoveItem(item.uid, 1) return true end Te ajudei ?? Que tal fazer uma contribuição ?
Postado Agosto 20, 2017 7 anos Autor 13 horas atrás, DboExplorer disse: local config = { days = 30, message = 'Você recebeu 30 dias de VIP.' } function onUse(cid, item, frompos, item2, topos) vip.setVip(cid,config.days) doPlayerSendTextMessage(cid, 22, config.message) doRemoveItem(item.uid, 1) return true end Deu certo vlw ! Pode me explicar o que essa função pega na config.lua ? function vip.setVip(cid,time) dofile("config.lua") Ajudei ? Clique em GOSTEI! Skype : neoowned
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.