Postado Dezembro 13, 2014 10 anos Galera, gostaria de saber como faço um sistema vip de compra pro meu server! tipo assim, quando digitar !buyvip ele adquire vip por 30 dias e tem acesso a uma area especial
Postado Dezembro 13, 2014 10 anos Vai na pasta data/lib e cria um arquivo chamado 049-vipsys.lua e adiciona isso dentro: vip = { name = "Vip system"; author = "Mock"; version = "1.0.0.0"; query="ALTER TABLE `accounts` ADD `prem_days` INTEGER"; query2="ALTER TABLE `accounts` ADD `prem_days` INT(15) NOT NULL" } function vip.setTable() dofile('config.lua') if sqlType == "mysql" 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_days` 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_days` 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_days` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';") end function vip.getVipByAccount(acc) assert(acc,'Account is nil') return db.getResult("SELECT `vip_days` 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_days` = '"..(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 Agora vai na pasta data/talkactions e abre o arquivo talkactions.xml e adiciona essa tag: Agora vai na pasta data/talkactions/scripts e cria um arquivo chamado buyvip.lua e coloca isso dentro: function onSay(cid, words, param, channel) vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(30)) doPlayerRemoveItem(cid, 9971, 30) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce adquiriu 30 dias de VIP!") return true end Ve aí se funciona. É pq aqui no meu ot tem esse sistema vip, mas ñ uso então ñ sei se ta tudo ok. Se der certo, me avisa que aí eu bolo um jeito do player entrar na area vip. Mas eu queria saber o que vc tem em mente, se é tipo, o player falar <b>!flycityvip</b> (ou sei la) ou se vc qr um piso que cheque se o player é vip pra poder entrar. Editado Dezembro 13, 2014 10 anos por danihcv (veja o histórico de edições) Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
Postado Dezembro 13, 2014 10 anos Autor Vai na pasta data/lib e cria um arquivo chamado 049-vipsys.lua e adiciona isso dentro: vip = { name = "Vip system"; author = "Mock"; version = "1.0.0.0"; query="ALTER TABLE `accounts` ADD `prem_days` INTEGER"; query2="ALTER TABLE `accounts` ADD `prem_days` INT(15) NOT NULL" } function vip.setTable() dofile('config.lua') if sqlType == "mysql" 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_days` 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_days` 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_days` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';") end function vip.getVipByAccount(acc) assert(acc,'Account is nil') return db.getResult("SELECT `vip_days` 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) &lt; 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) &lt; t then return TRUE else return FALSE end end function vip.accountHasVip(acc) assert(acc,'Account is nil') if os.time() &lt; 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 &lt; 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_days` = '"..(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 Agora vai na pasta data/talkactions e abre o arquivo talkactions.xml e adiciona essa tag: Agora vai na pasta data/talkactions/scripts e cria um arquivo chamado buyvip.lua e coloca isso dentro: function onSay(cid, words, param, channel) vip.addVipByAccount(getPlayerAccount(cid), vip.getDays(30)) doPlayerRemoveItem(cid, 9971, 30) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce adquiriu 30 dias de VIP!") return true end Ve aí se funciona. É pq aqui no meu ot tem esse sistema vip, mas ñ uso então ñ sei se ta tudo ok. Se der certo, me avisa que aí eu bolo um jeito do player entrar na area vip. Mas eu queria saber o que vc tem em mente, se é tipo, o player falar <b>!flycityvip</b> (ou sei la) ou se vc qr um piso que cheque se o player é vip pra poder entrar. Quero um piso que cheque se o player é vip
Postado Dezembro 13, 2014 10 anos Testa ae: local back = getPlayerPosition(cid).y-1 local tile = ACTION_ID --ACTION ID DO TILE AQUI function onStepIn(cid, item, pos) if vip.getDays(days) >= 1 then if item.actionid == tile then if vip.getDays(days) == 0 then doPlayerSendCancel(cid,"Esta área é exclusiva para players Premium.") doTeleportThing(cid, back) else end end end end Não esquece de botar o actionID do piso onde está escrito: tile = ACTION_ID Não testei, pois não tenho sistema vip ligado no meu ot. Editado Dezembro 13, 2014 10 anos por danihcv (veja o histórico de edições) Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
Postado Janeiro 7, 2015 10 anos O tópico foi movido para a área correta, preste mais atenção da próxima vez! Leia as regras do fórum: http://tibiaking.com/forum/topic/1281-regras-gerais/?p=7680 Este tópico foi movido: De: "OTServ → Scripting → Geral" Para: "OTServ → Suporte OTServ → Suporte de Scripts" -"Supra Omnes Lux Lucis" - Acima de todos brilha a Luz -
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.