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

TFS 1.X+ Talkactions command from snowball event errors/not working

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i have problem with talkactions command from snowball event, when i try use !snowball info to check rank/info abaut snowball i got client crash, when i trying use command to shot snowball i dont see any effect, i can kill player only if he stay close me, and it dont give me points
And i have error:
zPMFyDW.png


Code:
function onSay(player, words, param)
    if not isInArena(player) then
        return false
    end

    if param == SNOWBALL.comandoAtirar then

        if not SNOWBALL.muniInfinito then
            if player:getStorageValue(10108) > 0 then
                player:setStorageValue(10108, player:getStorageValue(10108) - 1)
                player:sendCancelMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemQntBolas):format(player:getStorageValue(10108)))
            else
                player:sendCancelMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemNaoTemBola)
                return true
            end
        end

        enviarSnowball(player:getId(), player:getPosition(), SNOWBALL.muniDistancia, player:getDirection())
        return false
    elseif param == "info" then
        local str = "     ## -> Player Infos <- ##\n\nPontos: ".. player:getStorageValue(10109) .."\nBolas de neve: ".. player:getStorageValue(10108)

        str = str .. "\n\n          ## -> Ranking <- ##\n\n"
        for i = 1, 5 do
            if CACHE_GAMEPLAYERS[i] then
                str  = str .. i .. ". " .. Player(CACHE_GAMEPLAYERS[i]):getName() .."\n"
            end
        end
        for pos, players in ipairs(CACHE_GAMEPLAYERS) do
            if player:getId() == players then
                str = str .. "Minha posição no ranking: " .. pos
            end
        end

        player:showTextDialog(2111, str)
        return false
    end
end
 
Solution
Okey, i fix 99%, last problem is problem with onSay nil value
Code:
function onSay(player, words, param)
    if not isInArena(player) then
        return false
    end

    if param == 'shot' then
        if player:getExhaustion(10107) > 1 then
            return true
        end

        if not SNOWBALL.muniInfinito then
            if player:getStorageValue(10108) > 0 then
                player:setStorageValue(10108, player:getStorageValue(10108) - 1)
                player:sendCancelMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemQntBolas):format(player:getStorageValue(10108)))
            else
                player:sendCancelMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemNaoTemBola)
                return true
            end...
have u tried to print to find the problem?

I added few, but still i don't know where is problem, when i trying shot i got nil value error, when i try got info about player/ranking i got client crash :/
Code with prints:
Code:
function onSay(player, words, param)
    if not isInArena(player) then
        print("Log: player not found in arena")
        return false
    end

    if param == SNOWBALL.comandoAtirar then
        if player:getExhaustion(10107) > 1 then
            print("Log: command exhaustion")
            return true
        end

        if not SNOWBALL.muniInfinito then
            if player:getStorageValue(10108) > 0 then
                player:setStorageValue(10108, player:getStorageValue(10108) - 1)
                player:sendCancelMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemQntBolas):format(player:getStorageValue(10108)))
                print("Log: snowball removed, still has: " .. player:getStorageValue(10108))
            else
                player:sendCancelMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemNaoTemBola)
                print("Log: player not have snowballs")
                return true
            end
        end
        player:setExhaustion(10107, SNOWBALL.muniExhaust)
        enviarSnowball(player:getId(), player:getPosition(), SNOWBALL.muniDistancia, player:getDirection())
                print("log player id: " .. player:getId())
        print("log position: " .. player:getPosition())
        print("log snowball distance: " .. SNOWBALL.muniDistancia)
        print("log direction: " .. player:getDirection())
        return false
    elseif param == "info" then
        local str = "     ## -> Player Infos <- ##\n\nPontos: ".. player:getStorageValue(10109) .."\nBolas de neve: ".. player:getStorageValue(10108)

        str = str .. "\n\n          ## -> Ranking <- ##\n\n"
        for i = 1, 5 do
            if CACHE_GAMEPLAYERS[i] then
                str  = str .. i .. ". " .. Player(CACHE_GAMEPLAYERS[i]):getName() .."\n"
                print("Log players info: " .. Player(CACHE_GAMEPLAYERS[i]):getName())
            end
        end
        for pos, players in ipairs(CACHE_GAMEPLAYERS) do
            if player:getId() == players then
                str = str .. "Minha posição no ranking: " .. pos
                print("log player ranking: " .. player:getId())
            end
        end

        player:showTextDialog(2111, str)
        return false
    end
end

Prints in console:
adsada.png
dsada.png
dasdas.png
 

Attachments

Okey, i fix 99%, last problem is problem with onSay nil value
Code:
function onSay(player, words, param)
    if not isInArena(player) then
        return false
    end

    if param == 'shot' then
        if player:getExhaustion(10107) > 1 then
            return true
        end

        if not SNOWBALL.muniInfinito then
            if player:getStorageValue(10108) > 0 then
                player:setStorageValue(10108, player:getStorageValue(10108) - 1)
                player:sendCancelMessage(SNOWBALL.prefixo .. (SNOWBALL.mensagemQntBolas):format(player:getStorageValue(10108)))
            else
                player:sendCancelMessage(SNOWBALL.prefixo .. SNOWBALL.mensagemNaoTemBola)
                return true
            end
        end
        player:setExhaustion(10107, SNOWBALL.muniExhaust)
        enviarSnowball(player:getId(), player:getPosition(), SNOWBALL.muniDistancia, player:getDirection())
        return false
                elseif param == 'test' then
            local text = "\n"
            text = text .. "## -> Info <- ##\n\nPkt: ".. player:getStorageValue(10109) .."\nSnowballs: ".. player:getStorageValue(10108)
            text = text .. "\nRanks:\n"

            for i = 1, 5 do
            if CACHE_GAMEPLAYERS[i] then
                text  = text .. i .. ". " .. Player(CACHE_GAMEPLAYERS[i]):getName() .."\n"
            end
        end
                        for pos, players in ipairs(CACHE_GAMEPLAYERS) do
            if player:getId() == players then
                text = text .. "Rank: " .. pos
            end
        end

            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, text)
            return false
    end
end
Post automatically merged:

Okey nvm, i fixed all thanks
 
Last edited:
Solution
Back
Top