Postado Outubro 17, 2018 6 anos Olá pessoal do TK eu queria sabe se tem alguma função para eu adicionar x premium points (aquele que é utilizado no shop system), pois fiz um script aqui e ele precisa dessa função, exemplo o player é level 26 e comprou um item que dá vocation, mas o item só permite ter a vocação se for level 25, no caso devolveria os pontos, ao player já que ele não adquiriu a vocação, aqui vai o script feito por mim: Script: Spoiler local config = { Vocation = 413, Outfit = {lookType = 330}, Item = 13487, StorageVoc = 30050, effecterror = 12, effect = 15 } function onThink(cid, interval) if isPlayer(cid) then if getPlayerStorageValue(cid, StorageVoc) == -1 and getPlayerStorageValue(cid, 30023) ~= 4 and getPlayerLevel(cid) < 25 then doPlayerSetVocation(cid, config.Vocation) doCreatureChangeOutfit(cid, config.Outfit) setPlayerStorageValue(cid,config.StorageVoc, 1) doPlayerRemoveItem(cid, config.Item, 1) addEvent(doRemoveCreature, 1, cid) end if getPlayerStorageValue(cid, 30023) == 4 and getPlayerItemCount(cid, config.Item) >= 1 then doPlayerRemoveItem(cid, config.Item, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce nao pode comprar vocation para um player rebornado. Seus pontos foram devolvidos!") end if getPlayerLevel(cid) > 24 and getPlayerItemCount(cid, config.Item) >= 1 then doPlayerRemoveItem(cid, config.Item, 1) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Voce esta acima do nivel que pode ser adquirido a vocation que e 24. Seus pontos foram devolvidos!") doPlayerSendMagicEffect(getCreaturePosition(cid), effecterror) end if getPlayerStorageValue(cid,config.StorageVoc) == 1 and getPlayerItemCount(cid, config.Item) >= 1 then doPlayerRemoveItem(cid, config.Item, 1) doPlayerSendTextMessage(cid,25,"Voce ja possui uma vocation VIP. Seus pontos foram devolvidos!") end end return true end Editado Outubro 17, 2018 6 anos por matheus1234567 (veja o histórico de edições)
Postado Outubro 17, 2018 6 anos Solução @matheus1234567 data/libs/050-function.lua function addPoint(uid, count) local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. getPlayerAccount(uid) .. "' LIMIT 1;") local points = tonumber(accountPoints:getDataInt("premium_points")) db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. points + count .. " WHERE `name`='" .. getPlayerAccount(uid) .. "' LIMIT 1;") end function removePoint(uid, count) local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. getPlayerAccount(uid) .. "' LIMIT 1;") local points = tonumber(accountPoints:getDataInt("premium_points")) db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. points - count .. " WHERE `name`='" .. getPlayerAccount(uid) .. "' LIMIT 1;") end Editado Outubro 17, 2018 6 anos por DukeeH (veja o histórico de edições)
Postado Outubro 17, 2018 6 anos Autor 14 horas atrás, DukeeH disse: @matheus1234567 data/libs/050-function.lua function addPoint(uid, count) local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. getPlayerAccount(uid) .. "' LIMIT 1;") local points = tonumber(accountPoints:getDataInt("premium_points")) db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. points + count .. " WHERE `name`='" .. getPlayerAccount(uid) .. "' LIMIT 1;") end function removePoint(uid, count) local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. getPlayerAccount(uid) .. "' LIMIT 1;") local points = tonumber(accountPoints:getDataInt("premium_points")) db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. points - count .. " WHERE `name`='" .. getPlayerAccount(uid) .. "' LIMIT 1;") end muito obrigado funcionou perfeitamente só tive que alterar de "db.executeQuery" para "db.query"
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.