Postado Abril 13, 2013 12 anos Fala galera do Fórum tibiaking. Hoje estarei postando uma espécie de shop donate, mais você poderá acessá-lo dentro do jogo. Vamos lá! Vá em data/actions/scripts, copie um arquivo .lua, renomeie para donateshop e cole isso - local t = { [1938] = {100,"arcane staff",2453}, [1939] = {100,"magic plate armor",2472}, } function onUse(cid,item,fromPosition,itemEx,toPosition) local v = t[item.uid] if getPremiumPoints(cid,v[1]) > v[1] and getPlayerFreeCap(cid) >= (getItemWeightById(v[3])) then doPlayerAddItem(cid,v[3]) db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..v[1]..' WHERE id=' .. getPlayerAccountId(cid)) doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have buy a " .. v[2] .. " for "..v[1].." points! Your current balance is "..getPremiumPoints(cid).." points!") elseif getPremiumPoints(cid,v[1]) < v[1] then doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need atleast "..v[1].." points to buy "..getItemNameById(v[3]).."!") elseif getPlayerFreeCap(cid) < (getItemWeightById(v[3])) then doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. getItemWeightById(v[3]) .. ".00 oz in order to get the item") end return true end function getPremiumPoints(cid) local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'') if(res:getID() == -1) then return 0 end local ret = res:getDataInt("premium_points") res:free() return tonumber(ret) end Adicione esta tag em actions.xml -<action uniqueid="1938-1939" event="script" value="donateshop.lua"/> Configuração [1938] = {100,"arcane staff",2453},1938: UniqueId100: Preço2453: ID do item É muito fácil adicionar mais - [1938] = {100,"arcane staff",2453}, [1939] = {100,"magic plate armor",2472}, [1940] = {150,"demon armor",2494}, [1941] = {50,"demon shield",2520}, E não se esqueça de adicionar os uniqueids em actions.xml -<action uniqueid="1938-1941" event="script" value="donateshop.lua"/> Balance Check Este script permite que você verifique a quantidade de pontos na sua acc. Vá em data/actions/scripts, copie um arquivo .lua e renomeie para balance, adicione isso - function onUse(cid,item,fromPosition,itemEx,toPosition) if getPlayerLevel(cid) > 1 then doPlayerSendTextMessage(cid,19,"You have " .. getPremiumPoints(cid) .. " points on your account!") end return true end function getPremiumPoints(cid) local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'') if(res:getID() == -1) then return 0 end local ret = res:getDataInt("premium_points") res:free() return tonumber(ret) end Adicione esta tag em actions.xml - <action uniqueid="12461" event="script" value="balance.lua"/> Balance Check NPC Vá em data/npc, copie um arquivo .xml e renomeie para balance, adicione isso -<?xml version="1.0" encoding="UTF-8"?> <npc name="Balance" script="balance.lua" walkinterval="2000" floorchange="0"> <health now="150" max="150"/> <look type="142" head="114" body="0" legs="95" feet="114" corpse="2212"/> <parameters> <parameter key="module_shop" value="1"/> <parameter key="message_greet" value="Hello |PLAYERNAME|. Would you like to {balance} points?."/> </parameters> </npc> Agora vá em data/npc/scripts, copie um arquivo .lua e renomeie para balance, adicione isso - local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local Topic = {} 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 --[[functions]]-- function getPoints(cid) local res = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."' LIMIT 1 ;") local value = 0 if(res:getID() ~= -1) then value = res:getDataInt("premium_points") res:free() end return value end function greetCallback(cid) Topic[cid] = 0 return true end --[[script start]]-- function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if (msgcontains(msg, 'balance') or msgcontains(msg, 'yes')) and Topic[cid] ~= 1 and Topic[cid] ~= 2 then selfSay("Ok, You have "..getPoints(cid).." premium points on your account!",cid) end return true end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Balance Check Talkaction Isso permite que você cheque seus pontos pelo comando !balance Vá em data/talkactions/scripts, copie um arquivo .lua, renomeie para balance e adicione isso - function onSay(cid, words, param) if getPlayerLevel(cid) > 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You currently have "..getPoints(cid).." points on your account!") end return TRUE end function getPoints(cid) local res = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."' LIMIT 1 ;") local value = 0 if(res:getID() ~= -1) then value = res:getDataInt("premium_points") res:free() end return value end Em talkactions.xml, adicione a seguinte tag - <talkaction log="yes" words="!balance" access="1" event="script" value="balance.lua"/> Bem, espero que gostem!Créditos - limos/CorneXUpdate V2.0 (06/04) - Donate Shop InGame 2.0 ►[Mega Topic] Seu Primeiro Open Tibia Server◄ ►Lista Dos Meus Trabalhos◄
Postado Julho 26, 2014 10 anos Cara como faço pra adicionar esses pontos em uma acc ex: /addpoints GOD , 100... /Revomepoints... ou seria talkations.. E a proposito tenho que executa algo na db?
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.