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

Require an Item, not money

Dakotah

New Member
Joined
Feb 4, 2018
Messages
14
Reaction score
0
Hi,
I am not sure if this is the right place to post this, but I am currently working on an VIP Medal, and I would like the command !Addvip to take the medal from you instead of the money it is currently requiring but I am having issue. The ID for the medal is :5785

This is the script I am hoping to change

Code:
-- Script SYtem vip 2.0 --
 
function onSay(cid, words, param)
if(words == "!buyvip") then
local price = 5000000
if doPlayerRemoveMoney(cid, price) == TRUE then
local days = 7
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13540)
local timenow = os.time()
 
if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
 
if string.find(tostring(getCreatureName(cid)),"[[Vip]]") then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
setPlayerStorageValue(cid, 13540, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
setPlayerStorageValue(cid, 13540, time)
local name = getCreatureName(cid)
db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(cid)..";")
doRemoveCreature(cid)
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa de "..price.." gp's para colocar vip.")
end
 
elseif(words == "!vipdays") then
local timenow = os.time()
local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. (quantity < 0 and 0 or quantity) .." dias de VIP no seu character.")
 
elseif(words == "/checkvip") then
if getPlayerAccess(cid) == 5 then
if not param then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
end
 
local player = getPlayerByName(param)
if not isPlayer(player) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player "..player.." not found.")
end
 
local timenow = os.time()
 
local quantity = math.floor((getPlayerStorageValue(player, 13540) - timenow)/(24 * 60 * 60))
doPlayerPopupFYI(cid, "O jogador tem ".. (quantity < 0 and 0 or quantity) .." dias de VIP no character.")
return TRUE
end
 
elseif(words == "/addvip") then
if getPlayerAccess(cid) == 5 then
local t = string.explode(param, ",")
if not t[2] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
end
 
local player = getPlayerByName(t[1])
local name = getCreatureName(player)
local days = t[2]
local pid = getPlayerByNameWildcard(t[1])
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.")
return TRUE
end
 
local daysvalue = days*3600*24
local storageplayer = getPlayerStorageValue(player, 13540)
local timenow = os.time()
local time = storageplayer <= 0 and (timenow + daysvalue) or (storageplayer + daysvalue)
 
if string.find(tostring(getCreatureName(pid)),"[[Vip]]") then
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..days.." dias de VIP no seu character.")
setPlayerStorageValue(player, 13540, time)
local quantity = math.floor((getPlayerStorageValue(player,13540) - timenow)/(3600*24))
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você tem "..quantity.." dias de VIP restantes.")
else
setPlayerStorageValue(player, 13540, time)
db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(player)..";")
doRemoveCreature(player)
end
end
 
elseif(words == "/delvip") then
if getPlayerAccess(cid) == 5 then
local dec = MESSAGE_INFO_DESCR
if(param == "") then return TRUE,doPlayerSendTextMessage(cid,18,"Command param required.")end
local C,t = {},string.explode(param, ",")
C.pos = getPlayerPosition(cid)
C.uid = getCreatureByName(t[1])
C.time = ((tonumber(t[2]) == nil) and 1 or tonumber(t[2]))*3600*24 --Tempo da vip por dia.
C.days = (tonumber(t[2]) == nil) and 1 or tonumber(t[2]) --Dias de vip.
 
if(getPlayerStorageValue(C.uid,13540) < C.time)then
doPlayerSendTextMessage(cid,dec,'O jogador '..t[1]..' não possui '..C.days..' dias de vip.')
else
doPlayerSendTextMessage(cid,dec,'Você removeu '..C.days..' dias de vip do player '..t[1]..'.')
setPlayerStorageValue(C.uid,13540,getPlayerStorageValue(C.uid,13540)-C.time)
end
doSendMagicEffect(C.pos, math.random(28,30))
end
end
 
return TRUE
end

Can anyone help with this? I am sure it is a simple fix but I cant figure it out. I am running an 8.6 which is think is tfs.4

Thanks
 
Solution
Lua:
--/addvip & /removevip time is in minutes. Use: /removevip player, minutes   or  /addvip player, minutes --

local vipStorage = 13540
local itemReq = 5785
local amountReq = 1

function onSay(cid, words, param)
    if (words == "!vip") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[VIP Talkaction]: !buyvip, !checkvip")
        return true
      
    elseif (words == "!buyvip") then
        if doPlayerRemoveItem(cid, itemReq, amountReq) then
            local timeDays = 7 * 24 * 60 * 60
            local timeAdd = 0
          
            if getPlayerStorageValue(cid, vipStorage) == nil or getPlayerStorageValue(cid, vipStorage) == -1 then
                setPlayerStorageValue(cid, vipStorage, 0)...
change doPlayerRemoveMoney(cid, price) to doPlayerRemoveItem(cid, 5785)
you'll also need to change this line doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa de "..price.." gp's para colocar vip.")
since it no longer costs "price" amount of money
also moved the thread to the appropriate board, which is support (you are asking for help, not requesting a script)
 
Like this?

Code:
function onSay(cid, words, param) 
if(words == "!buyvip") then 
if doPlayerRemoveItem(cid, 5785) == TRUE then 
local days = 7
local daysvalue = days * 24 * 60 * 60 
local storageplayer = getPlayerStorageValue(cid, 13540) 
local timenow = os.time() 
 
if getPlayerStorageValue(cid, 13540) - os.time() <= 0 then 
time = timenow + daysvalue 
else 
time = storageplayer + daysvalue 
end 
 
if string.find(tostring(getCreatureName(cid)),"[[Vip]]") then 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.") 
setPlayerStorageValue(cid, 13540, time) 
local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60)) 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.") 
else 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.") 
setPlayerStorageValue(cid, 13540, time) 
local name = getCreatureName(cid) 
db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(cid)..";") 
doRemoveCreature(cid) 
end 
else 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa de "..price.." gp's para colocar vip.") 
end 
 
elseif(words == "!vipdays") then 
local timenow = os.time() 
local quantity = math.floor((getPlayerStorageValue(cid, 13540) - timenow)/(24 * 60 * 60)) 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. (quantity < 0 and 0 or quantity) .." dias de VIP no seu character.") 
 
elseif(words == "/checkvip") then 
if getPlayerAccess(cid) == 5 then 
if not param then 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") 
end 
 
local player = getPlayerByName(param) 
if not isPlayer(player) then 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player "..player.." not found.") 
end 
 
local timenow = os.time() 
 
local quantity = math.floor((getPlayerStorageValue(player, 13540) - timenow)/(24 * 60 * 60)) 
doPlayerPopupFYI(cid, "O jogador tem ".. (quantity < 0 and 0 or quantity) .." dias de VIP no character.") 
return TRUE 
end 
 
elseif(words == "/addvip") then 
if getPlayerAccess(cid) == 5 then 
local t = string.explode(param, ",") 
if not t[2] then 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") 
end 
 
local player = getPlayerByName(t[1]) 
local name = getCreatureName(player) 
local days = t[2] 
local pid = getPlayerByNameWildcard(t[1]) 
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") 
return TRUE 
end 
 
local daysvalue = days*3600*24 
local storageplayer = getPlayerStorageValue(player, 13540) 
local timenow = os.time() 
local time = storageplayer <= 0 and (timenow + daysvalue) or (storageplayer + daysvalue) 
 
if string.find(tostring(getCreatureName(pid)),"[[Vip]]") then 
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..days.." dias de VIP no seu character.") 
setPlayerStorageValue(player, 13540, time) 
local quantity = math.floor((getPlayerStorageValue(player,13540) - timenow)/(3600*24)) 
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você tem "..quantity.." dias de VIP restantes.") 
else 
setPlayerStorageValue(player, 13540, time) 
db.executeQuery("UPDATE `players` SET `name` = '[Vip] "..name.."' WHERE `id` = "..getPlayerGUID(player)..";") 
doRemoveCreature(player) 
end 
end 
 
elseif(words == "/delvip") then 
if getPlayerAccess(cid) == 5 then 
local dec = MESSAGE_INFO_DESCR 
if(param == "") then return TRUE,doPlayerSendTextMessage(cid,18,"Command param required.")end 
local C,t = {},string.explode(param, ",") 
C.pos = getPlayerPosition(cid) 
C.uid = getCreatureByName(t[1]) 
C.time = ((tonumber(t[2]) == nil) and 1 or tonumber(t[2]))*3600*24 --Tempo da vip por dia. 
C.days = (tonumber(t[2]) == nil) and 1 or tonumber(t[2]) --Dias de vip. 
 
if(getPlayerStorageValue(C.uid,13540) < C.time)then 
doPlayerSendTextMessage(cid,dec,'O jogador '..t[1]..' não possui '..C.days..' dias de vip.') 
else 
doPlayerSendTextMessage(cid,dec,'Você removeu '..C.days..' dias de vip do player '..t[1]..'.') 
setPlayerStorageValue(C.uid,13540,getPlayerStorageValue(C.uid,13540)-C.time)
end 
doSendMagicEffect(C.pos, math.random(28,30)) 
end 
end 
 
return TRUE
 
yes, but you didn't change the sendTextMessage
for future reference you could just try it out and see if it works instead of having to ask if it works before trying it
 
Lua:
--/addvip & /removevip time is in minutes. Use: /removevip player, minutes   or  /addvip player, minutes --

local vipStorage = 13540
local itemReq = 5785
local amountReq = 1

function onSay(cid, words, param)
    if (words == "!vip") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[VIP Talkaction]: !buyvip, !checkvip")
        return true
      
    elseif (words == "!buyvip") then
        if doPlayerRemoveItem(cid, itemReq, amountReq) then
            local timeDays = 7 * 24 * 60 * 60
            local timeAdd = 0
          
            if getPlayerStorageValue(cid, vipStorage) == nil or getPlayerStorageValue(cid, vipStorage) == -1 then
                setPlayerStorageValue(cid, vipStorage, 0)
            end
          
            if getPlayerStorageValue(cid, vipStorage) - os.time() <= 0 then
                timeAdd = timeDays + os.time()
            else
                timeAdd = getPlayerStorageValue(cid, vipStorage) + timeDays
            end
          
            setPlayerStorageValue(cid, vipStorage, timeAdd)
            local playerName = getCreatureName(cid)
          
            if string.find(playerName, "[[VIP]]") then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added 7 days to your VIP.")
            else
                db.query("UPDATE `players` SET `name` = [[VIP]] "..playerName.." WHERE `name` = "..playerName..";")
                doRemoveCreature(cid)
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have a medal to buy more VIP time.")
        return true
        end
  
    elseif (words == "!checkvip") then
        if getPlayerStorageValue(cid, vipStorage) == nil or getPlayerStorageValue(cid, vipStorage) == -1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have any vip time.")
            return true
        end
      
        local timeLeft = getPlayerStorageValue(cid, vipStorage) - os.time()
        if timeLeft <= 0 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have any vip time left.")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have "..vipTimeToText(timeLeft).. " of VIP time left.")
            return true
        end
      
    elseif (words == "/addvip") then
        if not getPlayerAccess(cid) >= 5 then
            return false
        else
            local t = string.explode(param, ",")
            playerName = t[1]
            timeAdd = t[2]
          
            if not timeAdd then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Insufficient parameters.")
                return true
            end
          
            timeAdd = tonumber(timeAdd)
            timeAdd = timeAdd * 60
            local player = getPlayerByNameWildcard(playerName)
          
            if player then
                if getPlayerStorageValue(player, vipStorage) == nil or getPlayerStorageValue(player, vipStorage) == -1 then
                    setPlayerStorageValue(player, vipStorage, 0)
                end
              
                local playerName = getCreatureName(player)
              
                if getPlayerStorageValue(cid, vipStorage) - os.time() <= 0 then
                    timeAdd = timeAdd + os.time()
                else
                    timeAdd = getPlayerStorageValue(cid, vipStorage) + timeAdd
                end
              
                setPlayerStorageValue(player, vipStorage, timeAdd)
              
                if string.find(playerName, "[[VIP]]") then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been given VIP time. Use !checkvip to see your new time.")
                else
                    db.query("UPDATE `players` SET `name` = [[VIP]] "..playerName.." WHERE `name` = "..playerName..";")
                    doRemoveCreature(player)
                end
              
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have added vip time to "..playerName..".")
                return true
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online or doesn't exist.")
            return true
            end
        end
      
    elseif (words == "/removevip") then
        if not getPlayerAccess(cid) >= 5 then
            return false
        else
            local t = string.explode(param, ",")
            playerName = t[1]
            timeRemove = t[2]
          
            if not timeRemove then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Insufficient parameters.")
                return true
            end
          
            timeRemove = tonumber(timeRemove)
            timeRemove = timeRemove * 60
            local player = getPlayerByNameWildcard(playerName)
          
            if player then
                if getPlayerStorageValue(player, vipStorage) == nil or getPlayerStorageValue(player, vipStorage) == -1 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player does not have any VIP time left.")
                    return true
                end
              
                local timeLeft = getPlayerStorageValue(player, vipStorage)
              
                if timeLeft - timeRemove <= 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player does not have this much VIP time left.")
                    return true
                else
                    setPlayerStorageValue(player, vipStorage, getPlayerStorageValue(player, vipStorage) - timeRemove)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have removed "..timeRemove.." minutes from "..getCreatureName(player)..".")
                    return true
                end
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player is not online or doesn't exist.")
                return true
            end
        end
    end
return true
end


function vipTimeToText(timeLeft)
    local years = 0
    local months = 0
    local days = 0
    local hours = 0
    local minutes = 0
    local seconds = 0

        while (timeLeft >= 31104000) do
            years = years + 1
            timeLeft = timeLeft - 31104000
        end
          
        while (timeLeft >= 2592000) do
            months = months + 1
            timeLeft = timeLeft - 2592000
        end
          
        while (timeLeft >= 86400) do
            days = days + 1
            timeLeft = timeLeft - 86400
        end
          
        while (timeLeft >= 3600) do
            hours = hours + 1
            timeLeft = timeLeft - 3600
        end
          
        while (timeLeft >= 60) do
            minutes = minutes + 1
            timeLeft = timeLeft - 60
        end
          
        while (timeLeft >= 1) do
            seconds = seconds + 1
            timeLeft = timeLeft - 1
        end
    return years.." years, "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes, and "..seconds.." seconds"
end
 
Last edited:
Solution

Similar threads

Back
Top Bottom