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

Help to finish: Convert Znote Referral 1.1 to 0.4

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:

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>
 
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:

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>
Change:
Code:
        local accountId = cid:getAccountId()
To:
Code:
        local accountId = getPlayerAccountId(cid)
 
Hmm, maybe "local accountId = getPlayerAccountId(cid)"

Edit: Got damnit @MatheusMkalo - I was already responding! I just wanted to browse luascript.cpp first to make sure it was right and by the time I post you have already posted.

How dare you!
 
All depends on what VIP system you are using, unless you literally just want premium days.

Im pretty sure the VIP systems have like addVIPDays(cid, 7) or something like that. Use the search function to find related posted with addpremiumdays or addvipdays and im sure youll find something you can copy/paste and modify.
 
All depends on what VIP system you are using, unless you literally just want premium days.

Im pretty sure the VIP systems have like addVIPDays(cid, 7) or something like that. Use the search function to find related posted with addpremiumdays or addvipdays and im sure youll find something you can copy/paste and modify.

it's not too simple, it need to check if player is online
if player is online:
doPlayerAddPremiumDays(cid, 7)

But if player is offline need to add on mysql command

Anyways idk how to do it
 
@gmstrikker - yeah you're right, mysql would be best for if they sign offline; but since its onAdvance they shouldnt be offline when adding the premium days so that function should work fine :) thanks for clarifying!
 
@Extrodus
I think you don't understand what this system do...
Let me explain...

An exemple:
You give me your reffer KEY, i register in the server using your reffer KEY
When i get lvl 10 you, who invite me to play on the server and give me your reffer key, recive 7 premium days

That is a idea to old players invite new players and recive premium days...

---
About topic
I would never, ever, use to add donate points, if you do it, you will lose some donates and maybe make your project a fail
Premium days sounds so better (if you use premium like vip system)
 
Ah, I get it; so the player you referred is leveling and the person getting the premium days could be online/offline since they are your referral. So yeah, db query would be the way to go.
 
Back
Top