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

weapon levels. nil value

soul4soul

Intermediate OT User
Joined
Aug 13, 2007
Messages
1,878
Solutions
3
Reaction score
130
Location
USA
code:
Code:
--[[
        ** Weapons with Levels V3.0 by Soul4Soul**
]]--

function onKill(cid, target)
    local playerWeapon = getPlayerWeapon(cid, TRUE)
    if(playerWeapon.itemid == 0) then
        return true
    end
    
    local add = 2
    local currentExtraAttack = getItemAttribute(playerWeapon.uid, "extraattack")
    if currentExtraAttack == nil then
        currentExtraAttack = 0
    end
    
    local levelforumla = math.ceil(currentExtraAttack+2+math.sqrt(currentExtraAttack))
    if(playerWeapon.actionid ~= 0) then
        if((playerWeapon.actionid-1000) >= levelformula) then
            doItemSetAttribute(playerWeapon.uid, "extraattack", currentExtraAttack + add)
            ddoSendAnimatedText(getCreaturePosition(cid), "Congratulations! Your weapon received +" ..add.. " attack points and now have total extra damage of +" .. getItemAttribute(playerWeapon.uid, "extraattack") .. " points!", TEXTCOLOR_WHITE)
            doItemSetAttribute(playerWeapon.uid, "description", "")
        else
            doItemSetAttribute(playerWeapon.uid, "aid", playerWeapon.actionid + 1)
            doItemSetAttribute(playerWeapon.uid, "description", "["..(playerWeapon.actionid-1000).."/"..levelformula.." ]")
        end
    else
        doItemSetAttribute(playerWeapon.uid, "aid", 1001)
        doItemSetAttribute(playerWeapon.uid, "description", "[1/"..levelformula.." ]")
    end
    return true
end
im not sure whats wrong anymore i tried a lot of different things and i was testing the variables they all have the correct set values. i even tried using tonumber to make sure levelforumla is a number
error:
[Error - CreatureScript Interface]
data/creaturescripts/scripts/weaponadvance.lua:onKill
Description:
data/creaturescripts/scripts/weaponadvance.lua:29: attempt to concatenate global
'levelformula' (a nil value)
stack traceback:
data/creaturescripts/scripts/weaponadvance.lua:29: in function <data/cre
aturescripts/scripts/weaponadvance.lua:5>

[Error - CreatureScript Interface]
data/creaturescripts/scripts/weaponadvance.lua:onKill
Description:
data/creaturescripts/scripts/weaponadvance.lua:19: attempt to compare nil with n
umber
stack traceback:
data/creaturescripts/scripts/weaponadvance.lua:19: in function <data/cre
aturescripts/scripts/weaponadvance.lua:5>
 
Last edited:
Well for me the getItemAttribute(uid,key) function doesn't work well it always return nil.

The bug is you need to replace:
math.ceil((math.sqrt(currentExtraAttack))+(currentExtraAttack+2))
with
math.ceil((math.sqrt(currentExtraAttack)+currentExtraAttack+2))

also you need to fix the getItemAttribute (or myb it works for you)
 
well it seems to be working for me(getitemattribute). and i was testing it by using docreaturesay


doCreatureSay(cid, playerWeapon.actionid, TALKTYPE_ORANGE_1)
would make me say 0 once then i would say 1001 forever
doCreatureSay(cid, currentExtraAttack, TALKTYPE_ORANGE_1)
would make me say 0 forever
----------------
i placed docreaturesay right after local levelformula= etc....
------------------
math.ceil(currentExtraAttack+2+math.sqrt(currentExtraAttack))
this is what i use now its less ()'s
 
Last edited:
What is not working now?
This formula? math.ceil(currentExtraAttack+2+math.sqrt(currentEx traAttack))

If yes than replace with:
math.ceil((currentExtraAttack+2+math.sqrt(currentEx traAttack)))
 
the same thing as the first post rearranging the order of the formula doesnt fix it.

doCreatureSay(cid, levelformula, TALKTYPE_ORANGE_1)
like i said im using do creauture say so help me determine the values of variables.

if i remove math.ceil() from the equation i say 2
if i keep it i dont say anything
 
Last edited:
Back
Top