• 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.X+ How to increase player speed using changeSpeed() method

super23

Member
Joined
Dec 27, 2013
Messages
98
Reaction score
5
I am trying to increase player speed by 1 speed unit using an item. But it doesnot produce the expected results.
I have tried printing out getSpeed and getBaseSpeed but those gave large numbers such as: 393478143.

There is no documentation about changeSpeed in TFS 1.x documentation on github.

How can I increase player speed by 1 unit each time the item is used?

What i've tried so far:
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:isPlayer() then
        print(tostring(player:getSpeed()))
        player:changeSpeed(player:getBaseSpeed() + 1)
    end
    return true
end
 
changeSpeed works by adding delta to your base speed.
All you need to do is use player:changeSpeed(1), that will add +1 to the base speed, -1 would remove 1.
You also don't need to check for player:isPlayer(), nothing but a player can use an item, so you don't need to check if the user is a player type.
 
changeSpeed works by adding delta to your base speed.
All you need to do is use player:changeSpeed(1), that will add +1 to the base speed, -1 would remove 1.
You also don't need to check for player:isPlayer(), nothing but a player can use an item, so you don't need to check if the user is a player type.

changeSpeed(1) didnt add 1 speed when used once. 2 uses gave 1 speed.
 
The value in the client gets divided by 2, if you expect your speed to increase by 1 in the character stats, use changeSpeed(2).
 
Solution
Back
Top