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

Tfs 1.3 Rebirth/prestige system

hangnail34

New Member
Joined
Jun 2, 2014
Messages
10
Reaction score
1
Hello i'm trying to get a prestige system to work, the code i took was for 0.3.6 but it's not working on 1.3 if anyone can help me i would greatly appreciate it!

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if(msgcontains(msg, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        -------CONFIGS-------
        local level = 500
        local cost = 10000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getPlayerStorageValue(cid, 85987)
        local Max_Rebirth = 5  --Change this for the number of rebirths

        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
        if getPlayerStorageValue(cid, 85987) < Max_Rebirth then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
                                db.executeQuery('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
                            doBroadcastMessage("" ..  name .. " has just prestiged!", TALKTYPE_ORANGE_1)
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] = 4200")
                    db.executeQuery("UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = '"..name.."' WHERE [ICODE]id[/ICODE] ='"..id.."';")
                else
                    selfSay('Please talk with Forgotten King and promote first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 10 mil to be rebirthed.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('You have reached the maximum rebirth.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('Only characters of level 500 or higher can be rebirthed.', cid)
        talkState[talkUser] = 0
    end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        talkState[talkUser] = 0
end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

LUA:
Lua Script Error: [Npc interface]
data/npc/scripts/rebirth.lua:onCreatureSay
data/npc/scripts/rebirth.lua:38: attempt to call global 'doPlayerSetStorageValue' (a nil value)
stack traceback:
        [C]: in function 'doPlayerSetStorageValue'
        data/npc/scripts/rebirth.lua:38: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:401: in function 'onCreatureSay'
        data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>
 
Solution
Code:
 [Error - mysql_real_query] Query: UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] = 4200
Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] =' at line 1
[Error - mysql_real_query] Query: UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = 'Test' WHERE [ICODE]id[/ICODE] ='2';
Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = 'Test' WHERE [ICODE]id[/ICODE] ' at line 1
u need fix it:

Code:
 db.query("UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8...
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if(msgcontains(msg, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        -------CONFIGS-------
        local level = 500
        local cost = 10000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getPlayerStorageValue(cid, 85987)
        local Max_Rebirth = 5  --Change this for the number of rebirths

        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
        if getPlayerStorageValue(cid, 85987) < Max_Rebirth then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    local player = Player(cid)
                    player:setStorageValue(85987, storage == -1 and 1 or storage + 1)
                                db.query('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
                            Game.broadcastMessage("" ..  name .. " has just prestiged!", MESSAGE_STATUS_WARNING)
                    doRemoveCreature(cid)
                    db.query("UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] = 4200")
                    db.query("UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = '"..name.."' WHERE [ICODE]id[/ICODE] ='"..id.."';")
                else
                    selfSay('Please talk with Forgotten King and promote first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 10 mil to be rebirthed.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('You have reached the maximum rebirth.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('Only characters of level 500 or higher can be rebirthed.', cid)
        talkState[talkUser] = 0
    end
elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        talkState[talkUser] = 0
end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Hello i'm trying to get a prestige system to work, the code i took was for 0.3.6 but it's not working on 1.3 if anyone can help me i would greatly appreciate it!
 
Last edited:
Well i got this now

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/rebirth.lua:onCreatureSay
data/npc/scripts/rebirth.lua:40: attempt to call field 'executeQuery' (a nil value)
stack traceback:
        [C]: in function 'executeQuery'
        data/npc/scripts/rebirth.lua:40: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:401: in function 'onCreatureSay'
        data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>
 
Well i got this now

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/rebirth.lua:onCreatureSay
data/npc/scripts/rebirth.lua:40: attempt to call field 'executeQuery' (a nil value)
stack traceback:
        [C]: in function 'executeQuery'
        data/npc/scripts/rebirth.lua:40: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:401: in function 'onCreatureSay'
        data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>
edited script, copy and try again
 
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/rebirth.lua:onCreatureSay
data/npc/scripts/rebirth.lua:41: attempt to call global 'doBroadcastMessage' (a nil value)
stack traceback:
        [C]: in function 'doBroadcastMessage'
        data/npc/scripts/rebirth.lua:41: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:401: in function 'onCreatureSay'
        data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>
 
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/rebirth.lua:onCreatureSay
data/npc/scripts/rebirth.lua:41: attempt to call global 'doBroadcastMessage' (a nil value)
stack traceback:
        [C]: in function 'doBroadcastMessage'
        data/npc/scripts/rebirth.lua:41: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:401: in function 'onCreatureSay'
        data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>
edited again...
 
Code:
 [Error - mysql_real_query] Query: UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] = 4200
Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] =' at line 1
[Error - mysql_real_query] Query: UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = 'Test' WHERE [ICODE]id[/ICODE] ='2';
Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = 'Test' WHERE [ICODE]id[/ICODE] ' at line 1
 
Code:
 [Error - mysql_real_query] Query: UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] = 4200
Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] =' at line 1
[Error - mysql_real_query] Query: UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = 'Test' WHERE [ICODE]id[/ICODE] ='2';
Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = 'Test' WHERE [ICODE]id[/ICODE] ' at line 1
u need fix it:

Code:
 db.query("UPDATE [ICODE]players[/ICODE] SET [ICODE]level[/ICODE] = 8, [ICODE]experience[/ICODE] = 4200")
db.query("UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = '"..name.."' WHERE [ICODE]id[/ICODE] ='"..id.."';")
remove [ CODE ] ...

Now I won't fix any more mistakes. you neither do the job of understanding what the error says.
any error that comes up is because you have to go to 1.3. the script is done in 0.4
 
Solution
Back
Top