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

Im looking for minimun level script. Thanks

CesarZ

Well-Known Member
Joined
Sep 20, 2012
Messages
268
Solutions
4
Reaction score
63
like this one but for TFS 1.0 this one doesn't work on TFS 1.0.
The minimun level is 350 if it goes below it get you back up.


Code:
function onLogin(cid)

if getPlayerLevel(cid) < 350 then
doPlayerAddExperience(cid, (getExperienceForLevel(350) - getPlayerExperience(cid)))
end
return TRUE
end
 
Solution
What? This isn't related to globalevents at all.
data\creaturescripts\scripts then create a new Lua file name it levellock and add HalfAway script to it
Lua:
function onLogin(cid)
     local player = Player(cid)
     if player:getLevel() < 350 then
         player:addExperience(getExpForLevel(350) - player:getExperience(), true)
    end
    return true
end
then in data\creaturescripts\creaturescripts.xml add this line
XML:
<event type="login" name="LevelLock" script="levellock.lua"/>
and register it in data\creaturescripts\scripts\login.lua like this
Lua:
player:registerEvent("LevelLock")
Then in data\global.lua add this function at the end
Lua:
function getExpForLevel(level)
level = level - 1...
Lua:
function onLogin(cid)
 	local player = Player(cid)
 	if player:getLevel() < 350 then
 		player:addExperience(getExpForLevel(350) - player:getExperience(), true)
	end
	return true
end
 
getExpForLevel doesn't exist in TFSS 1.0, You'll have to add it to your global.lua
Lua:
function getExpForLevel(level)
level = level - 1
return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end
 
getExpForLevel doesn't exist in TFSS 1.0, You'll have to add it to your global.lua
Lua:
function getExpForLevel(level)
level = level - 1
return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end


How would i put this is my globalevent?
Code:
<globalevent type="startup" name="levellock" script="levellock.lua" />

But then it says they cant find anything in startup.lua what else do i have to add in my startup.lua other than what i already have which is.
Code:
function onStartup()
    db.query("TRUNCATE TABLE `players_online`")
    db.query("DELETE FROM `guild_wars` WHERE `status` = 0")
    db.query("DELETE FROM `players` WHERE `deletion` != 0 AND `deletion` < " .. os.time())
    db.query("DELETE FROM `ip_bans` WHERE `expires_at` != 0 AND `expires_at` <= " .. os.time())
    db.query("DELETE FROM `market_history` WHERE `inserted` <= " .. (os.time() - configManager.getNumber(configKeys.MARKET_OFFER_DURATION)))

    -- Move expired bans to ban history
    local resultId = db.storeQuery("SELECT * FROM `account_bans` WHERE `expires_at` != 0 AND `expires_at` <= " .. os.time())
    if resultId ~= false then
        repeat
            local accountId = result.getDataInt(resultId, "account_id")
            db.query("INSERT INTO `account_ban_history` (`account_id`, `reason`, `banned_at`, `expired_at`, `banned_by`) VALUES (" .. accountId .. ", " .. db.escapeString(result.getDataString(resultId, "reason")) .. ", " .. result.getDataLong(resultId, "banned_at") .. ", " .. result.getDataLong(resultId, "expires_at") .. ", " .. result.getDataInt(resultId, "banned_by") .. ")")
            db.query("DELETE FROM `account_bans` WHERE `account_id` = " .. accountId)
        until not result.next(resultId)
        result.free(resultId)
    end

    -- Check house auctions
    local resultId = db.storeQuery("SELECT `id`, `highest_bidder`, `last_bid`, (SELECT `balance` FROM `players` WHERE `players`.`id` = `highest_bidder`) AS `balance` FROM `houses` WHERE `owner` = 0 AND `bid_end` != 0 AND `bid_end` < " .. os.time())
    if resultId ~= false then
        repeat
            local house = House(result.getDataInt(resultId, "id"))
            if house ~= nil then
                local highestBidder = result.getDataInt(resultId, "highest_bidder")
                local balance = result.getDataLong(resultId, "balance")
                local lastBid = result.getDataInt(resultId, "last_bid")
                if balance >= lastBid then
                    db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
                    house:setOwnerGuid(highestBidder)
                end
                db.query("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
            end
        until not result.next(resultId)
        result.free(resultId)
    end
end
or i have to set it to another "type"?
 
What? This isn't related to globalevents at all.
data\creaturescripts\scripts then create a new Lua file name it levellock and add HalfAway script to it
Lua:
function onLogin(cid)
     local player = Player(cid)
     if player:getLevel() < 350 then
         player:addExperience(getExpForLevel(350) - player:getExperience(), true)
    end
    return true
end
then in data\creaturescripts\creaturescripts.xml add this line
XML:
<event type="login" name="LevelLock" script="levellock.lua"/>
and register it in data\creaturescripts\scripts\login.lua like this
Lua:
player:registerEvent("LevelLock")
Then in data\global.lua add this function at the end
Lua:
function getExpForLevel(level)
level = level - 1
return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end
 
Solution
Dude it worked. i learned something new about the global.lue and adding function in it if the TFs version doesn't have it. Thank you very much, and yea i was messing with the global event like an idiot lol. I'm learning tho im trying to open a war ot and learning how to script and get scripts to work together lmao i already know how to compile took me a week. Wish me luck!




What? This isn't related to globalevents at all.
data\creaturescripts\scripts then create a new Lua file name it levellock and add HalfAway script to it
Lua:
function onLogin(cid)
     local player = Player(cid)
     if player:getLevel() < 350 then
         player:addExperience(getExpForLevel(350) - player:getExperience(), true)
    end
    return true
end
then in data\creaturescripts\creaturescripts.xml add this line
XML:
<event type="login" name="LevelLock" script="levellock.lua"/>
and register it in data\creaturescripts\scripts\login.lua like this
Lua:
player:registerEvent("LevelLock")
Then in data\global.lua add this function at the end
Lua:
function getExpForLevel(level)
level = level - 1
return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3
end
 
Good luck with your server, Feel free to post any other issue you have during doing it and me or other Support team members/members will try to help you.
 
Hey if i want to add an amulet of loss to the player everytime he lose it in a fight. how do i do it? it's pretty much this same process but with an item i guess. the lua script have to check if the player has the item if not add it up. How would you set that up.

or if you can make the amulet of loss to never end which would be easier. is that something i edit in the compile files?

Also when you die you log in with a bag after loosing you backpack if i cant find where is this lua is located i can add the amulet of loss script right next to it so when you log in after dying you get an amulet also.





Nevermind i figured out!

Good luck with your server, Feel free to post any other issue you have during doing it and me or other Support team members/members will try to help you.
 
Last edited:
Good, Just create a thread for every issue/request so it doesn't get all messed up in one thread and to be easier for others to find what they are looking for by using search button.
 
Back
Top