Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = guiGetScreenSize()
- local keys = {
- "vehicle_right", "vehicle_left",
- "vehicle_look_right", "vehicle_look_left",
- "special_control_right", "special_control_left",
- "left", "right",
- }
- screenSrc = dxCreateScreenSource(w, h)
- renderEffect = addEventHandler("onClientPreRender", root, function()
- local x, y, z, lx, ly, lz = getCameraMatrix()
- x, lx, y, ly = -x, -lx, -y, -ly
- setCameraMatrix (x, y, z, lx, ly, lz)
- for _, key in pairs(keys) do
- bindKey(key, "both", invertedKeys)
- toggleControl(key, false)
- end
- dxUpdateScreenSource(screenSrc)
- dxDrawImage(w, 0, -w, h,screenSrc)
- end)
- function invertedKeys(key, state)
- local s, e = key:find("right") and key:find("right") or key:find("left")
- local dir = key:sub(s, e)
- local newkey = key:gsub(dir, (dir == "right" and "left" or "right"))
- local enabledControl = (state == "down" and true or false)
- setControlState(newkey, enabledControl)
- end
- addEventHandler("onClientResourceStop", resourceRoot, function()
- for _, key in pairs(keys) do
- unbindKey(key, "both", invertedKeys)
- toggleControl(key, true)
- end
- removeEventHandler("onClientHUDRender", getRootElement(), renderEffect)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement