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

marcos16

Falkhonn
Joined
May 4, 2012
Messages
224
Reaction score
1
Hello!
I am using the following script to reduce my server speed . But ... when the player moves the level he gets speed 0 , does anyone know why ?
Following is the script:

local info = {
[10] = {speed = 250},
[50] = {speed = 280},
[100] = {speed = 340},
[200] = {speed = 380},
[300] = {speed = 480},
[400] = {speed = 580}
}

function onAdvance(cid, skill, oldLevel, newLevel)
for level, x in pairs(info) do
if skill == 8 and newLevel >= level then
doChangeSpeed(cid, -getCreatureSpeed(cid))
doChangeSpeed(cid, info.speed)
end
end
return 1
end


I'm using svn Tfs 3884
 
Can you post login.lua and your onAdvance script how it looks like now?
And when exactly do you get speed 0?

For the player.h.
Code:
void updateBaseSpeed()
{
     if(!hasFlag(PlayerFlag_SetMaxSpeed))
         baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));
     else
         baseSpeed = SPEED_MAX;
}

The SPEED_MAX is the maximum speed, what gods automaticly have because of the flag.




I did the setup there , put to win 0.5. But when the player leaves and enters the speed is standard again , as if he had not set .
Like this:
Code:
void updateBaseSpeed()
{
     if(!hasFlag(PlayerFlag_SetMaxSpeed))
         baseSpeed = vocation->getBaseSpeed() + (0.5 * (level - 0.3));
     else
         baseSpeed = SPEED_MAX;
}

What may have given wrong?
 
For the Lua script parts post your login.lua and the onAdvance script with the changes, if you want to make changes in the source you have to compile it to create a new .exe.
 
I have compiled , I added the level and won 1 speed every 1 level . 0.5 + 0.5 = 1.
But when the player leaves and enters the speed is like winning pattern if he had 2 speed every level . [How was happening in the script ]

login.lua
Code:
local config = {
    loginMessage = getConfigValue('loginMessage')
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 30)
    end

    if getCreatureStorage(cid, 30029) >= 10 then
            doChangeSpeed(cid, -getCreatureSpeed(cid))
            doChangeSpeed(cid, getCreatureStorage(cid, 30029))
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Sua última visita foi em " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Escolha sua roupa."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "Frags")
    registerCreatureEvent(cid, "ProtectLevel")
    registerCreatureEvent(cid, "SkullCheck")
    registerCreatureEvent(cid, "ReportBug")
        registerCreatureEvent(cid, "repKill") 
        registerCreatureEvent(cid, "repLook") 
        registerCreatureEvent(cid, "repMonster")
    registerCreatureEvent(cid, "hmup")
    registerCreatureEvent(cid, "VocationsGain")
    registerCreatureEvent(cid, "FirstItems")
    registerCreatureEvent(cid, "Outfit")
    registerCreatureEvent(cid, "Out")
    registerCreatureEvent(cid, "Recompensa")
    registerCreatureEvent(cid, "Death")
    registerCreatureEvent(cid, "Firstitems")
    registerCreatureEvent(cid, "gainpa")
    registerCreatureEvent(cid, "KillProtection")
    registerCreatureEvent(cid, "SpeedLevel")

    return true
end

script:
Code:
local info = {
[{10, 49}] = {speed = 250},
[{50, 100}] = {speed = 300},
[{101, 149}] = {speed = 350},
[{150, 249}] = {speed = 400},
[{250, 300}] = {speed = 450},
[{301, 400}] = {speed = 500}
}

function onAdvance(cid, skill, oldLevel, newLevel)
    for level, x in pairs(info) do
        if skill == 8 and newLevel >= level[1] and newLevel <= level[2] then
            doChangeSpeed(cid, -getCreatureSpeed(cid))
            doCreatureSetStorage(cid, 30029, x.speed)
        end
    end
return 1
end
 
The doChangeSpeed(cid, x.speed) is missing in the onAdvance script.
Code:
local info = {
     [{10, 49}] = {speed = 250},
     [{50, 100}] = {speed = 300},
     [{101, 149}] = {speed = 350},
     [{150, 249}] = {speed = 400},
     [{250, 300}] = {speed = 450},
     [{301, 400}] = {speed = 500}
}

function onAdvance(cid, skill, oldLevel, newLevel)
     for level, x in pairs(info) do
         if skill == 8 and newLevel >= level[1] and newLevel <= level[2] then
             doChangeSpeed(cid, -getCreatureSpeed(cid))
             doChangeSpeed(cid, x.speed)
             doCreatureSetStorage(cid, 30029, x.speed)
         end
     end
     return true
end
 
Now it worked. But when regresses the level not back pro speed of the new level x .
Ex:
I am level 301 Speed 500 .
Die back to level 299, the 500 Speed still only back to 450 when speed level up to 300 , knowing that the speed is 500 to level 301-400 .
But just okay .
Thank you very much!
 
Instead of using storage, you could also add the table and the script part inside function onAdvance in login.lua and remove the skill == 8 and instead of newLevel use getPlayerLevel(cid).
 
I set speed item in the player [level 310 - speed 500 + 40 [speed of boh] = 540.
I leave and enter the player's speed back to 500.
When I remove the boh the speed is 460.

Why ?


I was willing to pay premium .
The OTLand team helps a lot.
Note: I am Brazilian
 
I set speed item in the player [level 310 - speed 500 + 40 [speed of boh] = 540.
I leave and enter the player's speed back to 500.
When I remove the boh the speed is 460.

Why ?
Knowing your nationality is frivolous information.
It bears no semblance on our perception of you, however it does make me question your sanity. :(

@topic

The problem is an oversight, as I didn't think about speed items when calculating the players speed.
An easy fix.

login.lua
Code:
if getCreatureStorage(cid, 30029) >= 10 then
     doChangeSpeed(cid, -getCreatureSpeed(cid))
     doChangeSpeed(cid, getCreatureStorage(cid, 30029))
end
change
Code:
if getCreatureStorage(cid, 30029) >= 10 then
     doChangeSpeed(cid, -getCreatureBaseSpeed(cid))
     doChangeSpeed(cid, getCreatureStorage(cid, 30029))
end
 
It worked, thanks.

I said I'm Brazilian due to the dollar price . But that is beside the point.

I'll stop commenting on the topic since been resolved , soon makes libro with so many of my comments.

Again thanks to two. :p
 
Back
Top