Cassandra Posted March 1, 2013 Posted March 1, 2013 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
Moderators IIYAMA Posted March 1, 2013 Moderators Posted March 1, 2013 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.
Cassandra Posted March 1, 2013 Author Posted March 1, 2013 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. I don't understand.
Moderators IIYAMA Posted March 1, 2013 Moderators Posted March 1, 2013 getElementPosition = middle of the ped (0) The distances from the body (middle of the ped) is circa 0.6. (depends how long this ped is) The lines starts 1.4 a both the head of the ped.
Cassandra Posted March 1, 2013 Author Posted March 1, 2013 Well thanks for that. How can I fix the timer problem?
Moderators IIYAMA Posted March 1, 2013 Moderators Posted March 1, 2013 (edited) 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 March 1, 2013 by Guest
Cassandra Posted March 1, 2013 Author Posted March 1, 2013 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?
Moderators IIYAMA Posted March 1, 2013 Moderators Posted March 1, 2013 made a mistake, updated. 300 milliseconds It means it can only executed every 300 milliseconds.
Cassandra Posted March 1, 2013 Author Posted March 1, 2013 Gotcha. How would I go about checking if the timer is running or not?
Moderators IIYAMA Posted March 2, 2013 Moderators Posted March 2, 2013 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()
Cassandra Posted March 2, 2013 Author Posted March 2, 2013 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()
Moderators IIYAMA Posted March 2, 2013 Moderators Posted March 2, 2013 (edited) 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 March 2, 2013 by Guest
Cassandra Posted March 2, 2013 Author Posted March 2, 2013 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.
Moderators IIYAMA Posted March 2, 2013 Moderators Posted March 2, 2013 I updated the sample a little bit.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now