• 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 random mount on login tfs 1.3

miguelshta

Member
Joined
Mar 21, 2009
Messages
351
Solutions
1
Reaction score
13
Location
Toronto, Canada
tried to add this on login but didnt work
Lua:
function onAdvance(cid, skill, oldlevel, newlevel)

               if getPlayerLevel(cid) >= 1 and getPlayerStorageValue(cid, 623139) ~= 1 then
                            doPlayerAddMount(cid, math.random(1,174))
                            setPlayerStorageValue(cid, 632139, 1)
                            doPlayerSendTextMessage(cid, 19, "You have received a free Mount.")
                            end
            return TRUE
end
 
Well, why would they be advancing on login?

Take out the code and put it into an on login fuction instead.
give me an example pls i have this function too on my login.lua

Lua:
function onLogin(player)
    local items = {
        {2120, 1},
        {2148, 3}
    }
    if player:getLastLoginSaved() == 0 then
        local backpack = player:addItem(1988)
        if backpack then
            for i = 1, #items do
                backpack:addItem(items[i][1], items[i][2])
            end
        end
        player:addItem(2050, 1, true, 1, CONST_SLOT_AMMO)
    else
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format("Your last visit in ".. SERVER_NAME ..": %s.", os.date("%d. %b %Y %X", player:getLastLoginSaved())))
    end
 
Try

Lua:
function onLogin(player)
    local items = {
        {2120, 1},
        {2148, 3}
    }

      if getPlayerLevel(cid) >= 1 and getPlayerStorageValue(cid, 623139) ~= 1 then
                            doPlayerAddMount(cid, math.random(1,174))
                            setPlayerStorageValue(cid, 632139, 1)
                            doPlayerSendTextMessage(cid, 19, "You have received a free Mount.")
                            end


    if player:getLastLoginSaved() == 0 then
        local backpack = player:addItem(1988)
        if backpack then
            for i = 1, #items do
                backpack:addItem(items[i][1], items[i][2])
            end
        end
        player:addItem(2050, 1, true, 1, CONST_SLOT_AMMO)
    else
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format("Your last visit in ".. SERVER_NAME ..": %s.", os.date("%d. %b %Y %X", player:getLastLoginSaved())))
    end
 
Try

Lua:
function onLogin(player)
    local items = {
        {2120, 1},
        {2148, 3}
    }

      if getPlayerLevel(cid) >= 1 and getPlayerStorageValue(cid, 623139) ~= 1 then
                            doPlayerAddMount(cid, math.random(1,174))
                            setPlayerStorageValue(cid, 632139, 1)
                            doPlayerSendTextMessage(cid, 19, "You have received a free Mount.")
                            end


    if player:getLastLoginSaved() == 0 then
        local backpack = player:addItem(1988)
        if backpack then
            for i = 1, #items do
                backpack:addItem(items[i][1], items[i][2])
            end
        end
        player:addItem(2050, 1, true, 1, CONST_SLOT_AMMO)
    else
        player:sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format("Your last visit in ".. SERVER_NAME ..": %s.", os.date("%d. %b %Y %X", player:getLastLoginSaved())))
    end
error:

Lua:
data/creaturescripts/scripts/others/login.lua:onLogin
data/creaturescripts/scripts/others/login.lua:34: attempt to compare number with boolean
stack traceback:
        [C]: in function '__le'
        data/creaturescripts/scripts/others/login.lua:34: in function <data/creaturescripts/scripts/others/login.lua:28>
 
Back
Top