Jump to content

help in script


Recommended Posts

hiall so iam creating convertviptocash for my vip system which i was having problems in it and i fixed it so guys can any one help i this script

error attempt to perform arithmetic on a string value

warrnings bad argument @ getElementData expected element at argument 1 got nil

script

server

function Converteviptocash () 
getElementData(client, "VIP Hours") 
setElementData(client, "VIP Hours"-1) 
givePlayerMoney ( thePlayer, 10000 ) 
end 
  
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

i want when payer type the command it give him cash and -1 hour

Link to comment
function Converteviptocash (thePlayer) 
    setElementData(thePlayer, "VIP Hours", getElementData(thePlayer, "VIP Hours")-1) 
    givePlayerMoney ( thePlayer, 10000 ) 
end 
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

Link to comment

They should.

function Converteviptocash (thePlayer) 
    setElementData(thePlayer, "VIP Hours", (tonumber(getElementData(thePlayer, "VIP Hours")) or 0)-1) 
    givePlayerMoney ( thePlayer, 10000 ) 
end 
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

Link to comment

the vip system

local sx, sy = guiGetScreenSize() 
  
function makeGUI() 
    vipGUI = guiCreateWindow((sx / 2) - (694 / 2), (sy / 2) - (526 / 2), 694, 526, "VIPs", false) 
    guiWindowSetSizable(vipGUI , false) 
    guiSetAlpha(vipGUI , 1.00) 
    guiSetVisible(vipGUI, false) 
    nameEdit = guiCreateEdit(9, 22, 152, 30, "", false, vipGUI) 
    list = guiCreateGridList(9, 61, 670, 408, false, vipGUI) 
    guiSetEnabled(nameEdit, false) 
    guiGridListAddColumn(list, "Account", 0.7) 
    guiGridListAddColumn(list, "Time", 0.1) 
    closeBttn = guiCreateButton(11, 483, 668, 33, "Close This Window", false, vipGUI) 
     
    addEventHandler("onClientGUIClick", closeBttn, function() guiSetVisible(vipGUI, false) showCursor(false) end, false) 
end 
addEventHandler("onClientResourceStart", resourceRoot, makeGUI) 
  
function showDonateMembers(d) 
    guiSetVisible(vipGUI, true) 
    showCursor(true) 
    guiGridListClear(list) 
    local online = 0 
     
    local online = 0 
    for ind, data in pairs(d) do 
        online = online + 1 
        local row = guiGridListAddRow(list) 
        local nTime = data - 1 
        if (nTime > 1) then 
            data = nTime 
        end 
        guiGridListSetItemText(list, row, 1, tostring(ind), false, false) 
        guiGridListSetItemText(list, row, 2, tostring(data), false, false) 
    end 
     
    guiSetText(nameEdit, "VIP Online: "..online) 
end 
addEvent("donate.showDonateMembers", true) 
addEventHandler("donate.showDonateMembers", root, showDonateMembers) 

  
local donate = {} 
local allTimeDonate = {} 
local con = dbConnect("sqlite", "db/donate.db") 
dbExec(con, "CREATE TABLE IF NOT EXISTS donators (account TEXT, time TEXT)") 
  
function loadUsers(query) 
    local data = dbPoll(query, 0) 
    if (data) then 
        for ind, d in ipairs(data) do 
            allTimeDonate[d.account] = d.time 
            if (d.account and getAccount(d.account) and getAccountPlayer(getAccount(d.account))) then 
                donate[d.account] = tonumber(d.time) 
            end 
        end 
    end 
end 
dbQuery(loadUsers, con, "SELECT * FROM donators") 
  
function isPlayerDonator(player) 
    local account = getAccountName(getPlayerAccount(player)) 
    return donate[account] 
end 
  
function addDonatorToDB(player, cmd, account, hours) 
    if (not (hasObjectPermissionTo(player, "function.banPlayer", false))) then return end 
     
    if (account and hours) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
         
        if (not tonumber(hours) or tonumber(hours) < 0) then 
            outputChatBox(tostring(hours).." is an invalid hour specific", player, 2500, 0, 0) 
            return 
        end 
         
        local plr = getAccountPlayer(getAccount(account)) 
         
        if (not allTimeDonate[getAccount(account)]) then 
            dbExec(con, "INSERT INTO donators (account, time) VALUES (?, ?)", tostring(account), tostring(hours)) 
            donate[account] = tonumber(hours) 
            if (tonumber(hours) == 0) then 
                hours = "infinite" 
            end 
            outputDebugString(getPlayerName(player).. " added "..hours.." VIP hours to "..account) 
            outputChatBox("Added "..hours.." VIP hours to "..account, player, 255, 150, 0) 
            if (plr) then 
                outputChatBox(getPlayerName(player).." added "..hours.." VIP hours to your account ("..account..")", plr, 0, 2500, 0) 
            end 
        end 
    end 
end 
addCommandHandler("addvip", addDonatorToDB) 
  
function removeOfflineVIP(player, cmd, account) 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
     
    if (account) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
         
        if (donate[account]) then donate[account] = nil end 
        if (allTimeDonate[account]) then allTimeDonate[account] = nil end 
        dbExec(con, "DELETE FROM donators WHERE account=?", tostring(account)) 
        outputDebugString(getPlayerName(player).. " removed account "..account.." from database") 
    end 
end 
addCommandHandler("removevip", removeOfflineVIP) 
  
function makeDonateTick() 
    for ind, d in pairs(donate) do 
        if (ind and getAccount(ind)) then 
            if (getAccountPlayer(getAccount(ind))) then 
                if (donate[ind] and donate[ind] < 1 and donate[ind] ~= 0) then 
                    donate[ind] = nil 
                    allTimeDonate[ind] = nil 
                    dbExec(con, "DELETE FROM donators WHERE account=?", tostring(ind)) 
                    outputDebugString("Remove account "..ind.." from database because time ran out", root, 255, 255, 0) 
                elseif (donate[ind] and donate[ind] > 1 and donate[ind] ~= 0) then 
                    donate[ind] = donate[ind] - 1 
                    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[ind]), tostring(ind)) 
                    outputDebugString("Account "..ind.." VIP Time set to "..donate[ind].." Hours") 
                elseif (donate[ind]) then 
                    outputDebugString("Account "..ind.." has infinite VIP hours") 
                end 
            end 
        end 
    end 
end 
setTimer(makeDonateTick, 3600000 , 0) 
  
function getVipsTable(player) 
    --if (exports.CEDadmin:doesPlayerHaveAccess(player, "viewVipGUI")) then 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    triggerClientEvent(player, "donate.showDonateMembers", player, allTimeDonate) 
end 
addCommandHandler("showvip", getVipsTable) 
  
function donaterLoggedIn() 
    dbQuery(loadUsers, con, "SELECT * FROM donators") 
end 
addEventHandler("onPlayerLogin", root, donaterLoggedIn) 
  
function getMyVIP(plr) 
    if (not isPlayerDonator(plr)) then return end 
    local hours = isPlayerDonator(plr) 
    local minutes = math.floor(hours / 60) 
     
    if (tonumber(hours) == 0) then 
        hours = "infinite" 
        minutes = "nil" 
    end 
  
    outputChatBox("You have "..hours.." VIP Hours ("..minutes.." minutes) remaining on this account ("..getAccountName(getPlayerAccount(plr))..")", plr, 0, 2500, 0) 
     
end 
addCommandHandler("VIP Hours", getMyVIP) 
  
function setCorrectVIPData() 
    for ind, plr in pairs(getElementsByType("player")) do 
        setElementData(plr, "VIP Hours", donate[getAccountName(getPlayerAccount(plr))]) 
    end 
end 
setTimer(setCorrectVIPData, 1000, 0) 

Link to comment
function Converteviptocash (thePlayer) 
    local acc = getPlayerAccount(thePlayer) 
    if isGuestAccount(acc) then return end 
    local accName = getAccountName(acc) 
    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tonumber(donate[accName])-1, accName) 
    givePlayerMoney ( thePlayer, 10000 ) 
end 
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

Link to comment

Put it inside your script. Like this:

local donate = {} 
local allTimeDonate = {} 
local con = dbConnect("sqlite", "db/donate.db") 
dbExec(con, "CREATE TABLE IF NOT EXISTS donators (account TEXT, time TEXT)") 
  
function loadUsers(query) 
    local data = dbPoll(query, 0) 
    if (data) then 
        for ind, d in ipairs(data) do 
            allTimeDonate[d.account] = d.time 
            if (d.account and getAccount(d.account) and getAccountPlayer(getAccount(d.account))) then 
                donate[d.account] = tonumber(d.time) 
            end 
        end 
    end 
end 
dbQuery(loadUsers, con, "SELECT * FROM donators") 
  
function isPlayerDonator(player) 
    local account = getAccountName(getPlayerAccount(player)) 
    return donate[account] 
end 
  
function addDonatorToDB(player, cmd, account, hours) 
    if (not (hasObjectPermissionTo(player, "function.banPlayer", false))) then return end 
    
    if (account and hours) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
        
        if (not tonumber(hours) or tonumber(hours) < 0) then 
            outputChatBox(tostring(hours).." is an invalid hour specific", player, 2500, 0, 0) 
            return 
        end 
        
        local plr = getAccountPlayer(getAccount(account)) 
        
        if (not allTimeDonate[getAccount(account)]) then 
            dbExec(con, "INSERT INTO donators (account, time) VALUES (?, ?)", tostring(account), tostring(hours)) 
            donate[account] = tonumber(hours) 
            if (tonumber(hours) == 0) then 
                hours = "infinite" 
            end 
            outputDebugString(getPlayerName(player).. " added "..hours.." VIP hours to "..account) 
            outputChatBox("Added "..hours.." VIP hours to "..account, player, 255, 150, 0) 
            if (plr) then 
                outputChatBox(getPlayerName(player).." added "..hours.." VIP hours to your account ("..account..")", plr, 0, 2500, 0) 
            end 
        end 
    end 
end 
addCommandHandler("addvip", addDonatorToDB) 
  
function removeOfflineVIP(player, cmd, account) 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    
    if (account) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
        
        if (donate[account]) then donate[account] = nil end 
        if (allTimeDonate[account]) then allTimeDonate[account] = nil end 
        dbExec(con, "DELETE FROM donators WHERE account=?", tostring(account)) 
        outputDebugString(getPlayerName(player).. " removed account "..account.." from database") 
    end 
end 
addCommandHandler("removevip", removeOfflineVIP) 
  
function makeDonateTick() 
    for ind, d in pairs(donate) do 
        if (ind and getAccount(ind)) then 
            if (getAccountPlayer(getAccount(ind))) then 
                if (donate[ind] and donate[ind] < 1 and donate[ind] ~= 0) then 
                    donate[ind] = nil 
                    allTimeDonate[ind] = nil 
                    dbExec(con, "DELETE FROM donators WHERE account=?", tostring(ind)) 
                    outputDebugString("Remove account "..ind.." from database because time ran out", root, 255, 255, 0) 
                elseif (donate[ind] and donate[ind] > 1 and donate[ind] ~= 0) then 
                    donate[ind] = donate[ind] - 1 
                    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[ind]), tostring(ind)) 
                    outputDebugString("Account "..ind.." VIP Time set to "..donate[ind].." Hours") 
                elseif (donate[ind]) then 
                    outputDebugString("Account "..ind.." has infinite VIP hours") 
                end 
            end 
        end 
    end 
end 
setTimer(makeDonateTick, 3600000 , 0) 
  
function getVipsTable(player) 
    --if (exports.CEDadmin:doesPlayerHaveAccess(player, "viewVipGUI")) then 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    triggerClientEvent(player, "donate.showDonateMembers", player, allTimeDonate) 
end 
addCommandHandler("showvip", getVipsTable) 
  
function donaterLoggedIn() 
    dbQuery(loadUsers, con, "SELECT * FROM donators") 
end 
addEventHandler("onPlayerLogin", root, donaterLoggedIn) 
  
function getMyVIP(plr) 
    if (not isPlayerDonator(plr)) then return end 
    local hours = isPlayerDonator(plr) 
    local minutes = math.floor(hours / 60) 
    
    if (tonumber(hours) == 0) then 
        hours = "infinite" 
        minutes = "nil" 
    end 
  
    outputChatBox("You have "..hours.." VIP Hours ("..minutes.." minutes) remaining on this account ("..getAccountName(getPlayerAccount(plr))..")", plr, 0, 2500, 0) 
    
end 
addCommandHandler("VIP Hours", getMyVIP) 
  
function setCorrectVIPData() 
    for ind, plr in pairs(getElementsByType("player")) do 
        setElementData(plr, "VIP Hours", donate[getAccountName(getPlayerAccount(plr))]) 
    end 
end 
setTimer(setCorrectVIPData, 1000, 0) 
  
function Converteviptocash (thePlayer) 
    local acc = getPlayerAccount(thePlayer) 
    if isGuestAccount(acc) then return end 
    local accName = getAccountName(acc) 
    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tonumber(donate[accName])-1, accName) 
    givePlayerMoney ( thePlayer, 10000 ) 
end 
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

Link to comment
local donate = {} 
local allTimeDonate = {} 
local con = dbConnect("sqlite", "db/donate.db") 
dbExec(con, "CREATE TABLE IF NOT EXISTS donators (account TEXT, time TEXT)") 
  
function loadUsers(query) 
    local data = dbPoll(query, 0) 
    if (data) then 
        for ind, d in ipairs(data) do 
            allTimeDonate[d.account] = d.time 
            if (d.account and getAccount(d.account) and getAccountPlayer(getAccount(d.account))) then 
                donate[d.account] = tonumber(d.time) 
            end 
        end 
    end 
end 
dbQuery(loadUsers, con, "SELECT * FROM donators") 
  
function isPlayerDonator(player) 
    local account = getAccountName(getPlayerAccount(player)) 
    return donate[account] 
end 
  
function addDonatorToDB(player, cmd, account, hours) 
    if (not (hasObjectPermissionTo(player, "function.banPlayer", false))) then return end 
    
    if (account and hours) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
        
        if (not tonumber(hours) or tonumber(hours) < 0) then 
            outputChatBox(tostring(hours).." is an invalid hour specific", player, 2500, 0, 0) 
            return 
        end 
        
        local plr = getAccountPlayer(getAccount(account)) 
        
        if (not allTimeDonate[getAccount(account)]) then 
            dbExec(con, "INSERT INTO donators (account, time) VALUES (?, ?)", tostring(account), tostring(hours)) 
            donate[account] = tonumber(hours) 
            if (tonumber(hours) == 0) then 
                hours = "infinite" 
            end 
            outputDebugString(getPlayerName(player).. " added "..hours.." VIP hours to "..account) 
            outputChatBox("Added "..hours.." VIP hours to "..account, player, 255, 150, 0) 
            if (plr) then 
                outputChatBox(getPlayerName(player).." added "..hours.." VIP hours to your account ("..account..")", plr, 0, 2500, 0) 
            end 
        end 
    end 
end 
addCommandHandler("addvip", addDonatorToDB) 
  
function removeOfflineVIP(player, cmd, account) 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    
    if (account) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
        
        if (donate[account]) then donate[account] = nil end 
        if (allTimeDonate[account]) then allTimeDonate[account] = nil end 
        dbExec(con, "DELETE FROM donators WHERE account=?", tostring(account)) 
        outputDebugString(getPlayerName(player).. " removed account "..account.." from database") 
    end 
end 
addCommandHandler("removevip", removeOfflineVIP) 
  
function makeDonateTick() 
    for ind, d in pairs(donate) do 
        if (ind and getAccount(ind)) then 
            if (getAccountPlayer(getAccount(ind))) then 
                if (donate[ind] and donate[ind] < 1 and donate[ind] ~= 0) then 
                    donate[ind] = nil 
                    allTimeDonate[ind] = nil 
                    dbExec(con, "DELETE FROM donators WHERE account=?", tostring(ind)) 
                    outputDebugString("Remove account "..ind.." from database because time ran out", root, 255, 255, 0) 
                elseif (donate[ind] and donate[ind] > 1 and donate[ind] ~= 0) then 
                    donate[ind] = donate[ind] - 1 
                    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[ind]), tostring(ind)) 
                    outputDebugString("Account "..ind.." VIP Time set to "..donate[ind].." Hours") 
                elseif (donate[ind]) then 
                    outputDebugString("Account "..ind.." has infinite VIP hours") 
                end 
            end 
        end 
    end 
end 
setTimer(makeDonateTick, 3600000 , 0) 
  
function getVipsTable(player) 
    --if (exports.CEDadmin:doesPlayerHaveAccess(player, "viewVipGUI")) then 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    triggerClientEvent(player, "donate.showDonateMembers", player, allTimeDonate) 
end 
addCommandHandler("showvip", getVipsTable) 
  
function donaterLoggedIn() 
    dbQuery(loadUsers, con, "SELECT * FROM donators") 
end 
addEventHandler("onPlayerLogin", root, donaterLoggedIn) 
  
function getMyVIP(plr) 
    if (not isPlayerDonator(plr)) then return end 
    local hours = isPlayerDonator(plr) 
    local minutes = math.floor(hours / 60) 
    
    if (tonumber(hours) == 0) then 
        hours = "infinite" 
        minutes = "nil" 
    end 
  
    outputChatBox("You have "..hours.." VIP Hours ("..minutes.." minutes) remaining on this account ("..getAccountName(getPlayerAccount(plr))..")", plr, 0, 2500, 0) 
    
end 
addCommandHandler("VIP Hours", getMyVIP) 
  
function setCorrectVIPData() 
    for ind, plr in pairs(getElementsByType("player")) do 
        setElementData(plr, "VIP Hours", donate[getAccountName(getPlayerAccount(plr))]) 
    end 
end 
setTimer(setCorrectVIPData, 1000, 0) 
  
function Converteviptocash (thePlayer) 
    local acc = getPlayerAccount(thePlayer) 
    if isGuestAccount(acc) then return end 
    local accName = getAccountName(acc) 
    donate[accName] = donate[accName] - 1 
    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[accName]), tostring(accName)) 
    givePlayerMoney ( thePlayer, 10000 ) 
end 
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

Link to comment

Client:

local sx, sy = guiGetScreenSize() 
  
function makeGUI() 
    vipGUI = guiCreateWindow((sx / 2) - (694 / 2), (sy / 2) - (526 / 2), 694, 526, "VIPs", false) 
    guiWindowSetSizable(vipGUI , false) 
    guiSetAlpha(vipGUI , 1.00) 
    guiSetVisible(vipGUI, false) 
    nameEdit = guiCreateEdit(9, 22, 152, 30, "", false, vipGUI) 
    list = guiCreateGridList(9, 61, 670, 408, false, vipGUI) 
    guiSetEnabled(nameEdit, false) 
    guiGridListAddColumn(list, "Account", 0.7) 
    guiGridListAddColumn(list, "Time", 0.1) 
    closeBttn = guiCreateButton(11, 483, 668, 33, "Close This Window", false, vipGUI) 
    
    addEventHandler("onClientGUIClick", closeBttn, function() guiSetVisible(vipGUI, false) showCursor(false) end, false) 
end 
addEventHandler("onClientResourceStart", resourceRoot, makeGUI) 
  
function showDonateMembers(d) 
    guiSetVisible(vipGUI, true) 
    showCursor(true) 
    guiGridListClear(list) 
    local online = 0 
    
    local online = 0 
    for ind, data in pairs(d) do 
        online = online + 1 
        local row = guiGridListAddRow(list) 
        local nTime = data - 1 
        if (nTime > 1) then 
            data = nTime 
        end 
        guiGridListSetItemText(list, row, 1, tostring(ind), false, false) 
        guiGridListSetItemText(list, row, 2, tostring(data), false, false) 
    end 
    
    guiSetText(nameEdit, "VIP Online: "..online) 
end 
addEvent("donate.showDonateMembers", true) 
addEventHandler("donate.showDonateMembers", root, showDonateMembers) 

Server:

local donate = {} 
local allTimeDonate = {} 
local con = dbConnect("sqlite", "db/donate.db") 
dbExec(con, "CREATE TABLE IF NOT EXISTS donators (account TEXT, time TEXT)") 
  
function loadUsers(query) 
    local data = dbPoll(query, 0) 
    if (data) then 
        for ind, d in ipairs(data) do 
            allTimeDonate[d.account] = d.time 
            if (d.account and getAccount(d.account) and getAccountPlayer(getAccount(d.account))) then 
                donate[d.account] = tonumber(d.time) 
            end 
        end 
    end 
end 
dbQuery(loadUsers, con, "SELECT * FROM donators") 
  
function isPlayerDonator(player) 
    local account = getAccountName(getPlayerAccount(player)) 
    return donate[account] 
end 
  
function addDonatorToDB(player, cmd, account, hours) 
    if (not (hasObjectPermissionTo(player, "function.banPlayer", false))) then return end 
    
    if (account and hours) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
        
        if (not tonumber(hours) or tonumber(hours) < 0) then 
            outputChatBox(tostring(hours).." is an invalid hour specific", player, 2500, 0, 0) 
            return 
        end 
        
        local plr = getAccountPlayer(getAccount(account)) 
        
        if (not allTimeDonate[getAccount(account)]) then 
            dbExec(con, "INSERT INTO donators (account, time) VALUES (?, ?)", tostring(account), tostring(hours)) 
            donate[account] = tonumber(hours) 
            if (tonumber(hours) == 0) then 
                hours = "infinite" 
            end 
            outputDebugString(getPlayerName(player).. " added "..hours.." VIP hours to "..account) 
            outputChatBox("Added "..hours.." VIP hours to "..account, player, 255, 150, 0) 
            if (plr) then 
                outputChatBox(getPlayerName(player).." added "..hours.." VIP hours to your account ("..account..")", plr, 0, 2500, 0) 
            end 
        end 
    end 
end 
addCommandHandler("addvip", addDonatorToDB) 
  
function removeOfflineVIP(player, cmd, account) 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    
    if (account) then 
        if (not getAccount(account)) then 
            outputChatBox("No account with "..account.." as username", player, 2500, 0, 0) 
            return 
        end 
        
        if (donate[account]) then donate[account] = nil end 
        if (allTimeDonate[account]) then allTimeDonate[account] = nil end 
        dbExec(con, "DELETE FROM donators WHERE account=?", tostring(account)) 
        outputDebugString(getPlayerName(player).. " removed account "..account.." from database") 
    end 
end 
addCommandHandler("removevip", removeOfflineVIP) 
  
function makeDonateTick() 
    for ind, d in pairs(donate) do 
        if (ind and getAccount(ind)) then 
            if (getAccountPlayer(getAccount(ind))) then 
                if (donate[ind] and donate[ind] < 1 and donate[ind] ~= 0) then 
                    donate[ind] = nil 
                    allTimeDonate[ind] = nil 
                    dbExec(con, "DELETE FROM donators WHERE account=?", tostring(ind)) 
                    outputDebugString("Remove account "..ind.." from database because time ran out", root, 255, 255, 0) 
                elseif (donate[ind] and donate[ind] > 1 and donate[ind] ~= 0) then 
                    donate[ind] = donate[ind] - 1 
                    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[ind]), tostring(ind)) 
                    outputDebugString("Account "..ind.." VIP Time set to "..donate[ind].." Hours") 
                elseif (donate[ind]) then 
                    outputDebugString("Account "..ind.." has infinite VIP hours") 
                end 
            end 
        end 
    end 
end 
setTimer(makeDonateTick, 3600000 , 0) 
  
function getVipsTable(player) 
    --if (exports.CEDadmin:doesPlayerHaveAccess(player, "viewVipGUI")) then 
    if (not (hasObjectPermissionTo(player, "function.kickPlayer", false))) then return end 
    triggerClientEvent(player, "donate.showDonateMembers", player, allTimeDonate) 
end 
addCommandHandler("showvip", getVipsTable) 
  
function donaterLoggedIn() 
    dbQuery(loadUsers, con, "SELECT * FROM donators") 
end 
addEventHandler("onPlayerLogin", root, donaterLoggedIn) 
  
function getMyVIP(plr) 
    if (not isPlayerDonator(plr)) then return end 
    local hours = isPlayerDonator(plr) 
    local minutes = math.floor(hours / 60) 
    
    if (tonumber(hours) == 0) then 
        hours = "infinite" 
        minutes = "nil" 
    end 
  
    outputChatBox("You have "..hours.." VIP Hours ("..minutes.." minutes) remaining on this account ("..getAccountName(getPlayerAccount(plr))..")", plr, 0, 2500, 0) 
    
end 
addCommandHandler("hrv", getMyVIP) 
  
function setCorrectVIPData() 
    for ind, plr in pairs(getElementsByType("player")) do 
        setElementData(plr, "VIP Hours", donate[getAccountName(getPlayerAccount(plr))]) 
    end 
end 
setTimer(setCorrectVIPData, 1000, 0) 
  
function Converteviptocash (thePlayer) 
    local acc = getPlayerAccount(thePlayer) 
    if isGuestAccount(acc) then return end 
    local accName = getAccountName(acc) 
    donate[accName] = donate[accName] - 1 
    dbExec(con, "UPDATE donators SET time=? WHERE account=?", tostring(donate[accName]), tostring(accName)) 
    givePlayerMoney ( thePlayer, 10000 ) 
end 
addCommandHandler ( "Converteviptocash", Converteviptocash ) 

I used:

/addvip gtx 10

/Converteviptocash

/hrv

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...