Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local infoBar = {};
- local isShowing = false;
- local sx, sy = guiGetScreenSize();
- local bgColor = tocolor(0, 0, 0, 180); -- DRY
- local dc = tocolor(255, 0, 0);
- local dc2 = tocolor(0, 255, 0);
- local dc3 = tocolor(0, 0, 255);
- -- Testing only
- local title = "There is an interactable object";
- function drawInfoBar()
- -- Draw the background
- dxDrawRectangle( (sx/2)-180, 0, 360, 50, bgColor );
- -- Draw the title
- local width = dxGetTextWidth( infoBar.text, 1.2 );
- dxDrawText( infoBar.text, (sx/2)-(width/2), 12, sx, sy, tocolor(255, 255, 255), 1.2 );
- end
- function toggleInfoBar(text)
- text = text or "";
- if isShowing then
- local result = removeEventHandler("onClientRender", getRootElement(), drawInfoBar);
- if result then
- infoBar = {};
- isShowing = false;
- end
- else
- infoBar = {
- text = text,
- };
- local result = addEventHandler("onClientRender", getRootElement(), drawInfoBar);
- if result then
- isShowing = true;
- end
- end
- end
- addCommandHandler("testbar",
- function()
- toggleInfoBar("Press 'B' to interact with this object!");
- end
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement