• 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 0.X Limit 3 players for IP on Training Monks?

eyez

Member
Joined
Oct 11, 2016
Messages
129
Reaction score
19
How can i do to each player can have only 3 characters in training monk per IP?

entering_monks_script.lua
Code:
function onStepIn(cid, item, position, fromPosition)

for i = 17001, 17100 do
local pos = getThingPos(i)
if not isPlayer(getTopCreature(pos).uid) then
doTeleportThing(cid, pos)
doCreatureSay(cid, 'Training time!.', TALKTYPE_ORANGE_1, false, cid)
doSendMagicEffect(position, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
setPlayerStorageValue(cid, 17000, 1)
return true
end
end
doTeleportThing(cid, fromPosition, true)
doCreatureSay(cid, 'All training slots are taken', TALKTYPE_ORANGE_1, false, cid)
doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
end

leave_monks_script.lua
Code:
function onStepIn(cid, item, position, fromPosition)
    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    doSendMagicEffect(getPlayerPosition(cid), 10)
    setPlayerStorageValue(cid, 17000, 0)
    return true
end
 
Solution
Code:
function onStepIn(cid, item, position, fromPosition)
    local trainers_storage = 17000
    local my_players_on_traning_monk = 0
    local MAX_PLAYERSIP = 3

    if #getPlayersByIp(getPlayerIp(cid)) >= 3 then
        for _,pid in ipairs(getPlayersByIp(getPlayerIp(cid))) do
            if getPlayerStorageValue(pid, trainers_storage) > 0 then
                my_players_on_traning_monk = my_players_on_traning_monk + 1
                if my_players_on_traning_monk >= MAX_PLAYERSIP then
                    doPlayerSendCancel(cid, "You already have ".. MAX_PLAYERSIP .." characters in training monk, That is the limit.")
                    doTeleportThing(cid, fromPosition, true)
                    return false
                end...
Code:
function onStepIn(cid, item, position, fromPosition)
    local trainers_storage = 17000
    local my_players_on_traning_monk = 0
    local MAX_PLAYERSIP = 3

    if #getPlayersByIp(getPlayerIp(cid)) >= 3 then
        for _,pid in ipairs(getPlayersByIp(getPlayerIp(cid))) do
            if getPlayerStorageValue(pid, trainers_storage) > 0 then
                my_players_on_traning_monk = my_players_on_traning_monk + 1
                if my_players_on_traning_monk >= MAX_PLAYERSIP then
                    doPlayerSendCancel(cid, "You already have ".. MAX_PLAYERSIP .." characters in training monk, That is the limit.")
                    doTeleportThing(cid, fromPosition, true)
                    return false
                end
            end
        end
    end

    for i = 17001, 17100 do
        local pos = getThingPos(i)
        if not isPlayer(getTopCreature(pos).uid) then
            doTeleportThing(cid, pos)
            doCreatureSay(cid, 'Training time!.', TALKTYPE_ORANGE_1, false, cid)
            doSendMagicEffect(position, CONST_ME_TELEPORT)
            doSendMagicEffect(pos, CONST_ME_TELEPORT)
            setPlayerStorageValue(cid, trainers_storage, 1)
            return true
        end
    end

    doTeleportThing(cid, fromPosition, true)
    doCreatureSay(cid, 'All training slots are taken', TALKTYPE_ORANGE_1, false, cid)
    doSendMagicEffect(fromPosition, CONST_ME_TELEPORT)
end
 
Last edited:
Solution
that easy way
Lua:
    if #getPlayersByIp(getPlayerIp(cid)) > 3 then
return doPlayerSendTextMessage(cid, 22, "Sorry,to train this character you must have 3 character online not more.") , doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
    end
but with this code if player have more than 3 character online can't enter training room even if this characters are in hunting
there other way but long
add storage for ip and check if > 3 return false
 
that easy way
Lua:
    if #getPlayersByIp(getPlayerIp(cid)) > 3 then
return doPlayerSendTextMessage(cid, 22, "Sorry,to train this character you must have 3 character online not more.") , doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
    end
but with this code if player have more than 3 character online can't enter training room even if this characters are in hunting
there other way but long
add storage for ip and check if > 3 return false

Ty to try to help, but with this script i can lose players :(
 
Back
Top