Postado Setembro 7, 2017 8 anos Hello ! I'm using tfs 0.4 for client 8.6. I got an double exp rate script, which boost the exp gained from killing monsters, and this is it: local otswe = { storage = 5995, -- Put Unused Storage Here time_end = 120*60*1000, -- Edit Time Here end_text = "The Powers Of The Gods Has Expired.", -- Editable Text cancel_text = "Sorry, But You Already Effected By The Gods.", -- Editable Text text_onuse = "2X", -- Editable Magic Text Max 8 letters exp_rate = 2.0, -- New Exprience Rate old_rate = 1.0 -- Old Exprience Rate } function onUse(cid, item, frompos, item2, topos) if getPlayerStorageValue(cid,otswe.storage) == 1 then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, otswe.cancel_text) return false end if isPlayer(cid) then doCreatureSay(cid, "You Have Gained Powers from The Gods! You Will Gain Twice Faster Experience For 2 Hours! ", TALKTYPE_ORANGE_1) doSendAnimatedText(getCreaturePosition(cid), otswe.text_onuse ,TEXTCOLOR_RED) doSendMagicEffect(getCreaturePosition(cid), math.random(28, 30)) doPlayerSetRate(cid, SKILL__LEVEL, 2) addEvent(otswe_exp_scroll,otswe.time_end,cid) setPlayerStorageValue(cid, otswe.storage, 1) doRemoveItem(item.uid, 1) end return true end function otswe_exp_scroll(rate, cid) if isPlayer(rate) then doPlayerSetRate(rate, SKILL__LEVEL, otswe.old_rate) doPlayerSendTextMessage(rate,MESSAGE_STATUS_CONSOLE_RED, otswe.end_text) setPlayerStorageValue(rate, otswe.storage, 0) end end But as the title said I want the players to have double rate for all earned Exp including ( monsters / players"PVP" ). Or if someone able to make the double exp only for killing players (PVP), I will appreciate that alot
Postado Setembro 7, 2017 8 anos Hi. This could be difficult to do in tfs 0.4. I think it could be possible if you have a "gain experience formula" for dead player level. Even so, it would be an approximation. Additionally, you can try to add extra exp during a time if player kills another player, according to dead player level. If you think this could be useful, here you go. In actions/scripts, create a file: expkill.lua Spoiler local t = {duration = {1, "hour"}, exp_stor = 50400} function onUse(cid, item, fromPosition, itemEx, toPosition) local p = getPlayerPosition(cid) if getPlayerStorageValue(cid, t.exp_stor) - os.time() > 0 then local number = t.duration[2] == "hour" and 3600 or t.duration[2] == "min" and 60 or 1 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You are already affected for " .. math.ceil((getPlayerStorageValue(cid, t.exp_stor) - os.time())/(number)) .. " "..t.duration[2].." approximately.") doSendMagicEffect(p, CONST_ME_POFF) return true end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will now gain more experience in killing players for " .. t.duration[1] .. " " .. t.duration[2] .. "" .. (t.duration[1] > 1 and "s" or "").. ".") doSendMagicEffect(p, CONST_ME_STUN) setPlayerStorageValue(cid, t.exp_stor, mathtime(t.duration) + os.time()) doRemoveItem(item.uid,1) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return "Error: Bad declaration in mathtime function." end Add the tag in actions.xml: <action itemid="ITEMID" script="expkill.lua" /> In creaturescripts/scripts, create a file: killexp.lua Spoiler local exp_stor = 50400 local t = { [{1,100}] = 20000, -- {dead player fromlevel, dead player tolevel} = will be added this exp [{101, 200}] = 30000, [{200, 250}] = 40000 } function onKill(cid, target, damage, flags) if(not isPlayer(target)) or (not isPlayer(cid)) then return true end if getPlayerIp(target) == getPlayerIp(cid) then return true end if getPlayerStorageValue(cid, exp_stor) - os.time() > 0 then add_exp = tonumber(getExtraExp(target)) doPlayerAddExperience(cid, add_exp) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience points: " .. add_exp) end return true end function getExtraExp(target) for level, extra_exp in pairs(t) do if getPlayerLevel(target) >= level[1] and getPlayerLevel(target) <= level[2] then return extra_exp end end end In creaturescripts.xml, add the tag: <event type="kill" name="KillExp" event="script" value="killexp.lua"/> And register the event in the login.lua: registerCreatureEvent(cid, "KillExp") Editado Setembro 7, 2017 8 anos por Dwarfer (veja o histórico de edições) Contato: Email: [email protected] Discord: Dwarfer#2715
Postado Setembro 9, 2017 8 anos Autor On 9/7/2017 at 10:02 PM, Dwarfer said: Hi. This could be difficult to do in tfs 0.4. I think it could be possible if you have a "gain experience formula" for dead player level. Even so, it would be an approximation. Additionally, you can try to add extra exp during a time if player kills another player, according to dead player level. If you think this could be useful, here you go. In actions/scripts, create a file: expkill.lua Hide contents local t = {duration = {1, "hour"}, exp_stor = 50400} function onUse(cid, item, fromPosition, itemEx, toPosition) local p = getPlayerPosition(cid) if getPlayerStorageValue(cid, t.exp_stor) - os.time() > 0 then local number = t.duration[2] == "hour" and 3600 or t.duration[2] == "min" and 60 or 1 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You are already affected for " .. math.ceil((getPlayerStorageValue(cid, t.exp_stor) - os.time())/(number)) .. " "..t.duration[2].." approximately.") doSendMagicEffect(p, CONST_ME_POFF) return true end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You will now gain more experience in killing players for " .. t.duration[1] .. " " .. t.duration[2] .. "" .. (t.duration[1] > 1 and "s" or "").. ".") doSendMagicEffect(p, CONST_ME_STUN) setPlayerStorageValue(cid, t.exp_stor, mathtime(t.duration) + os.time()) doRemoveItem(item.uid,1) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return "Error: Bad declaration in mathtime function." end Add the tag in actions.xml: <action itemid="ITEMID" script="expkill.lua" /> In creaturescripts/scripts, create a file: killexp.lua Hide contents local exp_stor = 50400 local t = { [{1,100}] = 20000, -- {dead player fromlevel, dead player tolevel} = will be added this exp [{101, 200}] = 30000, [{200, 250}] = 40000 } function onKill(cid, target, damage, flags) if(not isPlayer(target)) or (not isPlayer(cid)) then return true end if getPlayerIp(target) == getPlayerIp(cid) then return true end if getPlayerStorageValue(cid, exp_stor) - os.time() > 0 then add_exp = tonumber(getExtraExp(target)) doPlayerAddExperience(cid, add_exp) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Extra experience points: " .. add_exp) end return true end function getExtraExp(target) for level, extra_exp in pairs(t) do if getPlayerLevel(target) >= level[1] and getPlayerLevel(target) <= level[2] then return extra_exp end end end In creaturescripts.xml, add the tag: <event type="kill" name="KillExp" event="script" value="killexp.lua"/> And register the event in the login.lua: registerCreatureEvent(cid, "KillExp") thanks mate i will give this a try.. but i made a highexp server which means players can get till 3m level and 5.5m max is there anyway to make the bonus exp is a ratio related to the dead player?
Postado Setembro 9, 2017 8 anos @Yusuf As I said before, you have to define a criterion. That's what I meant by "gain experience formula". If you know the experience that will be added to the killer based on level difference, you can do an approximation. The code I have sent you is based on dead player level and, consequently, on dead player experience approximately. You can define others like: function getGainExp(target, ratios) return math.random(ratios[1], ratios[2])*getPlayerExperience(target) end And use like this: getGainExp(target, {0.5, 0.7}) -- a value between 50% and 70% dead player experience Or: function getGainExp(cid, target, maxlevel, bigdiff, bigdiffratio) local diff = getPlayerLevel(target) - getPlayerLevel(cid) local exp = getPlayerExperience(target) if (diff + 30 <= 0) or (getPlayerLevel(cid) >= maxlevel) then return 0 elseif (diff >= bigdiff) then return bigdiffratio*exp else return (diff/10000)*exp end end And use like this: getGainExp(cid, target, 5000, 3000, 0.5) if killer level is 30 higher than dead player level -- it won't added exp if killer level is 5000 or higher -- it won't added exp if (dead player level - killer level) is 3000 or higher -- it will be added (0.5*dead player exp) that means 50% if none the before conditions occurs -- it will be added ((level difference)/10000)*dead player exp For example: level difference = 1000 It will be added 0.1*dead player exp that means 10% And so on, you can create a criterion. Editado Setembro 9, 2017 8 anos por Dwarfer (veja o histórico de edições) Contato: Email: [email protected] Discord: Dwarfer#2715
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.