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

[SOLVED] [CreatureScripts] BonusExp for Killing Monsters [1.0]

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,334
Reaction score
615
Location
Sweden
Okey, Another script! :)
Im trying to add a script for my 1.0 server that Points people towards right hunting grounds.
This script will give a player some bonus exp if he or she kills a creature within the right lvls.
(I set Bug high as im trying it on the bug)

Creaturescripts.xml
Code:
 <event type="kill" name="BonusExp" script="BonusExp.lua"/>

BonusExp.lua
Code:
function isWithinRange(number, minN, maxN)
 if maxN == nil then
 maxN = math.huge
 end
 
 if number >= minN and number <= maxN then
 return true
 end
 return false
end
 
check = {extraexp, extraprcnt}
 
 
function onKill(cid, target)
monsters = {
 {name = "Bug", normexp = 18, minlvl = 1, maxlvl = 10, extraexp = 1000},
 {name = "Dragon", normexp = 4200, minlvl = 30, maxlvl = 60, extraexp = 500*getPlayerLevel(cid)},
 {name = "Rat", normexp = 5, minlvl = 1, extraprcnt = 10}
}

 for i, a in pairs(monsters) do
 if a.name == getCreatureName(target) then
 if isWithinRange(getPlayerLevel(cid), a.minlvl, a.maxlvl) == true then
 if a.extraexp then
 doPlayerAddExp(cid, a.extraexp)
 end
 if a.extraprcnt then
 doPlayerAddExp(cid, a.normexp/a.extraprcnt)
 end
 a.extraexp = a.extraexp or 0
 a.extraprcnt = a.extraprcnt or 0
 doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "For killing a monster over your level, you gained " .. a.extraexp + (a.normexp/a.extraprcnt) .. " extra experience points.")
 end
 end
 end
 return 1
end

I got no errors in the logg and I tryed to re-check all the "doPlayerAddExp" etc for 1.0.
The Problem right now is that I DONT get any BONUSEXP when killing as for example a Bug.
A text wont appear either.

Here is the original Script:
http://otland.net/threads/bonus-exp-when-killing-difficult-monsters.141638/

Thanks in advance!

Kind Regards,
Eldin.
 
Hah, learned something new today. ^^

The "BonusExp" now gives the BonusExp, but you get now INFO about it and the logg says "1" "2"

The --- !monsters "bug --- now says "You need to type a Monster Name" without any error.

Kind Regards,
Eldin.
 
just remove the 2 print then and add a doCreatureSay ( just search for it on the forum) after the exp is added should do the trick :p
 
@Evil Hero

Let's say I want to make it so players with a certain storage value can earn 15% bonus experience from all monsters.

Do you know how to make that?
 
Back
Top