caquinha
Member
- Joined
- Aug 8, 2016
- Messages
- 248
- Solutions
- 1
- Reaction score
- 24
Anyone could help me to fix my try to convert this system 1.1 to 0.4?
System: https://otland.net/threads/znote-aac-tfs-1-1-referral-system.227199/#post-2405828
What i've tried:
Looking others scripts i made this chages:
But got this error, could you help me?
System: https://otland.net/threads/znote-aac-tfs-1-1-referral-system.227199/#post-2405828
What i've tried:
Looking others scripts i made this chages:
Code:
local cfg = {
stor = 250888,
requiredLevel = 13,
bonusPoints = 5
}
function onAdvance(cid, skill, oldLevel, newLevel)
if (newLevel == cfg.requiredLevel and skill == SKILL__LEVEL) and getPlayerStorageValue(cid, cfg.stor) < 1 then
local accountId = cid:getAccountId()
local resultId = db.storeQuery("SELECT `ref_key` FROM `__cornex_referral_actions` WHERE `registered_by` = " .. accountId .. " AND `blocked` = 0")
if resultId then
print(resultId)
local resultId2 = db.storeQuery("SELECT `belongs_to` FROM `__cornex_referral` WHERE `referral_key` = '" .. result.getDataString(resultId, "ref_key") .. "'")
print(resultId2)
if resultId2 then
db.executeQuery("UPDATE `__cornex_referral_actions` SET `blocked` = 1 WHERE `registered_by` = " .. accountId)
db.executeQuery("UPDATE `znote_accounts` SET `points` = (points + " .. cfg.bonusPoints .. ") WHERE `account_id` = '" .. result.getDataInt(resultId2, "belongs_to") .. "'")
print('-> account id: ' .. result.getDataInt(resultId2, "belongs_to"))
print('-> added ' .. cfg.bonusPoints .. ' points.')
result.free(resultId2)
else
print("Missing ref_key in `__cornex_referral` where ref_key = " .. result.getDataString(resultId, "ref_key"))
end
result.free(resultId)
end
end
return true
end
But got this error, could you help me?
Code:
[0:9:25.079] [Error - CreatureScript Interface]
[0:9:25.079] data/creaturescripts/scripts/referral.lua:onAdvance
[0:9:25.079] Description:
[0:9:25.079] data/creaturescripts/scripts/referral.lua:10: attempt to index local 'cid' (a number value)
[0:9:25.079] stack traceback:
[0:9:25.079] data/creaturescripts/scripts/referral.lua:10: in function <data/creaturescripts/scripts/referral.lua:8>