• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Monster Get Experience Percent

CollapserMemory

New Member
Joined
Dec 4, 2014
Messages
66
Reaction score
1
I need a monster of a percent level, regardless of the level of the player instance, I kill the monster at level 100 and earn 300% of experience that is 3 levels and the same with any other level
 
This should be in requests, not support. However, I'll help you this time. You should also be adding what distro you use. I've made a script for TFS 1.x. It won't work for earlier versions.

Set the monster's exp to 0, then create a lua script in creaturescripts/scripts. enter this:
Code:
local function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local levels = 3 -- number of levels to give
local monsters = {"Special Demon"} -- creatures that will give these levels
function onKill(creature, target)
    local monster = Monster(target)
    if not monster then
        return true
    end
    local player = Player(creature)
    if not player then
        return true
    end
    for i = 1, #monsters do
        if monster:getName():lower() == monsters[i]:lower() then
            for j = 1, levels do
                player:addExperience(getExperienceForLevel(player:getLevel() + 1))
            end
        end
    end
    return true
end

then in creaturescripts.xml, register it like this:
Code:
<event type="kill" name="ThreeLevels" script="YOUR_SCRIPT_NAME.lua" />
replace YOUR_SCRIPT_NAME with the name of the file you've chosen.

in creaturescripts/login.lua, at the bottom near the rest of the event registration, place this:
Code:
player:registerEvent("ThreeLevels")
 
This should be in requests, not support. However, I'll help you this time. You should also be adding what distro you use. I've made a script for TFS 1.x. It won't work for earlier versions.

Set the monster's exp to 0, then create a lua script in creaturescripts/scripts. enter this:
Code:
local function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local levels = 3 -- number of levels to give
local monsters = {"Special Demon"} -- creatures that will give these levels
function onKill(creature, target)
    local monster = Monster(target)
    if not monster then
        return true
    end
    local player = Player(creature)
    if not player then
        return true
    end
    for i = 1, #monsters do
        if monster:getName():lower() == monsters[i]:lower() then
            for j = 1, levels do
                player:addExperience(getExperienceForLevel(player:getLevel() + 1))
            end
        end
    end
    return true
end

then in creaturescripts.xml, register it like this:
Code:
<event type="kill" name="ThreeLevels" script="YOUR_SCRIPT_NAME.lua" />
replace YOUR_SCRIPT_NAME with the name of the file you've chosen.

in creaturescripts/login.lua, at the bottom near the rest of the event registration, place this:
Code:
player:registerEvent("ThreeLevels")

My Tfs is 0.3.1 i'm using server 8.40 :'( i'm searching for any tfs 0.3.2 but i don't find ... my tfs no can use MODS ?
 
I don't really know anything about mods. My script will only work for TFS 1.x, so 1.0 (maybe), 1.1, 1.2. Definitely won't work for any of the 0.3 range. Perhaps someone can convert it for you, as I'm unfamiliar with the functions available in 0.3.
 
I don't really know anything about mods. My script will only work for TFS 1.x, so 1.0 (maybe), 1.1, 1.2. Definitely won't work for any of the 0.3 range. Perhaps someone can convert it for you, as I'm unfamiliar with the functions available in 0.3.

I understand, thank you!. I will ask someone to convert it -- is possible add more functions on lib for this script succeed?
 
unfortunately, no. The main issue is that mine uses metatables/metamethods, and I'm not sure what the conversions are for your version.
If you have isMonster(cid), isPlayer(cid) and something to replace creature:getName() and player:addExperience, then I believe I can convert it. I also don't even know if 0.3 has onKill so someone will have to confirm that as well.
 
unfortunately, no. The main issue is that mine uses metatables/metamethods, and I'm not sure what the conversions are for your version.
If you have isMonster(cid), isPlayer(cid) and something to replace creature:getName() and player:addExperience, then I believe I can convert it. I also don't even know if 0.3 has onKill so someone will have to confirm that as well.

have the -- ..getPlayerName(cid).. -- and --- doPlayerAddExp --- Can u use this ?
 
getPlayerName(cid) can't be used as far as I know, is there one that's getCreatureName or something like that? And do you have something like isMonster(cid) or isPlayer(cid)? if so, I think this should work.
Code:
local function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local levels = 3 -- number of levels to give
local monsters = {"Special Demon"} -- creatures that will give these levels
function onKill(cid, target)
    if not isMonster(target) then
        return true
    end
    if not isPlayer(cid) then
        return true
    end
    for i = 1, #monsters do
        if getCreatureName(target):lower() == monsters[i]:lower() then
            for j = 1, levels do
                doPlayerAddExp(getExperienceForLevel(getPlayerLevel(cid) + 1))
            end
        end
    end
    return true
end
 
getPlayerName(cid) can't be used as far as I know, is there one that's getCreatureName or something like that? And do you have something like isMonster(cid) or isPlayer(cid)? if so, I think this should work.
Code:
local function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local levels = 3 -- number of levels to give
local monsters = {"Special Demon"} -- creatures that will give these levels
function onKill(cid, target)
    if not isMonster(target) then
        return true
    end
    if not isPlayer(cid) then
        return true
    end
    for i = 1, #monsters do
        if getCreatureName(target):lower() == monsters[i]:lower() then
            for j = 1, levels do
                doPlayerAddExp(getExperienceForLevel(getPlayerLevel(cid) + 1))
            end
        end
    end
    return true
end

where I can see what functions have?
 
well, in the source code would be the easiest place. global.lua may have some of them. if you have a lib folder, there may be some in there. otherwise, if you look inside some scripts in the creaturescripts folder, there MAY be an example of some functions that are used.
 
based on the assumptions that you have all of these, just change Special Demon to like Rat or something and test it, see if you get any errors.
Code:
local function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local levels = 3 -- number of levels to give
local monsters = {"Special Demon"} -- creatures that will give these levels
function onKill(cid, target)
if not isMonster(target) then
return true
end
if not isPlayer(cid) then
return true
end
for i = 1, #monsters do
if getCreatureName(target):lower() == monsters[i]:lower() then
for j = 1, levels do
doPlayerAddExp(cid, getExperienceForLevel(getPlayerLevel(cid) + 1))
end
end
end
return true
end
 
based on the assumptions that you have all of these, just change Special Demon to like Rat or something and test it, see if you get any errors.
Code:
local function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local levels = 3 -- number of levels to give
local monsters = {"Special Demon"} -- creatures that will give these levels
function onKill(cid, target)
if not isMonster(target) then
return true
end
if not isPlayer(cid) then
return true
end
for i = 1, #monsters do
if getCreatureName(target):lower() == monsters[i]:lower() then
for j = 1, levels do
doPlayerAddExp(cid, getExperienceForLevel(getPlayerLevel(cid) + 1))
end
end
end
return true
end

[27/07/2015 00:19:39] ¤~Vinny~¤ has logged in.

[27/07/2015 00:19:39] Lua Script Error: [CreatureScript Interface]
[27/07/2015 00:19:39] data/creaturescripts/scripts/login.lua:onLogin

[27/07/2015 00:19:39] data/creaturescripts/scripts/login.lua:15: attempt to index global 'player' (a nil value)
[27/07/2015 00:19:39] stack traceback:
[27/07/2015 00:19:39] data/creaturescripts/scripts/login.lua:15: in function <data/creaturescripts/scripts/login.lua:1>
[27/07/2015 00:19:39] ¤~Vinny~¤ has logged out.
 
player:registerEvent("ThreeLevels")
this is causing the error. I think you'd need something like
registerEvent(cid, "ThreeLevels")
Just follow what there is for other events in the script
 
that'd be the one then.
so RegisterCreatureEvent(cid, "ThreeLevels") should work.
fail man :x -- I login last i summon monster...
[27/07/2015 00:33:16] Kboing has logged in.

[27/07/2015 00:33:16] Lua Script Error: [CreatureScript Interface]
[27/07/2015 00:33:16] data/creaturescripts/scripts/login.lua:onLogin

[27/07/2015 00:33:16] luaRegisterCreatureEvent(). Creature not found
[27/07/2015 00:33:18] Kboing has logged out.
[27/07/2015 00:33:18] ¤~Vinny~¤ has logged in.

[27/07/2015 00:33:18] Lua Script Error: [CreatureScript Interface]
[27/07/2015 00:33:18] data/creaturescripts/scripts/login.lua:onLogin

[27/07/2015 00:33:18] luaRegisterCreatureEvent(). Creature not found
[27/07/2015 00:33:22] ¤~Vinny~¤ has logged out.
[27/07/2015 00:33:23] Kboing has logged in.

[27/07/2015 00:33:23] Lua Script Error: [CreatureScript Interface]
[27/07/2015 00:33:23] data/creaturescripts/scripts/login.lua:onLogin

[27/07/2015 00:33:23] luaRegisterCreatureEvent(). Creature not found
 
post your login.lua

function onLogin(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil) then
for i = PLAYERLOSS_EXPERIENCE, PLAYERLOSS_ITEMS do
doPlayerSetLossPercent(cid, i, getConfigValue('deathLostPercent'))
end
end

registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "ReflectDamage")
registerCreatureEvent(cid, "AntiMc")
registerCreatureEvent(cid, "AntiMcs")
registerCreatureEvent(cid, "WeaponPar")
registerCreatureEvent("ThreeLevels")
return TRUE
end
 
On XML are --
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" script="login.lua"/>
<event type="statschange" name="ReflectDamage" script="reflect.lua"/>
<event type="login" name="FirstItems" script="firstitems.lua"/>
<event type="login" name="AntiMC" script="antimc2.lua"/>
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
<event type="joinchannel" name="GuildMotd" script="guildmotd.lua"/>
<event type="login" name="Conected" script="conected.lua"/>
<event type="login" name="AntiMcs" event="script" value="antimc0.lua"/>
<event type="login" name="Add" event="script" value="preventcrash.lua"/>
<event type="logout" name="Del" event="script" value="preventcrash.lua"/>
<event type="attack" name="WeaponPar" script="weaponpar.lua"/>
<event type="kill" name="ThreeLevels" script="testao.lua" />
</creaturescripts>
 
Back
Top