• 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 for TFS 1.1

reebo

New Member
Joined
Nov 22, 2014
Messages
28
Reaction score
1
Hi there, I've new problem and need help with solution.
I'm trying to use Kekox VIP system, I've little edited it, but now I've problem with this.

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/global.lua:62: attempt to call global 'getPlayerAccountId' (a nil value)
stack traceback:
        [C]: in function 'getPlayerAccountId'
        data/global.lua:62: in function 'getPlayerVipDays'
        data/creaturescripts/scripts/others/VipCheck.lua:2: in function <data/cr          eaturescripts/scripts/others/VipCheck.lua:1>

can't find getPlayerAccountId in compat.lua and still I'm really newbee to scripting, any ideas?
 
Still I've problem on logon.
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/global.lua:4: attempt to call global 'getPlayerAccountId' (a nil value)
stack traceback:
        [C]: in function 'getPlayerAccountId'
        data/global.lua:4: in function 'getPlayerVipDays'
        data/creaturescripts/scripts/others/VipCheck.lua:2: in function <data/creaturescripts/scr

I add getPlayerAccountId into compat.lua as it was in that topic you send me to

My global looks like this:
Code:
function getPlayerVipDays(cid)
local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local days= Info:getDataInt("vipdays")
Info:free()
return days
end
return LUA_ERROR
end

function doAddVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doRemoveVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
Change db.getResult to db.storeQuery, Info:getID() ~= LUA_ERROR to Info, local days= Info:getDataInt("vipdays") to local days = result.getDataInt(Info, "vipdays") and Info:free() to result.free(Info).

Also change db.executeQuery to db.query.
You can also use
Code:
Player(cid):getAccountId()
Instead of getPlayerAccountId(cid)
 
Last edited:
Updated expect the Info line, I didn't get what you mean by it. But got another error. and I can't really notice whats wrong on that line
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/global.lua:42: attempt to index local 'Info' (a number value)
stack traceback:
        [C]: in function '__index'
        data/global.lua:42: in function 'getPlayerVipDays'
        data/creaturescripts/scripts/others/VipCheck.lua:2: in function <data/creaturescripts/scripts/others/VipCheck.lua:1


This is how it looks at this moment.
Code:
function getPlayerVipDays(cid)
local Info = db.storeQuery("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. Player(cid):getAccountId() .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local days = result.getDataString(Info, "vipdays")
result.free(Info)
return days
end
return LUA_ERROR
end
 
Ou I tried, new issue appeared!

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/creaturescripts/scripts/others/VipCheck.lua:2: attempt to compare number with string
stack traceback:
        [C]: in function '__le'
        data/creaturescripts/scripts/others/VipCheck.lua:2: in function <data/creaturescripts/scripts/others/VipCheck.lua:1>

This is my global now

Code:
function getPlayerVipDays(cid)
local Info = db.storeQuery("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. Player(cid):getAccountId() .. " LIMIT 1")
if Info then
local days = result.getDataString(Info, "vipdays")
result.free(Info)
return days
end
return LUA_ERROR
end

And this is my script for Vipcheck, what's wrong with the string there

Code:
function onLogin(cid)
if getPlayerVipDays(cid) >= 1 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have ".. getPlayerVipDays(cid) .." vip days left.")
end
return true
end
 
Now I could've loged in, but after I used medal, it should add VIP (or its teddy bear in my version, but thats what I can fix). After I can't login on that account. index global 'player'... Do you have idea what happened?
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/creaturescripts/scripts/others/VipCheck.lua:3: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/others/VipCheck.lua:3: in function <data/creaturescripts/scripts/others/VipCheck.lua:1>

and this is what it wrote after I used medal. I've to change doCreatureSay or maybe I didnt had to add that ORANGE text.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/vipmedal.lua:onUse
data/actions/scripts/other/vipmedal.lua:6: attempt to call global 'doCreatureSay' (a nil value)
stack traceback:
        [C]: in function 'doCreatureSay'
        data/actions/scripts/other/vipmedal.lua:6: in function <data/actions/scripts/other/vipmedal.lua:1>

Here's medal code
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerVipDays(cid) > 365 then
player:sendCancelMessage("You can have only vip of 1 year or less.", TALKTYPE_MONSTER_SAY)
else
doAddVipDays(cid, 30)
doCreatureSay(cid, "VIP",TALKTYPE_ORANGE_1)
doPlayerPopupFYI(cid, "We have added 30 vip days to your account!\nEnjoy it!.")
doRemoveItem(item.uid)
end
return true
end
 
That's what I've in my compat.lua... By the way, priority error is the first one with the indexing global players, I can't fix it anyhow :/
 
Code:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
Then for the doCreatureSay
Code:
player:say("VIP", TALKTYPE_MONSTER_SAY)

You can use the compat.lua as example to change TFS 0.2 functions to TFS 1.0 functions.
 
But I've it in my compat.lua included this already... Ill try out this, thanks... but still, do you have idea what to do with the first issue?
Code:
Now I could've loged in, but after I used medal, it should add VIP (or its teddy bear in my version, but thats what I can fix). After I can't login on that account. index global 'player'... Do you have idea what happened?
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/creaturescripts/scripts/others/VipCheck.lua:3: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/others/VipCheck.lua:3: in function <data/creaturescripts/scripts/others/VipCheck.lua:1>
 
It pops orange VIP, no debug now. But still cant login trough vipcheck

Code:
function onUse(player, item, fromPosition, itemEx, toPosition)
if getPlayerVipDays(player) > 365 then
doPlayerSendCancel(player, "You can only have 1 year of vip account or less.")
else
doAddVipDays(player, 30)
player:say("VIP", TALKTYPE_MONSTER_SAY)
doPlayerPopupFYI(player, "We have added 30 vip days to your account!\nEnjoy it!.")
doRemoveItem(item.uid)
end
return true
end

but problem is in VipCheck aswell, after I use medal (nothing happen, like it doesnt dissapear but it add 30 days of VIP to my sql database), but after if you want to relog, it cant... and this appear
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/VipCheck.lua:onLogin
data/global.lua:41: attempt to concatenate a nil value
stack traceback:
        [C]: in function '__concat'
        data/global.lua:41: in function 'getPlayerVipDays'
        data/creaturescripts/scripts/others/VipCheck.lua:2: in function <data/creaturescripts/scripts/others/VipCheck.lua:1>

here's vipcheck.lua code
Code:
function onLogin(player)
if getPlayerVipDays(player) >= 1 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have ".. getPlayerVipDays(player) .." vip days left.")
end
return true
end


this is in global

Code:
function getPlayerVipDays(player)
local Info = db.storeQuery("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. Player:getAccountId() .. " LIMIT 1")
if Info then
local days = result.getDataInt(Info, "vipdays")
result.free(Info)
return days
end
return LUA_ERROR
end
 
Last edited:
oo.. seems its working now, only remove item is not working...
doRemoveItem is problem only now, I've doRemoveItem in compat.lua

Code:
function onUse(player, item, fromPosition, itemEx, toPosition)
if getPlayerVipDays(player) > 365 then
player:sendCancelMessage(text)("You can only have 1 year of vip account or less.")
else
doAddVipDays(player, 30)
player:say("VIP", TALKTYPE_MONSTER_SAY)
player:popupFYI("We have added 30 vip days to your account!\nEnjoy it!.")
doRemoveItem(item.uid)
end
return true
end
 
Back
Top