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

TFS 1.0 add money to bank account - LUA

Tofflarn

New Member
Joined
Mar 22, 2008
Messages
360
Reaction score
1
Location
Sweden
Hello!

Im trying to create a script that deposit an amount of money if the player reach a specific level or something like that. But i can't find any good function for this..

My bank NPC uses:
player:depositMoney(cid, ...) and it seems to be working just fine.

But how can i use it in a creaturescript?

// Tofflarn
 
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
local player = Player(cid)
        if(skill == 8 and newLevel > oldLevel) then
               if player:getStorageValue(1000) < 1 and player:getLevel() >= 50 then
                            player:setBankBalance(player:getBankBalance() + 50000)
               end
       end


Something like that.
 
Code:
function onAdvance(cid, skill, oldLevel, newLevel)
local player = Player(cid)
        if(skill == 8 and newLevel > oldLevel) then
               if player:getStorageValue(1000) < 1 and player:getLevel() >= 50 then
                            player:setBankBalance(player:getBankBalance() + 50000)
               end
       end


Something like that.

Code:
function onAdvance(cid, skill, oldLevel, newLevel)
    if(skill == SKILL_LEVEL and newLevel > oldLevel) then
        local player = Player(cid)
        if player:getStorageValue(1000) < 1 and player:getLevel() >= 50 then
            player:setBankBalance(player:getBankBalance() + 50000)
        end
    end
end

That one works, you shoulden't index the player before all scenarios have been evaluated.
If you have a save player script you should merge them, insted of having 2 scripts doing the same thing.
And use constants insted of numbers.
 
Also change this:
Code:
if player:getStorageValue(1000) < 1

to this:
Code:
if player:getStorageValue(1000) ~= 1

Don't forgot:
Code:
player:setStorageValue(1000, 1)
 
Back
Top