[SOLVED] a_Player:SetNormalMaxSpeed(0)
#1
hi,

i would like to set players walk speed to 0
(players should not walk arround bevor countdown ends...),
but when i use a_Player:SetNormalMaxSpeed(0), clients camera zooms...
is it a bug or i do something wrong?

   

thx for answer
Reply
Thanks given by:
#2
That's because Minecraft changes the Field of View (FOV) depending on your speed attribute. Cuberite simply changes it and as a result Minecraft will also change the camera.If you don't want this you can try teleporting the player back once he leaves spot he's in.
Reply
Thanks given by:
#3
ok, thanks...
then its no plugin bug, but rather a feature for nowTongue
Reply
Thanks given by:
#4
Pretty much the only thing I could think of in this situation without changing the FoV is using the OnPlayerMoving hook like so:


-- Lets have a table containing names of players that cannot move
StopMove = {}

-- Also, lets assume that their name was already inserted into the table somehow

function OnPlayerMoving(Player)
    -- Search through the table as key-value format
    for _, k in pairs(StopMoving) do
        -- If the player\'s name happens to match a name in the table, stop them
        if Player:GetName() == k then
            -- Returning true means that the plugin has handled the player movement itself and the server doesn\'t have to perform any further actions
            return true
        end
    end
end

Reply
Thanks given by:
#5
@DiamondToaster: You're using an inefficient way to do this. Reorganize your StopMove table to instead be a map of PlayerName -> true for all players that are to be stopped, then it's much better:
--- Map of PlayerName -> true for all players who should not be allowed to move
StopMove = {}
 
-- Stop a player from moving:
StopMove[a_Player:GetName()] = true

-- Enable player to move again:
StopMove[a_Player:GetName()] = nil

--- The hook handler for HOOK_PLAYER_MOVING, stops specified players from moving:
function OnPlayerMoving(Player)
  if (StopMove[Player:GetName()]) then
    return true
  end
end
Reply
Thanks given by:
#6
Yeah. It's a bit of a bad habit treating them like C++ vectors. :/ Using a map and setting it to nil would definitely be better.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)