Cuberite Forum
[SOLVED] a_Player:SetNormalMaxSpeed(0) - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: [SOLVED] a_Player:SetNormalMaxSpeed(0) (/thread-2203.html)



[SOLVED] a_Player:SetNormalMaxSpeed(0) - heroldini - 11-09-2015

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


RE: a_Player:SetNormalMaxSpeed(0) - NiLSPACE - 11-09-2015

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.


RE: a_Player:SetNormalMaxSpeed(0) - heroldini - 11-09-2015

ok, thanks...
then its no plugin bug, but rather a feature for nowTongue


RE: [SOLVED] a_Player:SetNormalMaxSpeed(0) - DiamondToaster - 11-10-2015

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




RE: [SOLVED] a_Player:SetNormalMaxSpeed(0) - xoft - 11-11-2015

@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



RE: [SOLVED] a_Player:SetNormalMaxSpeed(0) - DiamondToaster - 11-11-2015

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.