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

Lua Rookgaard System - OTServ_SVN 0.6.3

Nottinghster

Tibia World RPG Developer
Joined
Oct 24, 2007
Messages
1,570
Solutions
6
Reaction score
437
Location
Brazil - Rio de Janeiro
GitHub
Nottinghster
Hello guys !

I've made a code for the famous "Rook System", but I don't know why isn't working, maybe I did something or I'm fucking blind :p.

I'm using OTServ_SVN 0.6.3, can you guys help me with that ?

Check the code below:
Code:
function sendToRook(cid)
    if getPlayerLevel(cid) < 6 and getPlayerVocation(cid) ~= 0 then
        for i = 1, 10 do
            local slotItem = getPlayerSlotItem(cid, i)
            if slotItem.itemid > 0 then
                doRemoveItem(slotItem.uid)
            end
        end
        setPlayerStorageValue(cid, STORAGE_ROOK, 1)
        doPlayerSetVocation(cid, 0)
        doPlayerSetTown(cid, 11)
        db.executeQuery("UPDATE `players` SET `level` = '1', `experience` = '0', `health` = '150', `healthmax` = '150', `mana` = '0', `manamax` = '0', `maglevel` = '0', `manaspent` = '0',  `soul` = '100', `cap` = '400', `skull_type` = '0', `skull_time` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1;")
        db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. getPlayerGUID(cid) .. " LIMIT 7;")
        if(getPlayerSex(cid) == 0) then
            lookOutfit = 136
        else 
            lookOutfit = 128 
        end
        doCreatureChangeOutfit(cid, {lookType=lookOutfit, lookHead=78, lookBody=69, lookLegs=58, lookFeet=76})
        doTeleportThing(cid, {x = 32097, y = 32219, z = 7})
    end   
    return true
end
 
No, that's not the problem, it's defined in global.lua.
I don't know why, the code isn't being executed when player die ...
Then you should post your death script...

@Offtopic: If your player have a house and you get rook'd, do you lose your house? o_O
 
To be honest I don't see any error, but I never used OTServ before... Did you tried putting some prints to check if the function is being executed? And in which part is stopping.
Are you losing exp while dying at low level btw?
 
Keep in mind that queries such as these won't work unless the player is offline.
Code:
local function sendToRook(cid)
    if getPlayerLevel(cid) > 5 or getPlayerVocation(cid) == 0 then
        return false
    end

    for i = 1, 10 do
        local slotItem = getPlayerSlotItem(cid, i)
        if slotItem.itemid > 0 then
            doRemoveItem(slotItem.uid)
        end
    end

    setPlayerStorageValue(cid, STORAGE_ROOK, 1)

    local lookType = getPlayerSex(cid) == 0 and 136 or 128
    local playerGuid = getPlayerGUID(cid)

    doRemoveCreature(cid)

    db.executeQuery("UPDATE `players` SET `vocation` = '0', `town_id` = '11', `posx` = '32097', `posy` = '32219', `posz` = '7', `looktype` = " .. lookType .. ", `lookhead` = '78', `lookbody` = '69', `looklegs` = '58', `lookfeet` = '76', `level` = '1', `experience` = '0', `health` = '150', `healthmax` = '150', `mana` = '0', `manamax` = '0', `maglevel` = '0', `manaspent` = '0',  `soul` = '100', `cap` = '400', `skull_type` = '0', `skull_time` = '0' WHERE `id` = " .. playerGuid)
    db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. playerGuid .. " LIMIT 7;")
    return true
end

function onDie(cid, corpse)
    if isPlayer(cid) then
        sendToRook(cid)
    end
end
 
Keep in mind that queries such as these won't work unless the player is offline.
Code:
local function sendToRook(cid)
    if getPlayerLevel(cid) > 5 or getPlayerVocation(cid) == 0 then
        return false
    end

    for i = 1, 10 do
        local slotItem = getPlayerSlotItem(cid, i)
        if slotItem.itemid > 0 then
            doRemoveItem(slotItem.uid)
        end
    end

    setPlayerStorageValue(cid, STORAGE_ROOK, 1)

    local lookType = getPlayerSex(cid) == 0 and 136 or 128
    local playerGuid = getPlayerGUID(cid)

    doRemoveCreature(cid)

    db.executeQuery("UPDATE `players` SET `vocation` = '0', `town_id` = '1', `posx` = '32097', `posy` = '32219', `posz` = '7', `looktype` = " .. lookType .. ", `lookhead` = '78', `lookbody` = '69', `looklegs` = '58', `lookfeet` = '76', `level` = '1', `experience` = '0', `health` = '150', `healthmax` = '150', `mana` = '0', `manamax` = '0', `maglevel` = '0', `manaspent` = '0',  `soul` = '100', `cap` = '400', `skull_type` = '0', `skull_time` = '0' WHERE `id` = " .. playerGuid)
    db.executeQuery("UPDATE `player_skills` SET `value` = '10', `count` = '0' WHERE `player_id` = " .. playerGuid .. " LIMIT 7;")
    return true
end

function onDie(cid, corpse)
    if isPlayer(cid) then
        sendToRook(cid)
    end
end

Still not working ...
 
Back
Top