Search the Community
Showing results for tags 'size'.
-
I've been working on a script that realistically manipulates the wheels. I've gotten to the point I can hide the original wheels, in hopes I can later attach a new set in the same place. I'm aware I might have to use attachElements, and several other functions. For the moment, I'd like to attach a single wheel. I've got this: -- All GUI elements. local vehicle = getPedOccupiedVehicle(localPlayer) local x1, y1, z1 = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local x2, y2, z2 = getVehicleComponentPosition(vehicle, "wheel_rf_dummy") local x3, y3, z3 = getVehicleComponentPosition(vehicle, "wheel_lb_dummy") local x4, y4, z4 = getVehicleComponentPosition(vehicle, "wheel_rb_dummy") local function replace1 () attachElements (1097, vehicle, x1, y2, z1, 0, 0, 0) end addEventHandler ("onClientGUIClick", set1, replace1, false) -- Function runs when button called 'set1' is clicked. -- Everything else. Here's my thought process: First, I get the player's vehicle. Then, I get the position of all four wheels in the player's vehicle, and represent them with x1, y1 and z1. With all wheels hidden by another function, I then attach the wheel model in the same place as the front left wheel. At the moment, I'm only aiming at the position; I'll handle the rotation later. DB 3 can't identify '1097', and thus asks for a valid element. Am I on the right path?
-
Author and editor of Ilnaz Isangulov DxCreateDiagram Client-only function Draws an diargam on the screen for a single frame. In order for the diagram to stay visible continuously, you need to call this function with the same parameters on each frame update (see onClientRender). Syntax bool dxCreateDiagram (float N, float posX, float posY, float cleanWidth, int color = tocolor(255,255,255,255), float scaleXY = 1, bool postGUI = false) Required Arguments N: changing parameter, for example speed posX: the absolute X coordinate of the top left corner of the image posY: the absolute Y coordinate of the top left corner of the image cleanWidth: the width at which it will be cleaned and updated Optional Arguments color: Tints the image with a value produced by tocolor or hexadecimal number in format: 0xAARRGGBB (RR = red, GG = green, BB = blue, AA = alpha). postGUI: A bool representing whether the image should be drawn on top of or behind any ingame GUI (rendered by CEGUI). Example Example of a pendulum swinging from the top of the screen, made using dxDrawImage. local screenWidth,screenHeight = guiGetScreenSize() -- Get screen resolution. function renderDisplay ( ) dxCreateDiagram ( math.random ( 0, 200 ), 0, screenHeight / , , tocolor ( 255, 0, 255, 255 ) , 1, false ) end addEventHandler("onClientRender", root, renderDisplay) -- Keep everything visible with onClientRender. Author and editor of Ilnaz Isangulov This is required in the code! local dataTable = {} local zOld = 0 function dxCreateDiagram(N,x,y,cleanSize,color,size,gui) local _,h = guiGetScreenSize() local x = x or 0 local y = y or h/2 local N = N or 0 local cleanSize = cleanSize or h/2 local color = color or tocolor(255, 255, 255, 255) local size = size or 1 local gui = gui or false local izmen = (N-zOld) table.insert( dataTable, izmen) for i, z in pairs(dataTable) do local x3 = dataTable[i+1] or 1 local x2 = dataTable[i] or 1 if i >= cleanSize then for f,_ in pairs(dataTable) do table.remove(dataTable, f) end end dxDrawLine(x+(i-1), y+1-x2, x+i, y+1-x3, color,size,gui) end end Author and editor of Ilnaz Isangulov
-
Hello Community! Due to the development of SUI's memobox, I've been asking myself what's the space that wordBreak generates between dxDrawText's lines. So if anyone knows that information, let me know please. Thanks, Simple01.
-
- dxdrawtext
- wordbreak
-
(and 1 more)
Tagged with:
-
Hi all, could you tell me how to make a dynamic installation of interface sizes depending on the size of the user's screen? Code: function guiCreateMainMenu() local sWidth,sHeight = guiGetScreenSize() local localPlayerName = getPlayerName(getLocalPlayer()) mainMenuSound() menu = guiCreateStaticImage( 0, 0, sWidth, sHeight, "img/screen_shadow.png", false ) userImg = guiCreateStaticImage( sWidth/2.8, 0, sWidth/1.5, sHeight/1.5, "img/user.png", false, menu ) menuBg = guiCreateStaticImage( sWidth/7, sHeight/8.07692, sWidth/1.4, sHeight/17, "img/bg.png", false, menu ) menuFg = guiCreateStaticImage( sWidth/7, sHeight/8.07692, sWidth/1.4, sHeight/17, "img/fg.png", false, menu ) usernameLabel = guiCreateLabel( sWidth/2434.78260, sHeight/14000, 1, 1, localPlayerName, true, userImg) --24 символа макс. userNameFont = guiCreateFont( "fonts/calibri.ttf", 16 ) guiSetFont ( usernameLabel, userNameFont ) menuMainLabel = guiCreateLabel( sWidth/8400, sHeight/11666.66666, 1, 1, "*Главное меню*", true, menu) mainMenuFont = guiCreateFont( "fonts/carbon.ttf", 32 ) guiSetFont ( menuMainLabel, mainMenuFont ) carrierBtn = guiCreateLabel( (0.12/1680)*sWidth, 0.341, 1, 1, "КАРЬЕРА", true, menuFg) carrierBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( carrierBtn, carrierBtnFont ) carrierButton = guiCreateStaticImage( 385, 154, 80, 13, "img/btn.png", false, menu ) statBtn = guiCreateLabel( 0.2, 0.341, 1, 1, "СТАТИСТИКА", true, menuFg) statBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( statBtn, statBtnFont ) statButton = guiCreateStaticImage( 481, 154, 111, 13, "img/btn.png", false, menu ) achBtn = guiCreateLabel( 0.313, 0.341, 1, 1, "ДОСТИЖЕНИЯ", true, menuFg) achBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( achBtn, achBtnFont ) achButton = guiCreateStaticImage( 615, 154, 121, 13, "img/btn.png", false, menu ) bestBtn = guiCreateLabel( 0.432, 0.341, 1, 1, "ТОП ЛУЧШИХ ИГРОКОВ", true, menuFg) bestBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( bestBtn, bestBtnFont ) bestButton = guiCreateStaticImage( 758, 154, 198, 13, "img/btn.png", false, menu ) settingsBtn = guiCreateLabel( 0.616, 0.341, 1, 1, "НАСТРОЙКИ", true, menuFg) settingsBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( settingsBtn, settingsBtnFont ) settingsButton = guiCreateStaticImage( 980, 154, 101, 13, "img/btn.png", false, menu ) newsBtn = guiCreateLabel( 0.720, 0.341, 1, 1, "НОВОСТИ", true, menuFg) newsBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( newsBtn, newsBtnFont ) newsButton = guiCreateStaticImage( 1106, 154, 78, 13, "img/btn.png", false, menu ) aboutBtn = guiCreateLabel( 0.810, 0.341, 1, 1, "О СЕРВЕРЕ", true, menuFg) aboutBtnFont = guiCreateFont( "fonts/calibri.ttf", 15 ) guiSetFont ( aboutBtn, aboutBtnFont ) aboutButton = guiCreateStaticImage( 1213, 154, 87, 13, "img/btn.png", false, menu ) showCursor(true) showChat(false) setPlayerHudComponentVisible("all", false) end
-
this is the code: and the problem: if i'm far away then the dx elements will be bigger, and when i'm closer.. how to fix this?
-
createColRectangle I have a question, i can resize the zone using variables or an event like onColShapeHit ?
-
In 1440x900 resolution, the dx elements they are in the right place, but in 1920x1080 the dx elements move up, and in 1366x768 the dx elements move down.. Why? how to fix this? the guigetscreensize is added with the correct coordinates..
-
Heyo, so recently I got an awesome toptimes resource from a friend and today I fixed the positions of all elements drawn with dxDraw so that the toptimes window doesn't go outside of screen boundary on any resolution. So far, so good. But there is one problem, I don't know how to fix the elements' size to be same for all resolutions. I tried with something like " local x_,y_ = x/1680,y/1080 " and put " *y_ " after the size but it still looks ugly, also tried more combinations such as " x/1440,y/900 " and so on, to no success. Below is just the function which draws the F5 tops window, I always had trouble with fixing the size and here i am again, same problem...for the Nth time. Any help is appreciated. sX,sY = guiGetScreenSize() function drawToptimesIntreface() local x,y = guiGetScreenSize() if toptimes.animState == "closed" then local tick = getTickCount() - toptimes.tick local progress = tick/1000 toptimes.anim = interpolateBetween(0,0,0,390,0,0,progress,"OutBack") else local tick = getTickCount() - toptimes.tick local progress = tick/1000 toptimes.anim = interpolateBetween(390,0,0,0,0,0,progress,"InBack") end local clanColor = tocolor(255, 205, 0, 255) -- Clan Color local titleColor = tocolor(0, 255, 255, 255) -- Toptimes Title local displayColor = tocolor(0, 0, 0, 150) -- Toptimes Blackground if toptimes.state then local sY = sY-toptimes.anim*1.2 dxDrawRectangle(sX-x*0.4354166666666667, (sY/2)-y*0.5, x*0.1979166666666667, y*0.0231481481481481, clanColor) dxDrawText("Toptimes - "..toptimes.mapname, sX-x*0.6713541666666667, (sY/2)-y*0.8509259259259259,sX-x*0.0046875, (sY/2)-y*0.1240740740740741, tocolor(0,0,0,255), 1, "default-bold","center","center",true) dxDrawText("Toptimes - "..toptimes.mapname, sX-x*0.671875, (sY/2)-y*0.8518518518518519, sX-x*0.0052083333333333, (sY/2)-y*0.125, titleColor, 1, "default-bold", "center","center",true) dxDrawRectangle(sX-x*0.4354166666666667, (sY/2)-y*0.4768518518518519, x*0.1979166666666667, y*0.1666666666666667, displayColor) for i=1,9 do -- Show when player have toptime in any map dxDrawRectangle(sX-x*0.4354166666666667, (sY/2)+((i-1)*20)-y*0.4759259259259259, x*0.1979166666666667, y*0.017022792022792, tocolor(255,255,255,toptimes.color[i])) end for i=1,9 do -- Shadow dxDrawText(i..". "..removeColorCoding(toptimes.label[i]), sX-x*0.4310416666666667, (sY/2)+((i-1)*20)-y*0.8277777777777778, sX-x*0.0244791666666667, (sY/2)+((i)*20)-y*0.1240740740740741, tocolor(0,0,0,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.time[i], sX-x*0.3132291666666667, (sY/2)+((i-1)*20)-y*0.8277777777777778, sX-x*0.0244791666666667, (sY/2)+((i)*20)-y*0.1240740740740741, tocolor(0,0,0,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.data[i], sX-x*0.2744791666666667, (sY/2)+((i-1)*20)-y*0.8277777777777778, sX-x*0.0244791666666667, (sY/2)+((i)*20)-y*0.1240740740740741, tocolor(0,0,0,255), 1, "default-bold","left","center",true,false,false,true) -- dxDrawText(i..". "..toptimes.label[i], sX-x*0.4315625, (sY/2)+((i-1)*20)-y*0.8287037037037037, sX-x*0.025, (sY/2)+((i)*20)-y*0.125, tocolor(255,255,255,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.time[i], sX-x*0.31375, (sY/2)+((i-1)*20)-y*0.8287037037037037, sX-x*0.025, (sY/2)+((i)*20)-y*0.125, tocolor(255,255,255,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.data[i], sX-x*0.275, (sY/2)+((i-1)*20)-y*0.8287037037037037, sX-x*0.025, (sY/2)+((i)*20)-y*0.125, tocolor(255,255,255,255), 1, "default-bold","left","center",true,false,false,true) if toptimes.country[i] ~= "" then if fileExists(":admin/client/images/flags/"..toptimes.country[i]..".png") then dxDrawImage(sX-x*0.4227083333333333, (sY/2)+((i-1)*20)-y*0.4731481481481481, x*0.0083333333333333, y*0.0101851851851852, ":admin/client/images/flags/"..toptimes.country[i]..".png", tocolor(255,255,255,255)) end else if fileExists(":admin/client/images/flags/gtasa.png") then dxDrawImage(sX-x*0.4227083333333333, (sY/2)+((i-1)*20)-y*0.4731481481481481, x*0.0083333333333333, y*0.0101851851851852, ":admin/client/images/flags/gtasa.png", tocolor(255,255,255,255)) end end end if toptimes.personal[1] then dxDrawRectangle(sX-x*0.4354166666666667, (sY/2)-y*0.3101851851851852, x*0.1979166666666667, y*0.017592592592596, displayColor) dxDrawRectangle(sX-x*0.4354166666666667, (sY/2)-y*0.3089506172839506, x*0.1979166666666667, y*0.0166666666666667, tocolor(255,255,255,100)) -- Shadow dxDrawText(""..toptimes.personal.pos..". "..toptimes.personal.spacement..removeColorCoding(toptimes.personal.name), sX-x*0.4341666666666667, (sY/2)-y*0.6673611111111111, sX-x*0.0244791666666667, (sY/2)+y*0.0668981481481481, tocolor(0,0,0,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.personal.time, sX-x*0.3132291666666667, (sY/2)-y*0.6645833333333333, sX-x*0.0244791666666667, (sY/2)+y*0.0641203703703704, tocolor(0,0,0,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.personal.data, sX-x*0.2744791666666667, (sY/2)-y*0.6645833333333333, sX-x*0.0244791666666667, (sY/2)+y*0.0641203703703704, tocolor(0,0,0,255), 1, "default-bold","left","center",true,false,false,true) -- dxDrawText(""..toptimes.personal.pos..". "..toptimes.personal.spacement..toptimes.personal.name, sX-x*0.4346875, (sY/2)-y*0.668287037037037, sX-x*0.025, (sY/2)+y*0.0659722222222222, tocolor(255,255,255,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.personal.time, sX-x*0.31375, (sY/2)-y*0.6655092592592593, sX-x*0.025, (sY/2)+y*0.0631944444444444, tocolor(255,255,255,255), 1, "default-bold","left","center",true,false,false,true) dxDrawText(toptimes.personal.data, sX-x*0.275, (sY/2)-y*0.6655092592592593, sX-x*0.025, (sY/2)+y*0.0631944444444444, tocolor(255,255,255,255), 1, "default-bold","left","center",true,false,false,true) if toptimes.personal.country ~= "" then if fileExists(":admin/client/images/flags/"..toptimes.personal.country..".png") then dxDrawImage(sX-x*0.4227083333333333, (sY/2)-y*0.30625, x*0.0083333333333333, y*0.0101851851851852, ":admin/client/images/flags/"..toptimes.personal.country..".png", tocolor(255,255,255,255)) end else if fileExists(":admin/client/images/flags/gtasa.png") then dxDrawImage(sX-x*0.4227083333333333, (sY/2)-y*0.30625, x*0.0083333333333333, y*0.0101851851851852, ":admin/client/images/flags/gtasa.png", tocolor(255,255,255,255)) end end end end end addEventHandler("onClientRender",getRootElement(),drawToptimesIntreface) This is how it should look like, on any screen :
- 8 replies
-
- text
- rectangles
-
(and 6 more)
Tagged with: