• 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+ trying to get as first split name second split amount but im dumb

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,847
Solutions
82
Reaction score
1,955
Location
Germany
title says everything :D im kinda retarded

explain what I want to do: !addreborn playername,amount

script:
Lua:
local testa = TalkAction("!addreborn")

function testa.onSay(player, words, param)
    if player:getAccountType() == 6 then
        local split = param:splitTrimmed(",")
        if param == '' then
            player:sendCancelMessage('missing params')
        return false
    end
    local targetPlayer = Player(split[1])
    if not targetPlayer then
        player:sendCancelMessage('player does not exists')
        return false
    end
    local amount = split[2]
    if not amount or not isNumber(amount) then
        return false
    end
    player:addReborn(amount)
    end
    return false
end

testa:register()
 
Solution
try this
Lua:
local testa = TalkAction("!addreborn")
function testa.onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end
    local split = param:splitTrimmed(",")
    local target = Player(split[1])
    if not target then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end
    local amount = tonumber(split[2])
    if not amount or amount < 1 then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end
    target:addReborn(amount)
    return false
end
testa:separator(" ")
testa:register()
try this
Lua:
local testa = TalkAction("!addreborn")
function testa.onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end
    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end
    local split = param:splitTrimmed(",")
    local target = Player(split[1])
    if not target then
        player:sendCancelMessage("A player with that name is not online.")
        return false
    end
    local amount = tonumber(split[2])
    if not amount or amount < 1 then
        player:sendCancelMessage("Insufficient parameters.")
        return false
    end
    target:addReborn(amount)
    return false
end
testa:separator(" ")
testa:register()
 
Solution
Back
Top