• 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 Creaturescript file bug

Ahead

New Member
Joined
Dec 27, 2013
Messages
165
Reaction score
2
I got in my OT a creaturescript that recompense you if you reach X level. Well, it always worked fine but magically (of course, i do not know why if i did not touched anything) it got bugged. I will explain:

Here is the .lua

Code:
function onAdvance(cid, skill, oldlevel, newlevel)
       
            if(getPlayerStorageValue(cid, 99963) ~= 1 and newlevel >= 50) then
                            doPlayerAddItem(cid, 2160, 5)
                            setPlayerStorageValue(cid, 99963, 1)
                            doPlayerSendTextMessage(cid, 22, "You have received 5 Crystal Coins because you reached level 45.")
                            end

            if(getPlayerStorageValue(cid, 99964) ~= 1 and newlevel >= 100) then
                            doPlayerAddItem(cid, 2160, 5)
                            setPlayerStorageValue(cid, 99964, 1)
                            doPlayerSendTextMessage(cid, 22, "You have received 5 Crystal Coins because you reached level 100.")
                            end

            if(getPlayerStorageValue(cid, 99965) ~= 1 and newlevel >= 150) then
                            doPlayerAddItem(cid, 2160, 5)
                            setPlayerStorageValue(cid, 99965, 1)
                            doPlayerSendTextMessage(cid, 22, "You have received 5 Crystal Coins and an Addon Doll because you reached level 150.")
                            end

            if(getPlayerStorageValue(cid, 99966) ~= 1 and newlevel >= 200) then
                            doPlayerAddItem(cid, 2160, 10)
                            doPlayerAddItem(cid, 10064, 1)
                            setPlayerStorageValue(cid, 99966, 1)
                            doPlayerSendTextMessage(cid, 22, "You have received 5 Crystal Coins because you reached level 200.")
                            end

            if(getPlayerStorageValue(cid, 99967) ~= 1 and newlevel >= 250) then
                            doPlayerAddItem(cid, 2160, 10)
                            setPlayerStorageValue(cid, 99967, 1)
                            doPlayerSendTextMessage(cid, 22, "You have received 5 Crystal Coins because you reached level 250.")
                            end

            return TRUE
end

And here the problem:

When i log in with a lvl 8 player and i get ONE level more (to 9, although i get 12 because my server rates) i mysteriously receive 35 crystal coins and this item i put (a doll, doPlayerAddItem(cid, 10064, 1), even when they are for lvl 200). The thing i do not know is WHY now it works like that if before worked propely, you have to reach lvl 50 and incomings...

Thank you all. I hope to be understandable.
 
Code:
if skill ~= SKILL_LEVEL then return true end
I am a little bit confused cause my script had it and it didn't work for him. Wut?
He is using TFS 0.3 :p
000-constant.lua TFS 0.3.
Code:
SKILL_FIST = 0
SKILL_CLUB = 1
SKILL_SWORD = 2
SKILL_AXE = 3
SKILL_DISTANCE = 4
SKILL_SHIELD = 5
SKILL_FISHING = 6
SKILL__MAGLEVEL = 7
SKILL__LEVEL = 8
TFS 0.3 uses SKILL__LEVEL instead of SKILL_LEVEL.
You should check for SKILL__LEVEL, else it will also happen if you advance on other skills.
 
Back
Top