Postado Maio 10, 2018 7 anos boa Noite Galerinha do Tk gostaria de saber se tem como trocar o systema de vip por account e colocar por players 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.query(vip.query) else db.query(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.query("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.query("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
Postado Maio 10, 2018 7 anos Solução eu já fiz um sistema vip por players: Query Primeiro passado execute essa query na sua DB: ALTER TABLE `players` ADD `vipacess` INT(15) NOT NULL DEFAULT 0; Agora vá em Data/lib/050-function e adicione essas funções: function getCharacterAcess(cid) local query = db.getResult("SELECT `vipacess` FROM `players` WHERE `id` = "..getPlayerGUID(cid)) if query:getID() ~= -1 then return query:getDataInt("vipacess") end end function getCharacterDays(cid) local acess = math.ceil((getCharacterAcess(cid) - os.time())/(86400)) return acess <= 0 and 0 or acess end function HaveCharaterAcess(cid) return getCharacterDays(cid) > 0 and true or false end function setAcessTime(cid, time) return db.executeQuery("UPDATE `players` SET `vipacess` = "..time.." WHERE `id` = "..getPlayerGUID(cid)) end function addCharacterAcess(cid, days) local add = (days <= 0 and 1 or days)*86400 local time = getCharacterDays(cid) == 0 and (os.time() + add) or (getCharacterAcess(cid) + add) return setAcessTime(cid, time) end function doRemoveCharacterAcess(cid, days) local remove = days*86400 local time = getCharacterAcess(cid) - remove return setAcessTime(cid, (time <= 0 and 1 or time)) end function getVipAcessDate(cid) if HaveCharaterAcess(cid) then return os.date("%d/%m/%y %X", getCharacterAcess(cid)) end return false end Talkactions agora em talkactions/scripts vipsystemplayer.lua function onSay(cid, words, param) if(words == "!buyvip") then local days = 10 local price = 50000 if not doPlayerRemoveMoney(cid, price) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa de "..price.." gp's para colocar vip.") return true end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados "..days.." dias de VIP no seu character.") addCharacterAcess(cid, days) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem "..getCharacterDays(cid).." dias de VIP, ela acaba em "..getVipAcessDate(cid)) elseif(words == "!vipdays") then return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem "..getCharacterDays(cid).." dias de VIP. "..(getCharacterDays(cid) > 0 and "ela acaba em "..getVipAcessDate(cid).."." or "")) end return true end vipsystemgod.lua function onSay(cid, words, param) if(words == "/checkvip") then if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true end local player = getPlayerByName(param) if not isPlayer(player) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player "..player.." not found.") return true end return doPlayerPopupFYI(cid, "O jogador tem "..getCharacterDays(player).." dias de VIP no character.") elseif(words == "/addvip") then local t = string.explode(param, ",") if not tonumber(t[2]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true end local player = getPlayerByNameWildcard(t[1]) if(not player)then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") end addCharacterAcess(player, tonumber(t[2])) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você adicionou "..tonumber(t[2]).." dias de VIP no player "..getCreatureName(player)) doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..tonumber(t[2]).." dias de VIP no seu character.") elseif(words == "/delvip") then local t = string.explode(param, ",") if not tonumber(t[2]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true end local player = getPlayerByNameWildcard(t[1]) if(not player)then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.") end doRemoveCharacterAcess(player, tonumber(t[2])) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você removeu "..tonumber(t[2]).." dias de VIP do jogador "..getCreatureName(player)..".") end return true end em talkactions.xml adicione as tags: <talkaction words="!buyvip;!vipdays" event="script" value="vipsystemplayer.lua"/> <talkaction words="/addvip;/delvip;/checkvip" access="4" event="script" value="vipsystemgod.lua"/> Item Vip item que adiciona vip no character actions/script addvipdays.lua function onUse(cid, item, fromPosition, itemEx, toPosition) local days = 15 addCharacterAcess(cid, (days <= 0 and 1 or days)) doRemoveItem(item.uid) return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem "..getCharacterDays(cid).." dias de VIP, ela acaba em "..getVipAcessDate(cid)) end Actions.xml <action itemid="ID DO SEU ITEM" script="addvipdays.lua"/> Vip Door actions/script perfectvipdoor.lua function onUse(cid, item, frompos, item2, topos) if not HaveCharaterAcess(cid) then return doPlayerSendTextMessage(cid,22,"Você precisa ser vip para passar aqui.") end doTransformItem(item.uid, item.itemid + 1) doTeleportThing(cid, topos, true) return true end actions.xml <action actionid="7779" script="perfectvipdoor.lua"/> Tile VIP em movements/scripts crie um arquivo.lua e renomeie para vipe.lua function onStepIn(cid, item, position, fromPosition) if item.actionid == 13700 and not HaveCharaterAcess(cid) then doTeleportThing(cid, fromPosition, true) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você não é vip.") doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) return true end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"bem vindo.") return true end Em movements.xml adicione a tag: <movevent type="StepIn" actionid="13700" event="script" value="vipe.lua"/> no seu piso coloque ACTIONID 13700 Fim Vip em creaturescript/script endvip.lua function onLogin(cid) if getCharacterDays(cid) > 0 then setPlayerStorageValue(cid, 9898, 1) elseif getPlayerStorageValue(cid, 9898) == 1 and getCharacterDays(cid) <= 0 then doPlayerSetTown(cid, 1) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doPlayerPopupFYI(cid, "Sua vip Account acabou.") setPlayerStorageValue(cid, 9898, -1) end return true end em creaturescript.xml adicione a tag: <event type="login" name="CheckVip" script="endvip.lua"/> -------------------------------------------------------------------------------------------------------------------- só procurar no Google: Perfect Vip System 3.0 [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Maio 10, 2018 7 anos Autor mas ae meu script e so trocar por esse dai ou tenho q apagar o meu e colocar o seu ?
Postado Maio 20, 2018 7 anos Autor @Vodkart estou tentando usar um efeito de vip saindo do players quando ele compra a vip mas nao esta dando certo local rnd = {"[VIP]"} function onLogin(cid) sendEffect(cid) registerCreatureEvent(cid, "AdvEffect") return true end function sendEffect(cid) if isCreature(cid) then if vip.hasVip(cid) == true then pos = getThingPos(cid) doSendAnimatedText(pos, rnd[math.random(#rnd)], 210) addEvent(sendEffect, 5200,cid) end end end segue o erro [Error - CreatureScript Interface] data/creaturescripts/scripts/vipeffect.lua:onLogin Description: data/creaturescripts/scripts/vipeffect.lua:11: attempt to index global 'vip' (a nil value) stack traceback: data/creaturescripts/scripts/vipeffect.lua:11: in function 'sendEffect' data/creaturescripts/scripts/vipeffect.lua:4: in function <data/creaturescripts/scripts/vipeffect.lua:3> tem como dar uma ajuda ae e tem esse que vc fez pra min function onSay(cid, words, param, channel) local storage,days = (getPlayerAccountId(cid)+753200),1 if getGlobalStorageValue(storage) > 0 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce só pode usar esse comando 1 vez por account!") return true end setGlobalStorageValue(storage, 1) vip.addVipByAccount(getPlayerAccount(cid) ,vip.getDays(tonumber(days))) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você recebeu "..days.." dias de VIP, bom jogo!") addEvent(doRemoveCreature,1000,cid) return true end que com o seu sistema vip ta dando esse erro [Error - TalkAction Interface] data/talkactions/scripts/vipgratis.lua:onSay Description: data/talkactions/scripts/vipgratis.lua:7: attempt to index global 'vip' (a nil value) stack traceback: data/talkactions/scripts/vipgratis.lua:7: in function <data/talkactions/scripts/vipgratis.lua:1> eu queria q ele so pudesse ser usado uma ver por account Editado Maio 20, 2018 7 anos por mullino (veja o histórico de edições)
Postado Maio 20, 2018 7 anos tem que mudar as funções local rnd = {"[VIP]"} function onLogin(cid) sendEffect(cid) registerCreatureEvent(cid, "AdvEffect") return true end function sendEffect(cid) if isCreature(cid) and HaveCharaterAcess(cid) then local pos = getThingPos(cid) doSendAnimatedText(pos, rnd[math.random(#rnd)], 210) addEvent(sendEffect, 5200,cid) end end function onSay(cid, words, param, channel) local storage,days = (getPlayerAccountId(cid)+753200),1 if getGlobalStorageValue(storage) > 0 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce só pode usar esse comando 1 vez por account!") return true end setGlobalStorageValue(storage, 1) addCharacterAcess(cid, (days <= 0 and 1 or days)) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você recebeu "..days.." dias de VIP, bom jogo!") return true end [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
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.