Atton Posted November 22, 2014 Posted November 22, 2014 Some time ago I made a remote control car script. It works on the client and works pretty well apart from the cam. I might make a video about it later on have fun with it. [url:1vdj4qfi]http://www.mediafire.com/download/3kcc3h71jid1djj/remotecar.lua[/url:1vdj4qfi] --[[ Made by Atton Risk in 2014 ]]-- -- Script local x,y,z = 0,0,12 local car = createVehicle(578,x,y,z) setVehicleDamageProof(car,true) local pedd = createPed(0,x,y,z+69) warpPedIntoVehicle(pedd,car) createBlipAttachedTo(car,0) setElementStreamable(car,false) setElementStreamable(pedd,false) fw = "num_8" bw = "num_2" le = "num_4" ri = "num_6" upk = "num_9" downk = "num_3" function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end function foward () if getKeyState(fw) == true then setPedControlState(pedd,"accelerate",true) end if getKeyState(fw) == false then setPedControlState(pedd,"accelerate",false) end end function back () if getKeyState(bw) == true then setPedControlState(pedd,"brake_reverse",true) end if getKeyState(bw) == false then setPedControlState(pedd,"brake_reverse",false) end end function left () if getKeyState(le) == true then setPedControlState(pedd,"vehicle_left",true) end if getKeyState(le) == false then setPedControlState(pedd,"vehicle_left",false) end end function right () if getKeyState(ri) == true then setPedControlState(pedd,"vehicle_right",true) end if getKeyState(ri) == false then setPedControlState(pedd,"vehicle_right",false) end end function up () if getKeyState(upk) == true then setPedControlState(pedd,"special_control_up",true) end if getKeyState(upk) == false then setPedControlState(pedd,"special_control_up",false) end end function down () if getKeyState(downk) == true then setPedControlState(pedd,"special_control_down",true) end if getKeyState(downk) == false then setPedControlState(pedd,"special_control_down",false) end end function cam () local offX,offY,offZ = getPositionFromElementOffset(car,0,0,1.5) local offX2,offY2,offZ2 = getPositionFromElementOffset(car,0,0,1.5) setCameraTarget(offX,offY,offZ) setCameraMatrix(offX,offY,offZ,offX2,offY2,offZ2) end function timeSystem () foward () back () right () left () up () down () -- cam () end dswitch = false function switch () if not dswitch then addEventHandler ("onClientRender", root, timeSystem) dswitch = true elseif dswitch then setCameraTarget(localPlayer) dswitch = false removeEventHandler ("onClientRender", root, timeSystem) --[[ setCameraMatrix(localPlayer) setCameraTarget(localPlayer) ]]-- end end addCommandHandler("onoff",switch) --[[ lor: #66cc66;">) then outputChatBox("row "..i.." removed") else outputChatBox("err") end end the loop is the problem, this might be the solution. Same result, but thanks. Ah, I just realised the problem. When row index 0 is deleted, index 1, 2 .. etc. are shifted upwards to 0, 1.. so the next index 1 that is being deleted is actually the original index 2, but the original index 1 never gets touched. I guess it worked that way for all the odd numbers. Tests confirmed it. Solved code: for i=0,rowCount do guiGridListRemoveRow(cart,0) end Nikola Tesla is love Nikola Tesla is light. Email: [email protected]
AJXB Posted November 22, 2014 Posted November 22, 2014 Nice, useful, good work! What's up with the last line though? ~ This has to be the worst board post I have ever read. It simply makes no sense. You start off by talking about space or something, then you randomly start babbling about cupcakes, and you end off with random fish names. ~ Don't listen to this guy, any board with the categories 'dinosaurs, spaceships, fried foods, wild animals, alien abductions, business casual, robots, and fireworks' has true potential.
Et-win Posted November 23, 2014 Posted November 23, 2014 Why not uploading to community... ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Woovie Posted November 23, 2014 Posted November 23, 2014 Since it was a single Lua, added to the OP. "The humble beet is the answer to all riddles." - Rolf
Atton Posted November 25, 2014 Author Posted November 25, 2014 It doesn't work here That is quite strange it should work, any sort of errors you can tell me of. Nikola Tesla is love Nikola Tesla is light. Email: [email protected]
Tails Posted November 25, 2014 Posted November 25, 2014 It doesn't work here That is quite strange it should work, any sort of errors you can tell me of. Yeah, forgot the /onoff switch. It's working now Discord: its.tails
Atton Posted November 28, 2014 Author Posted November 28, 2014 If anyone can come up with a fix for the cam post it here. Nikola Tesla is love Nikola Tesla is light. Email: [email protected]
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