• 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!

will this script work ?

Zombiegod

Active Member
Joined
Oct 22, 2009
Messages
198
Solutions
1
Reaction score
25
Code:
local mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42}
local daily = getPlayerStorageValue(cid, 13541)
local daysvalue = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerAccess(cid, 0) then
if getPlayerStorageValue(cid, getItemDescriptions(18423), 0) then
if getItemDescriptions == 'No one owns this.' then
doSetItemDesc( .. getPlayerName(cid) .. 'owns this.') then
if getPlayerStorageValue(cid,getItemDescriptions(cid), 0) then
setPlayerStorageValue(cid,getItemDescriptions(cid), 1)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns that.')
end
end
end
if getPlayerStorageValue(cid, getItemDescriptions(cid), 1) then
doPlayerAddMount(math.random(#mounts))
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_SOUND_BLUE)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns that.')
end
if (daily == -1) then
daily = 0
end
if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
time = os.time() + daysvalue
setPlayerStorageValue(cid, 13540, time)
setPlayerStorageValue(cid, 13541, daily+1)
local daily = getPlayerStorageValue(cid, 13541)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. daily .. " Daily Mount. Enjoy.")
elseif (daily == 42) then
doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR, "You recived all possible mounts")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, 13540)) .. ".")
end
return true
end
 
Code:
local mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42}
local daily = getPlayerStorageValue(cid, 13541)
local daysvalue = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local time
    if getPlayerAccess(cid, 0) then
        if getPlayerStorageValue(cid, getItemDescriptions(18423), 0) then
            if getItemDescriptions == 'No one owns this.' then
                doSetItemDesc( .. getPlayerName(cid) .. 'owns this.') then
                if getPlayerStorageValue(cid,getItemDescriptions(cid), 0) then
                    setPlayerStorageValue(cid,getItemDescriptions(cid), 1)
                else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns that.')
                end
            end
        end
       
        if getPlayerStorageValue(cid, getItemDescriptions(cid), 1) then
            doPlayerAddMount(math.random(#mounts))
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_SOUND_BLUE)
            else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns that.')
        end
       
        if (daily == -1) then
        daily = 0
        end
       
        if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
            time = os.time() + daysvalue
            setPlayerStorageValue(cid, 13540, time)
            setPlayerStorageValue(cid, 13541, daily+1)
            daily = getPlayerStorageValue(cid, 13541)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. daily .. " Daily Mount. Enjoy.")
        elseif (daily == 42) then
            doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR, "You recived all possible mounts")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, 13540)) .. ".")
        end
    return true
end
it is ok but i have fixed some mistakes from them
1-tabbing :)
2-you didn't declare time. i added it at the top local time
3-no need to re declare daily again.it is already declared at the top.i removed the local
anyway good and remember to tab to get help :)
 
Code:
local mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42}
local daily = getPlayerStorageValue(cid, 13541)
local daysvalue = 60

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local time
    if getPlayerAccess(cid, 0) then
        if getPlayerStorageValue(cid, getItemDescriptions(18423), 0) then
            if getItemDescriptions == 'No one owns this.' then
                doSetItemDesc( .. getPlayerName(cid) .. 'owns this.') then
                if getPlayerStorageValue(cid,getItemDescriptions(cid), 0) then
                    setPlayerStorageValue(cid,getItemDescriptions(cid), 1)
                else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns that.')
                end
            end
        end
      
        if getPlayerStorageValue(cid, getItemDescriptions(cid), 1) then
            doPlayerAddMount(math.random(#mounts))
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_SOUND_BLUE)
            else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns that.')
        end
      
        if (daily == -1) then
        daily = 0
        end
      
        if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
            time = os.time() + daysvalue
            setPlayerStorageValue(cid, 13540, time)
            setPlayerStorageValue(cid, 13541, daily+1)
            daily = getPlayerStorageValue(cid, 13541)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. daily .. " Daily Mount. Enjoy.")
        elseif (daily == 42) then
            doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR, "You recived all possible mounts")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, 13540)) .. ".")
        end
    return true
end
it is ok but i have fixed some mistakes from them
1-tabbing :)
2-you didn't declare time. i added it at the top local time
3-no need to re declare daily again.it is already declared at the top.i removed the local
anyway good and remember to tab to get help :)
lol btw the last to mistakes were not mine, as im still learning all the functions, i take parts from other scripts, if i have no idea how to do it, everything the deals with time is not my scripting lol
 
Any errors in console? what your problem with this script?
this topic, was about how i was curious as to if this script the way i scripted it would work, as i had no idea if it would work, did not want to try to input a script that would crash the server, so as of this moment there is no errors with it (have yet to test it)
 
No, it won't works.
The whole script bugged
what exactly are you trying to do?

make a personal item that can only be used by the first person that used it, that takes 24 hours to use, and for each use gives a mount, and at the end the item gets remove from the inventory
 
Not tested but it should works
Code:
local cfg ={
   mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42},
   storage = 13540
   }

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getItemAttribute(item.uid, "description") ~= nil then
    desc = getItemAttribute(item.uid, "description")
else
    desc = getItemInfo(item.itemid)
end
if desc ~= "No one owns this." then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns this.')
else
   if desk == ""..getPlayerName(cid) .." owns this." then
     if getPlayerStorageValue(cid, cfg.storage) < os.time() then
       mounts = getItemAttribute(item.uid, "mounts")
       if #mounts > 0 then
         random_outfit = (math.random(#mounts))
         doPlayerAddMount(random_outfit)
         setPlayerStorageValue(cid, cfg.storage, (os.time() + 86400))
         for k,v in ipairs(mounts) do
           if v == random_outfit then
             table.remove(mounts,v)
           end
         end
         doItemSetAttribute(item.uid, "mounts", mounts)
       else
         doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR, "You have recived all possible mounts")
         doRemoveItem(item.uid)
       end
     else
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, cfg.storage)) .. ".")
     end
   else
     doSetItemSpecialDescription(item.uid, ""..getPlayerName(cid) .." owns this.")
     doItemSetAttribute(item.uid, "mounts", cfg.mounts)
   end
end
   return true
end
 
Not tested but it should works
Code:
local cfg ={
   mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42},
   storage = 13540
   }

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getItemAttribute(item.uid, "description") ~= nil then
    desc = getItemAttribute(item.uid, "description")
else
    desc = getItemInfo(item.itemid)
end
if desc ~= "No one owns this." then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'Sorry someone else owns this.')
else
   if desk == ""..getPlayerName(cid) .." owns this." then
     if getPlayerStorageValue(cid, cfg.storage) < os.time() then
       mounts = getItemAttribute(item.uid, "mounts")
       if #mounts > 0 then
         random_outfit = (math.random(#mounts))
         doPlayerAddMount(random_outfit)
         setPlayerStorageValue(cid, cfg.storage, (os.time() + 86400))
         for k,v in ipairs(mounts) do
           if v == random_outfit then
             table.remove(mounts,v)
           end
         end
         doItemSetAttribute(item.uid, "mounts", mounts)
       else
         doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR, "You have recived all possible mounts")
         doRemoveItem(item.uid)
       end
     else
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, cfg.storage)) .. ".")
     end
   else
     doSetItemSpecialDescription(item.uid, ""..getPlayerName(cid) .." owns this.")
     doItemSetAttribute(item.uid, "mounts", cfg.mounts)
   end
end
   return true
end
forgot to say im using tfs 1.0 tibia10.31

http://1.imgland.net/8xi2ML.jpg
 
My first attempt with 1.0 xD
won't be surprised if it didn't works
Code:
local cfg ={
   mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42},
   storage = 13540
   }

function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
desc = Item(item.uid):getAttribute("description")
if desc ~= "No one owns this." then
   player:sendTextMessage(MESSAGE_STATUS_WARNING, "Sorry someone else owns this.")
else
   if desc == ""..player:getName() .." owns this." then
    if player:getStorageValue(cfg.storage) < os.time() then
      mounts = Item(item.uid):getAttribute("mounts")
      if #mounts > 0 then
       random_outfit = (math.random(#mounts))
       player:addMount(random_outfit)
       player:setStorageValue(cfg.storage, (os.time() + 86400))
       for k,v in ipairs(mounts) do
        if v == random_outfit then
          table.remove(mounts,v)
        end
       end
       Item(item.uid):setAttribute("mounts", mounts)
      else
       player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have recived all possible mounts")
       Item(item.uid):remove(1)
      end
    else
      player:sendTextMessage(MESSAGE_STATUS_WARNING, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", player:getStorageValue(cfg.storage)) .. ".")
    end
   else
     Item(item.uid):setAttribute("description", ""..player:getName() .." owns this.")
     Item(item.uid):setAttribute("mounts", cfg.mounts)
   end
end
   return true
end
 
Try with this and post what print on your console
Code:
local cfg ={
   mounts = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42},
   storage = 13540
   }

function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
desc = Item(item.uid):getAttribute("description")
if desc ~= "No one owns this." then
   player:sendTextMessage(MESSAGE_STATUS_WARNING, "Sorry someone else owns this.")
   print("Code:1,"..desc.."")
else
   if desc == ""..player:getName() .." owns this." then
     print("Code:2,"..desc.."")
    if player:getStorageValue(cfg.storage) < os.time() then
      mounts = Item(item.uid):getAttribute("mounts")
      if #mounts > 0 then
       random_outfit = (math.random(#mounts))
       player:addMount(random_outfit)
       player:setStorageValue(cfg.storage, (os.time() + 86400))
       for k,v in ipairs(mounts) do
        if v == random_outfit then
          table.remove(mounts,v)
        end
       end
       Item(item.uid):setAttribute("mounts", mounts)
      else
       player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have recived all possible mounts")
       Item(item.uid):remove(1)
      end
    else
      player:sendTextMessage(MESSAGE_STATUS_WARNING, "You must wait 24 Hours to get your daily mount. Next available mount will be at: " .. os.date("%H:%M:%S", player:getStorageValue(cfg.storage)) .. ".")
    end
   else
     Item(item.uid):setAttribute("description", ""..player:getName() .." owns this.")
     Item(item.uid):setAttribute("mounts", cfg.mounts)
   end
end
   return true
end
 
Back
Top