• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Orbs to sms points?

Zorilyan

New Member
Joined
May 28, 2013
Messages
10
Reaction score
0
Hello otland world, im posting this becouse i need some help

-I need script of 1 NPc to change 100 orbs to 30 sms points.

-Scipt don't allow open more than 3 tibia mc

-Script for evry frag get 1 orb!

-And i need cast system! thanks thats all!
If some one can help mee he will make m glad :$
(Sorry for my english)
 
Last edited:
I dont know if you have the orbs and sms set up in your database.....but here you go....

Code:
local focuses = {}
local function isFocused(cid)
   for i, v in pairs(focuses) do
     if(v == cid) then
       return true
     end
   end
   return false
end

local function addFocus(cid)
   if(not isFocused(cid)) then
     table.insert(focuses, cid)
   end
end
local function removeFocus(cid)
   for i, v in pairs(focuses) do
     if(v == cid) then
       table.remove(focuses, i)
       break
     end
   end
end
local function lookAtFocus()
   for i, v in pairs(focuses) do
     if(isPlayer(v)) then
       doNpcSetCreatureFocus(v)
       return
     end
   end
   doNpcSetCreatureFocus(0)
end

local function getPlayerMoney(cid)
   return ((getPlayerItemCount(cid, 2160) * 10000) +
   (getPlayerItemCount(cid, 2152) * 100) +
   getPlayerItemCount(cid, 2148))
end


function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
   if(isFocused(cid)) then
     selfSay("Hmph!")
     removeFocus(cid)
     if(isPlayer(cid)) then --Be sure he's online
       closeShopWindow(cid)
     end
   end
end

---CUSTOM FUNCTIONS----
function getPlayerSMS(cid)
SELECT `orbs` FROM `accounts` WHERE `id` = getPlayerAccountId(cid)
end

function getPlayerOrbs(cid)
SELECT `sms` FROM `accounts` WHERE `id` = getPlayerAccountId(cid)
end

function setPlayerOrbs(cid, amount)
INSERT INTO `accounts` SET `orbs` = getPlayerOrbs(cid) + amount WHERE `id` = getPlayerAccountId(cid)
end

function setPlayerSMS(cid, amount)
INSERT INTO `accounts` SET `sms` = getPlayerSMS(cid) + amount WHERE `id` = getPlayerAccountId(cid)
end

--------SCRIPT START----------
function onCreatureSay(cid, type, msg)
   if((msg == "hi") and not (isFocused(cid))) then
     selfSay("Welcome to the SMS store. Would you like to see our prices?", cid, true)
     addFocus(cid)
   elseif((isFocused(cid)) and (msg == "yes" or msg == "prices")) then
     selfSay("We sell {30} sms for 100 orbs, or {60} sms for 180 orbs.", cid)
   elseif((is focused(cid)) and (msg == "30" or msg == "30 sms" or msg == "buy 30 sms")) then
     if getPlayerOrbs(cid) < 30 then
       selfSay("You do not have enough orbs.")
     return false
     else
       setPlayerOrbs(cid, -100)
       setPlayerSMS(cid, 30)
     end
   elseif((isfocused(cid)) and (msg == "60" or msg == "60 sms" or msg == "buy 60 sms"))
     if getPlayerOrbs(cid) < 30 then
       selfSay("You do not have enough orbs.")
     return false
     else
       setPlayerOrbs(cid, -180)
       setPlayerSMS(cid, 60)
     end
  
   elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
     selfSay("Goodbye!", cid, true)
     removeFocus(cid)
   end
end

function onPlayerCloseChannel(cid)
   if(isFocused(cid)) then
     selfSay("Hmph!")
     closeShopWindow(cid)
     removeFocus(cid)
   end
end

function onPlayerEndTrade(cid)
   selfSay("It was a pleasure doing business with you.", cid)
end

function onThink()
   for i, focus in pairs(focuses) do
     if(not isCreature(focus)) then
       removeFocus(focus)
     else
       local distance = getDistanceTo(focus) or -1
       if((distance > 4) or (distance == -1)) then
         selfSay("Hmph!")
         closeShopWindow(focus)
         removeFocus(focus)
       end
     end
   end
   lookAtFocus()
end
 
Last edited:
Orb on kill

Code:
function getPlayerOrbs(cid)
SELECT `sms` FROM `accounts` WHERE `id` = getPlayerAccountId(cid)
end

function setPlayerOrbs(cid, amount)
INSERT INTO `accounts` SET `orbs` = getPlayerOrbs(cid) + amount WHERE `id` = getPlayerAccountId(cid)
end



function onKill(cid, target)
if isPlayer(target) then
   if isPlayer(cid) then
     setPlayerOrbs(cid, 1)
   end
end
end
 
Last edited:
Back
Top