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

Linux Advancedsave & Lowlevel not working!

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hi!

How can I fix this?

PHP:
[Error - CreatureScript Interface]
data/creaturescripts/scripts/advancesave.lua:onAdvance
Description:
attempt to index a nil value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/creaturescripts/scripts/advancesave.lua:15: in function <data/creaturescripts/scripts/advancesave.lua:7>
        [C]: in function 'doPlayerAddExperience'
        data/creaturescripts/scripts/lowlevellock.lua:4: in function <data/creaturescripts/scripts/lowlevellock.lua:1>
> Broadcasted message: "New record: 1 players are logged in.".
Account Manager has logged out.
Swag has logged in.

[Error - CreatureScript Interface]
data/creaturescripts/scripts/advancesave.lua:onAdvance
Description:
attempt to index a nil value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/creaturescripts/scripts/advancesave.lua:15: in function <data/creaturescripts/scripts/advancesave.lua:7>
        [C]: in function 'doPlayerAddExperience'
        data/creaturescripts/scripts/lowlevellock.lua:4: in function <data/creaturescripts/scripts/lowlevellock.lua:1>

Script advancedsave:
PHP:
local config = {
    savePlayer = true,
    healPlayerOnLevel = true,
    effectType = 30
}

function onAdvance(cid, skill, oldLevel, newLevel)
    if(skill == SKILL__EXPERIENCE) then
        return true
    end

    if(skill == SKILL__LEVEL and config.healPlayerOnLevel) then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
        doSendMagicEffect(pos, config.effectType)
    end

    if(config.savePlayer) then
        doPlayerSave(cid, true)
    end

    return true
end

and lowlevellock:
PHP:
function onLogin(cid)

    if getPlayerLevel(cid) < 50 then
    doPlayerAddExperience(cid, (getExperienceForLevel(50) - getPlayerExperience(cid)))
end
return true
end

Whats wrong?
 
Change this
Code:
doSendMagicEffect(pos, config.effectType)

To this
Code:
doSendMagicEffect(getThingPos(cid), config.effectType)

And add this function:
Code:
function getExperienceForLevel(lv)
   lv = lv - 1
   return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

Change your title to avoid thread deletion, you have to describe your problem in your title.
 
Change this
Code:
doSendMagicEffect(pos, config.effectType)

To this
Code:
doSendMagicEffect(getThingPos(cid), config.effectType)

And add this function:
Code:
function getExperienceForLevel(lv)
   lv = lv - 1
   return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

Change your title to avoid thread deletion, you have to describe your problem in your title.


Thanks! The errors were fixed.

@Limos, Could you explain me why this isn't working? Don't have erros in console when started..
PHP:
function onLogin(cid)

if (getPlayerLastLogin(cid) < 1) then
        if (isSorcerer(cid) or isDruid(cid)) then
            doPlayerAddMagLevel(cid, 45)
            doPlayerAddSkill(cid, SKILL_SHIELD, 10)
        elseif (isPaladin(cid)) then
            doPlayerAddSkill(cid, SKILL_DISTANCE, 60)
            doPlayerAddSkill(cid, SKILL_SHIELD, 60)
            doPlayerAddMagLevel(cid, 20)
        elseif (isKnight(cid)) then
            doPlayerAddSkill(cid, SKILL_SWORD, 60)
            doPlayerAddSkill(cid, SKILL_AXE, 60)
            doPlayerAddSkill(cid, SKILL_SHIELD, 60)
            doPlayerAddMagLevel(cid, 10)
        end
    end

    return TRUE
end

I've added inlogin.lua tag too..
PHP:
      registerCreatureEvent(cid, "StartSkills")


[Sorry for the title].
 
Don't register creaturescripts with type login.
Which server do you use?

You can add prints to see where it goes wrong.
Code:
print("test")
For example under: if (getPlayerLastLogin(cid) < 1) then
You will get this message in your console.

Also possible that the addskill functions aren't working properly, they are Lua made functions, so they can be easily edited.
 
Don't register creaturescripts with type login.
Which server do you use?

You can add prints to see where it goes wrong.
Code:
print("test")
For example under: if (getPlayerLastLogin(cid) < 1) then
You will get this message in your console.

Also possible that the addskill functions aren't working properly, they are Lua made functions, so they can be easily edited.

Like that bro?
PHP:
function onLogin(cid)

if (getPlayerLastLogin(cid) < 1) then
    print("test")
        if (isSorcerer(cid) or isDruid(cid)) then
            doPlayerAddMagLevel(cid, 45)
            doPlayerAddSkill(cid, SKILL_SHIELD, 10)
        elseif (isPaladin(cid)) then
            doPlayerAddSkill(cid, SKILL_DISTANCE, 60)
            doPlayerAddSkill(cid, SKILL_SHIELD, 60)
            doPlayerAddMagLevel(cid, 20)
        elseif (isKnight(cid)) then
            doPlayerAddSkill(cid, SKILL_SWORD, 60)
            doPlayerAddSkill(cid, SKILL_AXE, 60)
            doPlayerAddSkill(cid, SKILL_SHIELD, 60)
            doPlayerAddMagLevel(cid, 10)
        end
    end

    return TRUE
is strange becuz even something being wrong... him don't show me message on the console
 
Which server do you use? Did you tested it with a player that never logged in? If you did, you can also try to use storage instead of getPlayerLastLogin.
 
To check for storage value:
Code:
if getPlayerStorageValue(cid, 5100) == -1 then

To set storage:
Code:
setPlayerStorageValue(cid, 5100, 1)

Startvalue of storage is -1.
Now after a player logs in, the storage 5100 will be set to 1, so the value is not -1 anymore.
 
To check for storage value:
Code:
if getPlayerStorageValue(cid, 5100) == -1 then

To set storage:
Code:
setPlayerStorageValue(cid, 5100, 1)

Startvalue of storage is -1.
Now after a player logs in, the storage 5100 will be set to 1, so the value is not -1 anymore.

im sorry, i dont understand! oO, where i change this!?
 
The if statement instead of the other if statement and the function to set the storage inside the if statement to check for the storage value and outside the other if statement, so above the end above return true.

So change this
Code:
if (getPlayerLastLogin(cid) < 1) then

To this
Code:
if getPlayerStorageValue(cid, 5100) == -1 then

And add this
Code:
setPlayerStorageValue(cid, 5100, 1)

Above this
Code:
    end
    return TRUE
end
 
Last edited:
The if statement instead of the other if statement and the function to set the storage inside the if statement to check for the storage value and outside the other if statement, so above the end above return true.

So change this
Code:
if (getPlayerLastLogin(cid) < 1) then

Im sorry again.... ???? Could u help and show?! idk idea
 
The if statement instead of the other if statement and the function to set the storage inside the if statement to check for the storage value and outside the other if statement, so above the end above return true.

So change this
Code:
if (getPlayerLastLogin(cid) < 1) then

To this
Code:
if getPlayerStorageValue(cid, 5100) == -1 then

And add this
Code:
setPlayerStorageValue(cid, 5100, 1)

Above this
Code:
    end
    return TRUE
end

Now are working brah! Thanks a lot @Limos !
 
Last edited:
Back
Top