Jump to content

Something wrong?


-Doc-

Recommended Posts

Is something wrong there?

function isPlayerMoving(player) 
    return (not isPedInVehicle(player) and (getPedControlState(player, "forwards") or getPedControlState(player, "backwards") or getPedControlState(player, "aim_weapon") or getPedControlState(player, "left") or getPedControlState(player, "right") or getPedControlState(player, "accelerate") or getPedControlState(player, "brake_reverse") or getPedControlState(player, "enter_exit") or getPedControlState(player, "enter_passenger"))) 
end 
  

Link to comment

Yes

you have to do

(not isPedInVehicle(player) and getPedControlState(player, "forwards") == true) and true or (not isPedInVehicle(player) and getPedControlState(player, "backwards") == true) and true etc...

Just use that method

local controls = {"forwards","backwards","aim_weapon","left","right","accelerate","brake_reverse","enter_exit","enter_passenger"} 
function isPlayerMoving(player) 
    if not isPedInVehicle(player) then 
        for k,v in ipairs(controls) do 
            if getPedControlState(player, v) then 
                return true 
            end 
        end 
    end 
    return false 
end 

Link to comment
you have to do

(not isPedInVehicle(player) and getPedControlState(player, "forwards") == true) and true or (not isPedInVehicle(player) and getPedControlState(player, "backwards") == true) and true etc...

That's pretty incorrect. You don't have to do that.

There's nothing called incorrect, it called a proper way ...

Link to comment

1) By 'incorrect', I did not mean 'incorrect way' I mean that your statement was incorrect - you do not have to add 'and true'

2) The proper way is the most efficient way — don't add unnecessary bytes by adding redundant parts to a script. That is called being inefficient.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...