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

Lua System accepting only 2 cases

dkangel83

Member
Joined
Mar 31, 2010
Messages
148
Reaction score
18
Location
Brazil
Well im using a system to show what is the experience multiplier that the char is receiving but it only works if tow cases are set, more that, the code wont show..

im using this code to show the info needed

Code:
function onSay(player, words, param)
local p = player
local s = function(p, lv)
       local k = Game.getExperienceStage(lv)
       local st = p:getStamina()
       local pv = p:getVipDays()
       local pp = p:getPremiumDays()
        if pv > 0 and st > 2400 then
            return k*(1.5+1.2) .. " (vip exp and stamina bonus) "
        elseif pv > 0 and st < 840 then
            return k*(0.5+0.2) .. " (penalty for stamina too low) "
        elseif pp > 0 and pv == 0 and st > 2400 then
            return k*1.5 .. " (stamina bonus) "
        elseif pv == 0 and st < 840 then
            return k*0.5 .. " (stamina penalty) "
        elseif pp > 0 and pv == 0 and st > 841 and st < 2399 then
            return k .. " (normal) "
        elseif pp > 0 and pv > 0 and st > 841 and st < 2399 then
            return k*1.2 .. " (vip bonus) "
        elseif pp == 0 and pv > 0 and st > 841 and st < 2399 then
            return k*1.2 .. " (vip bonus) "
        elseif st < 1 then
           return 0 .. " (out of stamina) "
--        else
--           return k .. "(aqui)"
        end
    end

   if words == "!exp" then
     local lv = p:getLevel()
     p:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need " .. ((50 * lv^3) - (150 * lv^2) + (400 * lv)) / 3 - p:getExperience() .. " experience more, for " .. lv+1 .. " level.")
     p:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Current rate: x" .. s(p, lv))
     return false
   end
  p:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to spend " .. math.ceil((p:getVocation():getRequiredManaSpent(p:getBaseMagicLevel() + 1) - p:getManaSpent()) / configManager.getNumber(configKeys.RATE_MAGIC))  .. " mana more, for next magic level.")
return false
end

After using !exp command if the char meets the requirement for 2 it shows on screen but if 3 it skip, and if no option it gives an error..

the example is.. a Char with vip time, premium and stamina above 40hrs ..

if pp > 0 and pv > 0 and st > 2400 then
return k*(1.5+1.2) .. " (vip exp and stamina bonus) "

i get this error
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/expmana.lua:onSay
data/talkactions/scripts/expmana.lua:32: attempt to concatenate a nil value
stack traceback:
        [C]: in function '__concat'
        data/talkactions/scripts/expmana.lua:32: in function <data/talkactions/scripts/expmana.lua:1>

BUT if i remove pp > 0 letting only the rest like in here
Code:
if pv > 0 and st > 2400 then
return k*(1.5+1.2) .. " (vip exp and stamina bonus) "

the system will work, console will show now errors and in game screen i'll receive the info
Code:
22:39 Current rate: x18.9 (vip exp and stamina bonus)

i also made changes in player.lua to fit with my needs but the same.. this time i get no errors but it doesnt counts the xp in right way. If the player is premium and with stamina above 40hrs it will receive the right xp but if the char is vip, is premium and stamina above 40hrs system will not count the line and will delivery the base xp..

Code:
    -- Stamina modifier
    if configManager.getBoolean(configKeys.STAMINA_SYSTEM) then
        useStamina(self)

        local staminaMinutes = self:getStamina()
        if staminaMinutes > 2400 and self:isPremium() then
            exp = exp * 1.5
        elseif staminaMinutes <= 840 then
            exp = exp * 0.5
        elseif staminaMinutes > 2400 and self:isPremium() and self:isVip() then
            exp = exp * (1.5 + 1.2)
        elseif staminaMinutes <= 840 and self:isVip() then
            exp = exp * (0.5 + 0.2)
        elseif staminaMinutes < 2399 and staminaMinutes > 841 and self:isVip() then
            exp = exp * 1.2
        end
    end

    return exp
end

is this a system thing that doesnt accept more than two cases or what?
 
:p no else in my player.lua :p

Well im pretty sure that im doubts free cuz of you guys.. both helped and im really thankful for :D i think this thread can me marked as solved
Next time instead going all at once i'll go step-by-step also using print to see what is happening :D

Sad that i cant show how glad for being helped in here im, but well ..who knows in the future i couldnt make something for the community :p no one knows :p till there i'll keep looking for help :D and learning with ^^

Thanks RazorBlade and Lordfire
 
Glad to know :) i'll try do my best before asking for help :D to not appear such lamme :p

thanks once again :) in need i'll contact you :)

Cheers

Regards
DeCarvalho
 
Back
Top