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

Rebirth Mysql Request

GoalTV

NANI?!
Joined
Jul 23, 2011
Messages
589
Reaction score
53
Hello Otland!

Today I have small request it was long time ago when I made my rebirth mysql and I left tibia for few months now I'm back and I need two this to be done I try my self but end up with errors.

This is my Rebirth Script
http://otland.net/threads/best-rebirth-system-mysql-by-god-batonik-with-gensior-script.186274/

first I want change my !rebirth talkaction script to mysql for my system

here my scritp

Code:
local level = 717171 -- the min level
function onSay(cid, words, param, channel)
    if(getPlayerLevel(cid) >= level) then
        local guid = getPlayerGUID(cid)
        doCreatureSetStorage(cid, 85987, getCreatureStorage(cid, 85987) == -1 and 1 or getCreatureStorage(cid, 85987) + 1)
        doRemoveCreature(cid)
        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 2000, `manamax` = 2000, `promotion` = 0 WHERE `id` = " .. guid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need level " .. level .. ".")
    end
    return true
end


second I get new rebirth on look but I want change to mysql too

Code:
 function onLogin(cid)
    registerCreatureEvent(cid, "newlook")
    return true
end
local config = {
storage = 85987 -- storage takie jak w skrypcie wyzej ;p
}
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid,'\n[Reborn: '..getPlayerStorageValue(thing.uid,config.storage)  ..']')
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid,'\n[Reborn: '..getPlayerStorageValue(cid,config.storage)..']')
        local string = 'You see yourself.'
        if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
            string = string..' You are '.. getPlayerGroupName(cid) ..'.'
        elseif getPlayerVocation(cid) ~= 0 then
            string = string..' You are '.. getPlayerVocationName(cid) ..'.'
        else
            string = string..' You have no vocation.'
        end
        string = string..getPlayerSpecialDescription(cid)..'\n'
        if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
            string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
        end
        if getPlayerGuildId(cid) > 0 then
            string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
            string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
        end
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
            string = string..'\nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
            string = string..'\nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
        end
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
            string = string..'\nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string) 
        return false
    end
    return true
end


Best Regards
mlody.1039
 
This might work:
Code:
local level = 717171 -- the min level
function onSay(cid, words, param, channel)
    if(getPlayerLevel(cid) >= level) then
        local guid = getPlayerGUID(cid)
        doRemoveCreature(cid)
        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 2000, `manamax` = 2000, `promotion` = 0 WHERE `id` = " .. guid)
        db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` + " .. rebs .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need level " .. level .. ".")
    end
    return true
end

And:
Code:
 function onLogin(cid)
    registerCreatureEvent(cid, "newlook")
    return true
end
local config = {
storage = 85987 -- storage takie jak w skrypcie wyzej ;p
}
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid,'\n[Reborn: '..getPlayerStorageValue(thing.uid,config.storage)  ..']')
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid,'\n[Reborn: '..getPlayerRebirth(cid)..']')
        local string = 'You see yourself.'
        if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
            string = string..' You are '.. getPlayerGroupName(cid) ..'.'
        elseif getPlayerVocation(cid) ~= 0 then
            string = string..' You are '.. getPlayerVocationName(cid) ..'.'
        else
            string = string..' You have no vocation.'
        end
        string = string..getPlayerSpecialDescription(cid)..'\n'
        if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
            string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
        end
        if getPlayerGuildId(cid) > 0 then
            string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
            string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
        end
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
            string = string..'\nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
            string = string..'\nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
        end
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
            string = string..'\nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
        return false
    end
    return true
end

If any of them dont work plz post the error, it makes it easier to solve
 
I have this error on talkactions

Code:
[Error - TalkAction Interface]
data/talkactions/scripts/rebirth.lua:onSay
Description:
(internalGetPlayerInfo) Player not found when requesting player info #18

[Error - TalkAction Interface]
data/talkactions/scripts/rebirth.lua:onSay
Description:
data/talkactions/scripts/rebirth.lua:7: attempt to concatenate a boolean value
stack traceback:
        data/talkactions/scripts/rebirth.lua:7: in function <data/talkactions/scripts/rebirth.lua:2>


onlook I will do it myself on !rebirths is most important for me atm


Best Regards
mlody.1039
 
Last edited:
This one?
Code:
local level = 717171 -- the min level
function onSay(cid, words, param, channel)
    if(getPlayerLevel(cid) >= level) then
        local guid = getPlayerGUID(cid)
        doRemoveCreature(cid)
        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 2000, `manamax` = 2000, `promotion` = 0 WHERE `id` = " .. guid)
        db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` +  1 `WHERE `id` = " .. guid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need level " .. level .. ".")
    end
    return true
end

And do you want it to set the hp and mana to 2k after rebirth?
 
Hello.
now this error
Code:
mysql_real_query(): UPDATE `players` SET `rebirths` = `rebirths` +  1 `WHERE `id` = 2 - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`WHERE `id` = 2' at line 1 (1064)

it should work i think as in libs is did
db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` - " .. rebs .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";"
 
Code:
local level = 717171 -- the min level
function onSay(cid, words, param, channel)
    if(getPlayerLevel(cid) >= level) then
        local guid = getPlayerGUID(cid)
        doRemoveCreature(cid)
        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 2000, `manamax` = 2000, `promotion` = 0 WHERE `id` = " .. guid)
        db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` - "1" WHERE `id` = " .. getPlayerGUID(cid) .. ";"
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need level " .. level .. ".")
    end
    return true
end

this shuld work if you are right
 
Hmm Still same maybe I will go to support thread with this

Code:
[Error - LuaScriptInterface::loadFile] data/talkactions/scripts/rebirth.lua:7: ')' expected near '1'
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/rebirth.lua)
data/talkactions/scripts/rebirth.lua:7: ')' expected near '1
 
Code:
local level = 717171 -- the min level
function onSay(cid, words, param, channel)
    if getPlayerLevel(cid) >= level then
        local guid = getPlayerGUID(cid)
        doRemoveCreature(cid)
        db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` + 1, `level` = 8, `experience` = 4200, `health` = 2000, `healthmax` = 2000, `mana` = 2000, `manamax` = 2000, `promotion` = 0 WHERE `id` = " .. guid)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need level " .. level .. ".")
    end
    return true
end
 
Back
Top