Advertisement
Shiny_

Untitled

Aug 2nd, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. local w, h = guiGetScreenSize()
  2. local keys = {
  3.     "vehicle_right", "vehicle_left",
  4.     "vehicle_look_right", "vehicle_look_left",
  5.     "special_control_right", "special_control_left",
  6.     "left", "right",
  7. }
  8.  
  9. screenSrc = dxCreateScreenSource(w, h)
  10. renderEffect = addEventHandler("onClientPreRender", root, function()
  11.     local x, y, z, lx, ly, lz = getCameraMatrix()
  12.     x, lx, y, ly = -x, -lx, -y, -ly
  13.  
  14.     setCameraMatrix (x, y, z, lx, ly, lz)
  15.     for _, key in pairs(keys) do
  16.         bindKey(key, "both", invertedKeys)
  17.         toggleControl(key, false)
  18.     end
  19.     dxUpdateScreenSource(screenSrc)
  20.     dxDrawImage(w, 0, -w, h,screenSrc)
  21. end)
  22.  
  23. function invertedKeys(key, state)
  24.     local s, e = key:find("right") and key:find("right") or key:find("left")
  25.     local dir = key:sub(s, e)
  26.     local newkey = key:gsub(dir, (dir == "right" and "left" or "right"))
  27.     local enabledControl = (state == "down" and true or false)
  28.     setControlState(newkey, enabledControl)
  29. end
  30.  
  31. addEventHandler("onClientResourceStop", resourceRoot, function()
  32.     for _, key in pairs(keys) do
  33.         unbindKey(key, "both", invertedKeys)
  34.         toggleControl(key, true)
  35.     end
  36.     removeEventHandler("onClientHUDRender", getRootElement(), renderEffect)
  37. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement