• 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
 
Now when the player 're level 10 is a speed 250, but I will add other levels to test and only modifies only at level 300 , the speed goes to 480 and is fixed , if I put 400 level is not going to speed 580. For what?
 
pairs doesn't use a specific order, so you can use a table for the levels.
Code:
[{10, 49}] = {speed = 250},
Then in the if statement.
Code:
newLevel >= level[1] and newLevel <= level[2]
 
an error has occurred:
Code:
data/creaturescripts/speed.lua:13: 'then' expected near 'doChangeSpeed'

I do not understand script , almost nothing ...
 
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]
            doChangeSpeed(cid, -getCreatureSpeed(cid))
            doChangeSpeed(cid, x.speed)
        end
    end
return 1
end
 
You can set a storage, then change the speed to that storagevalue in login.lua.
In the onAdvance script, under doChangeSpeed (or above, doesn't matter, should be between if and end).
Code:
doCreatureSetStorage(cid, 30029, x.speed)

Then in login.lua (somewhere between function onLogin and the last end and outside any if statement).
Code:
doChangeSpeed(cid, -getCreatureSpeed(cid))
doChangeSpeed(cid, getCreatureStorage(cid, 30029))
 
I have a friend who told me he did in lua he said he gave some mistakes in the future, he said he had a person who set the source to him ...

Change where ?
Code:
#define SPEED_MAX 1500
/\ here?

I want the speed is at the average of 450 to a level 400, but if I put SpeedMax 600 [ assuming ] when the player reaches this speed spells of running will have no effect ...
 
I have a friend who told me he did in lua he said he gave some mistakes in the future, he said he had a person who set the source to him ...

Change where ?
Code:
#define SPEED_MAX 1500
/\ here?

I want the speed is at the average of 450 to a level 400, but if I put SpeedMax 600 [ assuming ] when the player reaches this speed spells of running will have no effect ...
You literally have everything you need to get it done.
I'm assuming your 'bug' is right here though.. since you already have players on the server you'll want to check if their storage has been set in your onAdvance script, at least once.. otherwise everyone will be stuck and unmoving.

Change this in login.lua
Code:
doChangeSpeed(cid, -getCreatureSpeed(cid))
doChangeSpeed(cid, getCreatureStorage(cid, 30029))
to this
Code:
if getCreatureStorage(cid, 30029) >= 10 then
    doChangeSpeed(cid, -getCreatureSpeed(cid))
    doChangeSpeed(cid, getCreatureStorage(cid, 30029))
end

and here is the way your onAdvance script should look like right now
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
 
Where do I add ?

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

in

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

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 30)
    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 .. " Wellcome."
            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
 
Where do I add ?

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

in

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

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 30)
    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 .. " Wellcome."
            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
Code:
function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 30)
    end
<------------- RIGHT HERE :P ------------------>
    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
 
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.
 
Back
Top