Jump to content

setPedControlState problem


Recommended Posts

It doesn't make the bot jump when clearpath, jumping and isTimer is equals to false. It occurs frequently but randomly.

Inside onClientRender

  
local jumping = getPedControlState(bot, "jump") 
local clearpath = isLineOfSightClear(px, py, pz+2, x, y, z+2, true, true, false, true, false, true, false) 
            outputChatBox("Clear: " .. tostring(clearpath)) 
            outputChatBox("Jumping: " .. tostring(jumping)) 
  
if((clearpath == false) and (jumping == false) and (isTimer(jumpTimer) == false)) then 
             
                setPedAnimation(bot) 
                setPedControlState(bot, "jump", true) 
                jumpTimer = setTimer(setPedControlState, 500, 1, bot, "jump", false) 
             
            end 
  

Link to comment
  • Moderators
local clearpath = isLineOfSightClear(px, py, pz+2, x, y, z-2, true, true, false, true, false, true, false)-- -2 

ignoredElement: Allow the line of sight to pass through a certain specified element.

Link to comment
  • Moderators

timers lagg...

https://wiki.multitheftauto.com/wiki/GetTickCount

local lastTickCount = 0 
addEventHandler ( "onClientRender", root, 
    function () 
        if getTickCount() - lastTickCount > 300/getGameSpeed() then --Divided by gamespeed to reduce bugs. 
            lastTickCount = getTickCount()  
        end 
    end 
end) 

Edited by Guest
Link to comment
timers lagg...

https://wiki.multitheftauto.com/wiki/GetTickCount

local lastTickCount = 0 
addEventHandler ( "onClientRender", root, 
    function () 
        if getTickCount() - lastShotTime > 300/getGameSpeed() then --Divided by gamespeed to reduce bugs. 
            lastTickCount = getTickCount()  
        end 
    end 
end) 

Thanks a lot. I will try it and post the results.

Edit: What's the 300 for?

Link to comment
  • Moderators

You talking about tick-count from a both?

--running: 
if getTickCount() - lastTickCount > 300/getGameSpeed() then 

--not Running: 
if  getTickCount() - lastTickCount < 300/getGameSpeed() then   
--or  
if not getTickCount() - lastTickCount > 300/getGameSpeed() then 

or just an ordinary timer?

Normal timer, if the Timer ends it will be gone.

isTimer() 

Link to comment
You talking about tick-count from a both?
--running: 
if getTickCount() - lastTickCount > 300/getGameSpeed() then 

--not Running: 
if  getTickCount() - lastTickCount < 300/getGameSpeed() then   
--or  
if not getTickCount() - lastTickCount > 300/getGameSpeed() then 

or just an ordinary timer?

Normal timer, if the Timer ends it will be gone.

isTimer() 

And to start it I will use this code right?

lastjumptime = getTickCount() 

Link to comment
  • Moderators
Inside onClientRender

It is not like a real timer, your onClientRender is your timer.

getTickCount() is just a value you can use.

Every time your pc creates a render value, it request the join machine time.

This is a Sample with frames, not tickCount. But tickCount is preciser in scripting.

  
local startFrame = 0  
local frame = 0 
  
frame = frame + 1 
if frame-startFrame > 3 then --no 1 - 0 =  1 
startFrame = frame 
end 
outputChatBox(frame) --1 
--------- 
  
frame = frame + 1 
if frame-startFrame > 3 then -- no  2 - 0 =  2 
startFrame = frame 
end 
outputChatBox(frame) --2 
--------- 
  
frame = frame + 1 
if frame-startFrame > 3 then -- no   3 - 0 =  3 
startFrame = frame 
end 
outputChatBox(frame) --3 
--------- 
  
frame = frame + 1 
if frame-startFrame > 3 then -- yes!!!!!!    4 - 0 =  4 
startFrame = frame -- STARTFRAME GET FINAL HIS NEW VALUE !!!! "4" 
end 
outputChatBox(frame) --4 
--------- 

and now:

frame = frame + 1 
if frame-startFrame > 3 then -- no the som is now:  5 - 4 = -1   is -1 higher than 3? 
startFrame = frame 
end 
outputChatBox(frame .. "   " .. startFrame) --5    4 
--------- 

Edited by Guest
Link to comment
Inside onClientRender

It is not like a real timer, your onClientRender is your timer.

getTickCount() is just a value you can use.

Every time your pc creates a render value, it request the join machine time.

This is a Sample with frames, not tickCount. But tickCount is preciser in scripting.

  
local startFrame = 0  
local frame = 0 
  
frame = frame + 1 
if frame-startFrame > 3 then --no 1 - 0 =  1 
startFrame = frame 
end 
outputChatBox(frame) --1 
--------- 
  
frame = frame + 1 
if frame-startFrame > 3 then -- no  2 - 0 =  2 
startFrame = frame 
end 
outputChatBox(frame) --2 
--------- 
  
frame = frame + 1 
if frame-startFrame > 3 then -- no   3 - 0 =  3 
startFrame = frame 
end 
outputChatBox(frame) --3 
--------- 
  
frame = frame + 1 
if frame-startFrame > 3 then -- yes!!!!!!    4 - 0 =  4 
startFrame = frame 
end 
outputChatBox(frame) --4 
--------- 

and now:

frame = frame + 1 
if frame-startFrame > 3 then -- no the som is now:  5 - 4 = -3     ..  is -1 higher than 3? 
startFrame = frame 
end 
outputChatBox(frame .. "   " .. startFrame) --5    4 
--------- 

Woah thanks for the explanation. Finally understood how it works. Kudos to you.

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...