• 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 -=[TFS]=- 0.4 8.60 how can i fix this script

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
Lua:
function onSay(cid, words, param)
    if words == "!desbug" then
        local cap = getPlayerCap(cid) -- Supondo que essa função obtenha o valor atual da cap do jogador
        if cap == 72442500 then
            -- Defina o valor da cap diretamente para 9000000
            setPlayerCap(cid, 9000000)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sua cap foi desbugada!")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sua cap não atende aos requisitos para desbugar.")
        end
    end
end

-- Função para definir o valor da cap do jogador
function setPlayerCap(cid, value)
    -- Defina o valor da cap do jogador usando uma função apropriada do TFS
    -- Por exemplo: player:setCap(value)
end

Lua:
[19/08/2023 09:32:31] sqlite3_step(): SQLITE ERROR: UPDATE on table "player_skills" violates foreign: "player_id"
[19/08/2023 09:32:31] sqlite3_step(): SQLITE ERROR: cannot rollback - no transaction is active
[19/08/2023 09:32:31] sqlite3_step(): SQLITE ERROR: UPDATE on table "player_skills" violates foreign: "player_id"
[19/08/2023 09:32:31] sqlite3_step(): SQLITE ERROR: cannot rollback - no transaction is active

[19/08/2023 09:32:36] [Error - TalkAction Interface]
[19/08/2023 09:32:36] data/talkactions/scripts/desbug.lua:onSay
[19/08/2023 09:32:36] Description:
[19/08/2023 09:32:36] data/talkactions/scripts/desbug.lua:3: attempt to call global 'getPlayerCap' (a nil value)
[19/08/2023 09:32:36] stack traceback:
[19/08/2023 09:32:36]     data/talkactions/scripts/desbug.lua:3: in function <data/talkactions/scripts/desbug.lua:1>
[19/08/2023 09:32:56] > Broadcasted message: "O jogador "[VIP] Amped" tornou-se o novo Top Level. Parabens!".
[19/08/2023 09:33:01] sqlite3_step(): SQLITE ERROR: UPDATE on table "player_skills" violates foreign: "player_id"
[19/08/2023 09:33:01] sqlite3_step(): SQLITE ERROR: cannot rollback - no transaction is active
 
Solution
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerFreeCap(cid) > 7245000 then
        doPlayerSetMaxCapacity(cid, 90000)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sua capacidade foi ajustada.")
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sua capacidade está normal.")
    end

    return true
end

function!!!!!!!!!!!!
there is no function on tfs 0.4 that returns that current capacity a player have... so you will either have to use a query to return that value (remember that player must logout in order to update the value), or duplicate this:


and change getFreeCapacity to geCapacity
 
There's no such function in TFS 0.4 as getPlayerCap, there's also no setPlayerCap (use doPlayerSetMaxCapacity instead).
You could try to extend it:
C++:
enum PlayerInfo_t n {
    ...
    PlayerInfoCap
}

//getPlayerCap(cid)
lua_register(m_luaState, "getPlayerCap", LuaInterface::luaGetPlayerCap);

int32_t LuaInterface::luaGetPlayerCap(lua_State* L)
{
    return internalGetPlayerInfo(L, PlayerInfoCap);
}

int32_t LuaInterface::internalGetPlayerInfo(lua_State* L, PlayerInfo_t info)
{
    ...
    switch (info) {
        ...
        case PlayerInfoCap:
            value = (int64_t)player->getCapacity();
            break;
    }
    ...
}
 
Last edited:
Lua:
function onSay(cid, words, param)
    if param == "!desbugar" then
        local currentCapacity = getPlayerFreeCap(cid) -- Obtém a capacidade atual do jogador
        
        if currentCapacity > 7245000 then
            doPlayerSetMaxCapacity(cid, 90000) -- Define a capacidade para 90000 se for maior que 7245000
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sua capacidade foi ajustada.") -- Envia uma mensagem informativa
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sua capacidade está normal.") -- Envia uma mensagem informando que a capacidade está dentro do limite
        end
        
        return true
    end
    
    return false
end
 
Lua:
function onSay(cid, words, param)
    if words == "!desbug" then
        local fixCap = 900000 -- O valor para a capacidade corrigida (ajuste conforme necessário)

      
        db.executeQuery("UPDATE `players` SET `cap` = '" .. fixCap .. "' WHERE `id` = " .. getPlayerGUID(cid))

        doPlayerSetCapacity(cid, fixCap)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Bug corrigido! Sua capacidade foi restaurada.")
    end
   
    return true
end
 
Lua:
[19/08/2023 19:13:07] [Error - TalkAction Interface]
[19/08/2023 19:13:08] data/talkactions/scripts/desbug.lua:onSay
[19/08/2023 19:13:08] Description:
[19/08/2023 19:13:08] data/talkactions/scripts/desbug.lua:8: attempt to call global 'doPlayerSetCapacity' (a nil value)
[19/08/2023 19:13:08] stack traceback:
[19/08/2023 19:13:09]     data/talkactions/scripts/desbug.lua:8: in function <data/talkactions/scripts/desbug.lua:1>
 
Isn't better to simply disable the cap system? Seems like you dont have a real use for it anyway

Replace with: d976188p

Replace with: fvwobw7d

Replace with: fjdyt3i2
 
Isn't better to simply disable the cap system? Seems like you dont have a real use for it anyway

Replace with: d976188p

Replace with: fvwobw7d

Replace with: fjdyt3i2
Since he already said that he has no knowledge of editing the source.
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerFreeCap(cid) > 7245000 then
        doPlayerSetMaxCapacity(cid, 90000)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sua capacidade foi ajustada.")
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sua capacidade está normal.")
    end

    return true
end

function!!!!!!!!!!!!
 
Solution
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerFreeCap(cid) > 7245000 then
        doPlayerSetMaxCapacity(cid, 90000)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sua capacidade foi ajustada.")
        doRemoveItem(item.uid, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Sua capacidade está normal.")
    end

    return true
end

function!!!!!!!!!!!!
This is the script I sent him privately.
 

Similar threads

Back
Top