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

VIP System on Players

lSenturion2

Member
Joined
Oct 2, 2019
Messages
37
Reaction score
17
Im trying to do VIP system but it works only in Players database.

I have this script named "vipend.lua" , on creaturescripts.
Code:
function onLogin(cid)
local temple = { x =32369, y = 32241, z = 7}
if getPlayerVipDay(cid) >= 1 then
if getPlayerStorageValue(cid,55556) ~= 1 then
setPlayerStorageValue(cid,55556,1)
end
else
if getPlayerStorageValue(cid,55556) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Your VIP Time over!")
db.executeQuery("UPDATE `players` SET `vipday` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerStorageValue(cid, 55556, 0)
end
end
return true
end

The server shows an error in console and I cant log in in my serve. Please help me <3Sin título.png
 
Solution
What I did on my server and it worked well: I created an action that an item adds 30 days of VIP and it has specific storage, in this case 3009. To enter TPs, doors, etc. I place a condition on the map that the player you can only enter if you have this storage. The same goes for talkactions and other scripts.

Follow my vip.lua

Lua:
local vipStorage = 30009
local vipDays = 30

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local currentTime, vipStorageValue = os.time(), getPlayerStorageValue(cid, vipStorage)
    setPlayerStorageValue(cid, vipStorage, (vipStorageValue < currentTime and currentTime or vipStorageValue) + (60 * 60 * 24 * vipDays))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations...

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
989
Solutions
96
Reaction score
1,012
Location
London
GitHub
MillhioreBT
The function getPlayerVidDay(cid) is returning a boolean value, and boolean values cannot be compared to numbers

so look in your library of functions, or wherever that function is declared and investigate why it is returning a boolean value instead of the remaining days of VIP that your character has

you should try trying:
for some reason I think that the function already checks the days and returns a boolean, false to indicate that you are not vip and true to indicate that you are
Although the name of the function is quite crappy and does not make much sense :D

line 3:
if getPlayerVipDay(cid) then
 

pink_panther

Premium User
Premium User
Joined
Sep 10, 2016
Messages
716
Solutions
9
Reaction score
297
Location
Kazordoon
1616658858670.png

Looks like getPlayerVipDay(cid) is a bool...

Where is getPlayerVipDay() defined?

If it's just returning a bool if there are VIP days, then just do:

if getPlayerVipDay(cid) then
 

pink_panther

Premium User
Premium User
Joined
Sep 10, 2016
Messages
716
Solutions
9
Reaction score
297
Location
Kazordoon
you would just need to designate a storage value as your premium and change/add a new function to check if they have that storage value.

Or change your player:hasPremium to check for that value instead of whether the account has days.
 

potinho

Active Member
Joined
Oct 11, 2009
Messages
311
Solutions
7
Reaction score
25
Location
Brazil
What I did on my server and it worked well: I created an action that an item adds 30 days of VIP and it has specific storage, in this case 3009. To enter TPs, doors, etc. I place a condition on the map that the player you can only enter if you have this storage. The same goes for talkactions and other scripts.

Follow my vip.lua

Lua:
local vipStorage = 30009
local vipDays = 30

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local currentTime, vipStorageValue = os.time(), getPlayerStorageValue(cid, vipStorage)
    setPlayerStorageValue(cid, vipStorage, (vipStorageValue < currentTime and currentTime or vipStorageValue) + (60 * 60 * 24 * vipDays))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you've added " .. vipDays .. " VIP days to this account!")
    doRemoveItem(item.uid, 1)
    return true
end
 
Solution
OP
L

lSenturion2

Member
Joined
Oct 2, 2019
Messages
37
Reaction score
17
Ok, let me try something... i will test it
Post automatically merged:

I have try this action
Code:
function onUse(cid, item, frompos, item2, topos)
local vipStorage = 30009
local vipDays = 1
local USurvival = {
    

    exhaust = 7 * 24 * 60 * 60, -- Tempo em segundos ate poder entrar novamente na arena (1 * 24 * 60 * 60 = 1 dia)

    storage_ex = 65863,
}
if getPlayerStorageValue(cid, USurvival.storage_ex) <= os.time() then
    local currentTime, vipStorageValue = os.time(), getPlayerStorageValue(cid, 30009)
    setPlayerStorageValue(cid, 30009, (vipStorageValue < currentTime and currentTime or vipStorageValue) + (60 * 60 * 24 * vipDays))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you've added " .. vipDays .. " VIP days to this account!")
setPlayerStorageValue(cid, USurvival.storage_ex, os.time() + USurvival.exhaust)
doSendMagicEffect(getPlayerPosition(cid),30)
else
                local left = getPlayerStorageValue(cid, USurvival.storage_ex) - os.time()
        left = {days = math.floor(left/86400), hour = math.floor(86400/3600), minutes = math.ceil((left % 3600)/60)}
        doPlayerSendTextMessage(cid,21,'You have to wait '.. left.days ..' days, '.. left.hour ..' hours and '..left.minutes..'minutes. to open the chest again.')
        doSendMagicEffect(getThingPos(cid), 2)
end
end
but when i use the chest, it dont give me the Storage 30009
Post automatically merged:

Nevermind, i fixed hahaha Thanks a lot bro, im gonna test if this removes past 24 hrs
 
Last edited:
Top