• 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 Help me with on logout + in trainer camp = storage 5000 = onlogin keep message train

demonz

New Member
Joined
Jan 28, 2010
Messages
136
Reaction score
0
I

use this

Code:
local config = {
    timing = 1*60000, -- Time between trains
    storage = 5000, -- Storage used
    starttime = 10 -- Time before starting to train
}

function kick(cid)
    if (getPlayerStorageValue(cid, config.storage+1) == 0) then
        return false
    end
    doTeleportThing(cid, getPlayerMasterPos(cid))
    setPlayerStorageValue(cid, config.storage, 0)
    setPlayerStorageValue(cid, config.storage+1, 0)
end

function train(cid)
    local count = 0
    param = {cid = cid, count = count}
    train2(param)
end

function train2(param)
    local cid = param.cid
    local count = param.count
    if (isPlayer(cid) and getPlayerStorageValue(cid, config.storage) >= 1 and getPlayerStorageValue(cid, config.storage+2) == 1) then
        count = 0
        mana = 0
        leftwep = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
        rightwep = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
        if (leftwep.itemid ~= 0) then
            leftwep = getItemWeaponType(leftwep.uid) == 8 and 0 or getItemWeaponType(leftwep.uid)
        else
            leftwep = 0
        end
        if (rightwep.itemid ~= 0) then
            rightwep = getItemWeaponType(rightwep.uid) == 8 and 0 or getItemWeaponType(rightwep.uid)
        else
            rightwep = 0
        end
        if (rightwep == 1 or leftwep == 1) then
            doPlayerAddSkillTry(cid, 0, 0)
        elseif (rightwep == 2 or leftwep == 2) then
            doPlayerAddSkillTry(cid, 0, 0)
        elseif (rightwep == 3 or leftwep == 3) then
            doPlayerAddSkillTry(cid, 0, 0)
        elseif (rightwep == 5 or leftwep == 5) then
            doPlayerAddSkillTry(cid, 0, 0)
        elseif (rightwep == 6 or leftwep == 6) then
            mana = mana + 0
        elseif (rightwep == 0 or leftwep == 0) then
            doPlayerAddSkillTry(cid, 0, 0)
        end
        if (rightwep == 4 or leftwep == 4) then
            doPlayerAddSkillTry(cid, 0, 0)
        end
        doPlayerAddSpentMana(cid, mana)
        param = {cid = cid, count = count}
        addEvent(train2, config.timing, param)
        doSendMagicEffect(getCreaturePos(cid), CONST_ME_MAGIC_GREEN)
    elseif not(isPlayer(cid)) then
        return true
    else
        count = count + 1
        if (count == 12) then
            kick(cid)
            return TRUE
        end
        param = {cid = cid, count = count}
        addEvent(train2, config.starttime*1000, param)
    end
    return TRUE
end

function onStepIn(cid, item, pos, fromPos)
    setPlayerStorageValue(cid, config.storage, 0)
    setPlayerStorageValue(cid, config.storage+1, 1)
    setPlayerStorageValue(cid, config.storage+2, 0)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are in training area, please say !train. You have " .. config.starttime*12 .. " seconds to do this.")
    addEvent(train, config.starttime*1000, cid)
end

function onStepOut(cid, item, pos, fromPos)
    setPlayerStorageValue(cid, config.storage, 0)
    setPlayerStorageValue(cid, config.storage+1, 0)
    setPlayerStorageValue(cid, config.storage+2, 0)
end

When the players logged out and loge in the system not keep

Can somebody do a creaturescripts on on login.lua?

function onLogout(cid) keep storage....?
 

Similar threads

Back
Top