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

Lua [SQLite] -=[TFS]=- 0.4 8.60 Perfect System VIP 2.0 - Doesn't work as it should

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
When I buy vip a debug error appears and when an old char vip days 0 appears it does not remove the storage and does not remove the nickname [VIP] from the name

Talkaction
Systemvip.lua


Lua:
-- Script SYtem vip 2.0 --

function onSay(cid, words, param)
if(words == "!buyvip") then
local price = 2000
if doPlayerRemoveItem(cid,2159,2000) == TRUE then
local days = 31
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13545)
local timenow = os.time()

if getPlayerStorageValue(cid, 13545) - 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, 13545, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13545) - 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, 13545, 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.." [Donate] Coin's para colocar vip.")
end

elseif(words == "!vipdays") then
local timenow = os.time()
local quantity = math.floor((getPlayerStorageValue(cid, 13545) - 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) == 4 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, 13545) - 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) == 4 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, 13545)
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, 13545, time)
local quantity = math.floor((getPlayerStorageValue(player,13545) - timenow)/(3600*24))
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você tem "..quantity.." dias de VIP restantes.")
else
setPlayerStorageValue(player, 13545, time)
db.executeQuery("UPDATE `players` SET `name` = '[VIP] "..name.."' WHERE `id` = "..getPlayerGUID(player)..";")
doRemoveCreature(player)
end
end

elseif(words == "/delvip") then
if getPlayerAccess(cid) == 4 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,13545) < 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,13545,getPlayerStorageValue(C.uid,13545)-C.time)
end
doSendMagicEffect(C.pos, math.random(28,30))
end
end

return TRUE
end

Creaturescript
endvip.lua


Lua:
function onLogin(cid)
    local vipStorage = getPlayerStorageValue(cid, 13545)
    
    if vipStorage > 0 then
        if vipStorage - os.time() <= 0 then
            setPlayerStorageValue(cid, 13545, -1)
            doPlayerPopupFYI(cid, "Sua VIP Account acabou.")
            if string.find(tostring(getCreatureName(cid)), "%[VIP%]") then
                addEvent(EddyHavoc, 3 * 1000, cid)
            end
        else
            local pos = {x = 154, y = 51, z = 7}
            doTeleportThing(cid, pos)
            doPlayerPopupFYI(cid, "Sua VIP Account acabou.")
            setPlayerStorageValue(cid, 13545, -1)
            if string.find(tostring(getCreatureName(cid)), "%[VIP%]") then
                addEvent(EddyHavoc, 3 * 1000, cid)
            end
        end
    end
    return true
end

Movements
vipe.lua


Lua:
function onStepIn(cid, item, position, pos, fromPosition)

storage = 13545

if getPlayerLevel(cid) < storage then
if getPlayerStorageValue(cid, 13545) <= 0 then
doTeleportThing(cid, fromPosition, TRUE)
pos = getCreaturePosition(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_BIGCLOUDS)
doPlayerPopupFYI(cid,"Você não é vip, digite !buyvip 2.000 [Donate] Coin's Tem Que Ter [DONATE] Coin's se Consegui Passa.")
end
return TRUE
end
end
 
Solution
I think it's better to use the VIP system without adding 'VIP' to the player's name, as it looks ugly. It is best to use the normal VIP system and display animated text above the player.

mod system vip

show effect and animated text
When I buy vip a debug error appears and when an old char vip days 0 appears it does not remove the storage and does not remove the nickname [VIP] from the name

Talkaction
Systemvip.lua


Lua:
-- Script SYtem vip 2.0 --

function onSay(cid, words, param)
if(words == "!buyvip") then
local price = 2000
if doPlayerRemoveItem(cid,2159,2000) == TRUE then
local days = 31
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13545)
local timenow = os.time()

if getPlayerStorageValue(cid, 13545) - 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, 13545, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13545) - 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, 13545, 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.." [Donate] Coin's para colocar vip.")
end

elseif(words == "!vipdays") then
local timenow = os.time()
local quantity = math.floor((getPlayerStorageValue(cid, 13545) - 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) == 4 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, 13545) - 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) == 4 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, 13545)
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, 13545, time)
local quantity = math.floor((getPlayerStorageValue(player,13545) - timenow)/(3600*24))
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você tem "..quantity.." dias de VIP restantes.")
else
setPlayerStorageValue(player, 13545, time)
db.executeQuery("UPDATE `players` SET `name` = '[VIP] "..name.."' WHERE `id` = "..getPlayerGUID(player)..";")
doRemoveCreature(player)
end
end

elseif(words == "/delvip") then
if getPlayerAccess(cid) == 4 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,13545) < 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,13545,getPlayerStorageValue(C.uid,13545)-C.time)
end
doSendMagicEffect(C.pos, math.random(28,30))
end
end

return TRUE
end

Creaturescript
endvip.lua


Lua:
function onLogin(cid)
    local vipStorage = getPlayerStorageValue(cid, 13545)
 
    if vipStorage > 0 then
        if vipStorage - os.time() <= 0 then
            setPlayerStorageValue(cid, 13545, -1)
            doPlayerPopupFYI(cid, "Sua VIP Account acabou.")
            if string.find(tostring(getCreatureName(cid)), "%[VIP%]") then
                addEvent(EddyHavoc, 3 * 1000, cid)
            end
        else
            local pos = {x = 154, y = 51, z = 7}
            doTeleportThing(cid, pos)
            doPlayerPopupFYI(cid, "Sua VIP Account acabou.")
            setPlayerStorageValue(cid, 13545, -1)
            if string.find(tostring(getCreatureName(cid)), "%[VIP%]") then
                addEvent(EddyHavoc, 3 * 1000, cid)
            end
        end
    end
    return true
end

Movements
vipe.lua


Lua:
function onStepIn(cid, item, position, pos, fromPosition)

storage = 13545

if getPlayerLevel(cid) < storage then
if getPlayerStorageValue(cid, 13545) <= 0 then
doTeleportThing(cid, fromPosition, TRUE)
pos = getCreaturePosition(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_BIGCLOUDS)
doPlayerPopupFYI(cid,"Você não é vip, digite !buyvip 2.000 [Donate] Coin's Tem Que Ter [DONATE] Coin's se Consegui Passa.")
end
return TRUE
end
end
I think it does not eliminate the name because you do not have it specified.
Lua:
if getPlayerStorageValue(cid, 13545) <= os.time()  then

db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` = "..getPlayerGUID(cid)..";")

doRemoveCreature(cid)

end

You could add this code in login.lua to check and make the change.
 
I think it's better to use the VIP system without adding 'VIP' to the player's name, as it looks ugly. It is best to use the normal VIP system and display animated text above the player.

mod system vip

show effect and animated text
 
Last edited:
Solution
I think it's better to use the VIP system without adding 'VIP' to the player's name, as it looks ugly. It is best to use the normal VIP system and display animated text above the player.

mod system vip

show effect and animated text

Why?
 

Similar threads

Back
Top