• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help with a automatic script for give VIP when player get level 120

jonathan.dsa

New Member
Joined
Nov 17, 2011
Messages
61
Reaction score
0
Hello dears ^^
I have made a script for give one day of VIP for players level 120 more, and only for one char of account (i use vip system of mock), but when a player get level 120,did show the message, but player dont get VIP, here is my script:

local config = {
level = 120, -- Level que o player vai ser promovido. -- Storage Value que vai ser usado.
msg = "Parabéns, você recebeu 1 dia de vip!", -- Mensagem enviada quando atingir o level necessário.
msgtype = MESSAGE_EVENT_ADVANCE -- Tipo da mensagem enviada.
}
--[Fim das Configurações]--

function onAdvance(cid, oldLevel, newLevel)
if getPlayerLevel(cid) >= config.level and getGlobalStorageValue(getPlayerAccountId(cid)+326) <= 0 then
setGlobalStorageValue(getPlayerAccountId(cid)+326, 1)
vip.setVipByAccount(getPlayerAccountId(cid),1)
doPlayerSendTextMessage(cid, config.msgtype, config.msg)

end

return TRUE
end

Somebody can help me with that please?
 
LUA:
local config = {
level = 120,
storage = 3334,
msg = "Parabéns, você recebeu 1 dia de vip!",
msgtype = MESSAGE_EVENT_ADVANCE
}

function onAdvance(cid, oldLevel, newLevel)
if getPlayerLevel(cid) >= config.level and getGlobalStorageValue(getPlayerAccountId(cid)+326) <= 0 then
setGlobalStorageValue(getPlayerAccountId(cid)+326, 1)
vip.setVipByAccount(getPlayerAccountId(cid),1)
doPlayerSendTextMessage(cid, config.msgtype, config.msg)

end

return TRUE
end

Try That
 
Thanks man, but this did not work, i think the problem is here:
vip.setVipByAccount(getPlayerAccountId(cid),1)
And is there, in 1, i put here in days, or in minuts?
 
LUA:
local config = {
level = 120,
storageId = 15558,
msg = "Parabéns, você recebeu 1 dia de vip!",
msgtype = MESSAGE_EVENT_ADVANCE
}
 
function onAdvance(cid, oldLevel, newLevel)
if getPlayerLevel(cid) >= config.level and getGlobalStorageValue(cid, config.storageId) == -1) then
setGlobalStorageValue(cid, config.storageId, 1)
vip.setVipByAccount(getPlayerAccountId(cid), +1)
doPlayerSendTextMessage(cid, config.msgtype, config.msg)
 
end
 
return TRUE
end

Here try this.
 
I'm not even trying, because I don't even know if those functions exists, but last post of "protegy" have missing '(' in the IF statement, just telling
 
LUA:
local config = {
level = 120,
storageId = 15558,
msg = "Parabéns, você recebeu 1 dia de vip!",
msgtype = MESSAGE_EVENT_ADVANCE
}
 
function onAdvance(cid, oldLevel, newLevel)
if (getPlayerLevel(cid) >= config.level and getGlobalStorageValue(cid, config.storageId) == -1) then
setGlobalStorageValue(cid, config.storageId, 1)
vip.setVipByAccount(getPlayerAccountId(cid), +1)
doPlayerSendTextMessage(cid, config.msgtype, config.msg)
 
end
 
return TRUE
end

With the missing part off him nclx.
 
Look that is the lib:

vip = {
name = "Vip system";
author = "Mock";
version = "1.0.0.0";
query="ALTER TABLE `accounts` ADD `vip_time` INTEGER";
query2="ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL"
}

function vip.setTable()
dofile('config.lua')
if sqlType == "sqlite" then
db.executeQuery(vip.query)
else
db.executeQuery(vip.query2)
end
end

function vip.getVip(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then error('Player don\'t find') end;
ae = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';")
if ae:getID() == -1 then
return 0
end

local retee = ae:getDataInt("vip_time") or 0
ae:free()
return retee
end

function vip.getVipByAcc(acc)
assert(acc,'Account is nil')
local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';")
if a:getID() ~= -1 then
return a:getDataInt("vip_time") or 0, a:free()
else
error('Account don\'t find.')
end
end

function vip.setVip(cid,time)
dofile("config.lua")
assert(tonumber(cid),'Parameter must be a number')
assert(tonumber(time),'Parameter must be a number')
if isPlayer(cid) == FALSE then error('Player don\'t find') end;
db.executeQuery("UPDATE `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';")
end

function vip.getVipByAccount(acc)
assert(acc,'Account is nil')
return db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';"):getDataInt("vip_time") or 0
end

function vip.hasVip(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then return end;
local t = vip.getVip(cid) or 0
if os.time(day) < t then
return TRUE
else
return FALSE
end
end

function vip.hasVips(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then return end;
local t = vip.getVip(cid)
if os.time(day) < t then
return TRUE
else
return FALSE
end
end

function vip.accountHasVip(acc)
assert(acc,'Account is nil')
if os.time() < vip.getVipByAccount(acc) then
return TRUE
else
return FALSE
end
end
function vip.getDays(days)
return (3600 * 24 * days)
end

function vip.addVipByAccount(acc,time)
assert(acc,'Account is nil')
assert(tonumber(time),'Parameter must be a number')
local a = vip.getVipByAcc(acc)
a = os.difftime(a,os.time())
if a < 0 then a = 0 end;
a = a+time
return vip.setVipByAccount(acc,a)
end

function vip.setVipByAccount(acc,time)
dofile("config.lua")
assert(acc,'Account is nil')
assert(tonumber(time),'Parameter must be a number')
db.executeQuery("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")
return TRUE
end

function vip.returnVipString(cid) <!-- i have tried it -->
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == TRUE then
return os.date("%d %B %Y %X ", vip.getVip(cid))
end
end
 
LUA:
local config = {
level = 120,
storageId = 15558,
msg = "Parabéns, você recebeu 1 dia de vip!",
msgtype = MESSAGE_EVENT_ADVANCE
}
 
function onAdvance(cid, oldLevel, newLevel)
if (getPlayerLevel(cid) >= config.level and getGlobalStorageValue(cid, config.storageId) == -1) then
setGlobalStorageValue(cid, config.storageId, 1)
vip.setVipByAccount(getPlayerAccountId(cid), +1)
doPlayerSendTextMessage(cid, config.msgtype, config.msg)
 
end
 
return TRUE
end

With the missing part off him nclx.

thanks but, i put this function of storage by account, for a player dont create various chars to get lv 120 and renove vip
 
With + before 1, i get this error in console [Error - LuaInterface::loadFile] data/creaturescript/scripts/freevip.lua:11: unexpected symbol near '+' :/
 
Hello, i managed to get, and the code is:

local config = {
level = 120,
days = 1,
storageId = 15558,
msg = "Parabéns, por alcançar o level 120, você recebeu 1 dia de vip!",
msgtype = MESSAGE_EVENT_ADVANCE
}

function onAdvance(cid, oldLevel, newLevel)
if (getPlayerLevel(cid) >= config.level and getGlobalStorageValue(getPlayerAccountId(cid)+450) <= 0) then
setGlobalStorageValue(getPlayerAccountId(cid)+450, 1)
vip.addVipByAccount(getPlayerAccount(cid) ,vip.getDays(config.days))
doPlayerSendTextMessage(cid, config.msgtype, config.msg)

end

return TRUE
end

problem solved, thanks for all
 
Back
Top