mateplays Posted December 21, 2020 Share Posted December 21, 2020 Hey guys. I have a script where I want to draw text inside a "for" loop, and every row after the first one will vibrate. Have a look: Here is the code for this tab (only this tab vibrates): dxDrawText("#ffffffBarátok", sx/2-825/2+300, sy/2-410/2,sx/2-825/2+530, sy/2-410/2 ,tocolor(69,182,254,255), 0.9, RobotoLSized, "center", "center", false, false, false, true) triggerServerEvent("loadFriends",localPlayer,localPlayer, getElementData(localPlayer, "acc:id")) counter = getElementData(localPlayer, "friendCount") if hasElementData(localPlayer, "friendCount") then if (getElementData(localPlayer, "friendCount") > scrollData and counter < maxShow) then for i=1, counter do friendOG = tostring(getElementData(localPlayer, "friends"..i)) friendLegit = exports.rob_core:findPlayer(localPlayer, friendOG) dxDrawRectangle(sx/2-825/2,sy/2-515/2+(i*65), 825, 40, tocolor(0,0,0,220)) if friendLegit then dxDrawText(getPlayerName(friendLegit) .. " (ID: #45b6fe" .. getElementData(friendLegit, "playerid") .. "#ffffff)", sx/2-825/2+5+22,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) else if not (getElementData(localPlayer, "friendName"..i) == false) then dxDrawText(tostring(getElementData(localPlayer, "friendName"..i)), sx/2-825/2+5+22,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) end end if tonumber(getElementData(localPlayer, "friendOnline"..i) == 1) then isHeOnline = "igen" else isHeOnline = "nem" end if not (getElementData(localPlayer, "friendOnline"..i) == false) then dxDrawText("Online: #45b6fe"..tostring(isHeOnline), sx/2-825/2+5+41+120,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) end if not (getElementData(localPlayer, "friendLastLogin"..i) == false) then dxDrawText("Legutóbb online: #45b6fe" .. tostring(getElementData(localPlayer, "friendLastLogin"..i)), sx/2-825/2+5+41+225,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) end if not (getElementData(localPlayer, "friendLastLogin"..i) == false) then if isInSlot(sx/2+330, sy/2-515/2+(i*65)+7, 65,25) then dxDrawRectangle(sx/2+330, sy/2-515/2+(i*65)+7, 65,25, tocolor(215, 89, 89, 200)) else dxDrawRectangle(sx/2+330, sy/2-515/2+(i*65)+7, 65,25, tocolor(215, 89, 89, 150)) end dxDrawText("Törlés", sx/2+330, sy/2-515/2+(i*65)+7, sx/2+330+65, sy/2-515/2+(i*65)+7+25, tocolor(0,0,0,200), 1, Roboto, "center", "center") end if not (getElementData(localPlayer, "friendLastLogin"..i) == false) then if isInSlot(sx/2+250, sy/2-515/2+(i*65)+7, 65,25) then dxDrawRectangle(sx/2+250, sy/2-515/2+(i*65)+7, 65,25, tocolor(69,182,254, 200)) else dxDrawRectangle(sx/2+250, sy/2-515/2+(i*65)+7, 65,25, tocolor(69,182,254, 150)) end dxDrawText("Meghívás", sx/2+250, sy/2-515/2+(i*65)+7, sx/2+250+65, sy/2-515/2+(i*65)+7+25, tocolor(0,0,0,200), 1, Roboto, "center", "center") end end end end if isInSlot(sx/2-830/2, sy/2+470/2, 830,25) then dxDrawRectangle(sx/2-830/2, sy/2+470/2, 830,25, tocolor(69, 182, 254, 200)) else dxDrawRectangle(sx/2-830/2, sy/2+470/2, 830,25, tocolor(69, 182, 254, 150)) end dxDrawText("Új barát hozzáadása", sx/2+1/2, sy/2+500/2,sx/2+1/2, sy/2+500/2, tocolor(0,0,0,200), 1, Roboto, "center", "center") Please, if you can, help me. Link to comment
HiroShi Posted December 24, 2020 Share Posted December 24, 2020 On 21/12/2020 at 11:46, mateplays said: Hey guys. I have a script where I want to draw text inside a "for" loop, and every row after the first one will vibrate. Have a look: Here is the code for this tab (only this tab vibrates): dxDrawText("#ffffffBarátok", sx/2-825/2+300, sy/2-410/2,sx/2-825/2+530, sy/2-410/2 ,tocolor(69,182,254,255), 0.9, RobotoLSized, "center", "center", false, false, false, true) triggerServerEvent("loadFriends",localPlayer,localPlayer, getElementData(localPlayer, "acc:id")) counter = getElementData(localPlayer, "friendCount") if hasElementData(localPlayer, "friendCount") then if (getElementData(localPlayer, "friendCount") > scrollData and counter < maxShow) then for i=1, counter do friendOG = tostring(getElementData(localPlayer, "friends"..i)) friendLegit = exports.rob_core:findPlayer(localPlayer, friendOG) dxDrawRectangle(sx/2-825/2,sy/2-515/2+(i*65), 825, 40, tocolor(0,0,0,220)) if friendLegit then dxDrawText(getPlayerName(friendLegit) .. " (ID: #45b6fe" .. getElementData(friendLegit, "playerid") .. "#ffffff)", sx/2-825/2+5+22,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) else if not (getElementData(localPlayer, "friendName"..i) == false) then dxDrawText(tostring(getElementData(localPlayer, "friendName"..i)), sx/2-825/2+5+22,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) end end if tonumber(getElementData(localPlayer, "friendOnline"..i) == 1) then isHeOnline = "igen" else isHeOnline = "nem" end if not (getElementData(localPlayer, "friendOnline"..i) == false) then dxDrawText("Online: #45b6fe"..tostring(isHeOnline), sx/2-825/2+5+41+120,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) end if not (getElementData(localPlayer, "friendLastLogin"..i) == false) then dxDrawText("Legutóbb online: #45b6fe" .. tostring(getElementData(localPlayer, "friendLastLogin"..i)), sx/2-825/2+5+41+225,sy/2-515/2+(i*65)+2, 0, sy/2-515/2+(i*65)+2+36, tocolor(255,255,255,255), 1, Roboto, "left", "center",false,false,false,true) end if not (getElementData(localPlayer, "friendLastLogin"..i) == false) then if isInSlot(sx/2+330, sy/2-515/2+(i*65)+7, 65,25) then dxDrawRectangle(sx/2+330, sy/2-515/2+(i*65)+7, 65,25, tocolor(215, 89, 89, 200)) else dxDrawRectangle(sx/2+330, sy/2-515/2+(i*65)+7, 65,25, tocolor(215, 89, 89, 150)) end dxDrawText("Törlés", sx/2+330, sy/2-515/2+(i*65)+7, sx/2+330+65, sy/2-515/2+(i*65)+7+25, tocolor(0,0,0,200), 1, Roboto, "center", "center") end if not (getElementData(localPlayer, "friendLastLogin"..i) == false) then if isInSlot(sx/2+250, sy/2-515/2+(i*65)+7, 65,25) then dxDrawRectangle(sx/2+250, sy/2-515/2+(i*65)+7, 65,25, tocolor(69,182,254, 200)) else dxDrawRectangle(sx/2+250, sy/2-515/2+(i*65)+7, 65,25, tocolor(69,182,254, 150)) end dxDrawText("Meghívás", sx/2+250, sy/2-515/2+(i*65)+7, sx/2+250+65, sy/2-515/2+(i*65)+7+25, tocolor(0,0,0,200), 1, Roboto, "center", "center") end end end end if isInSlot(sx/2-830/2, sy/2+470/2, 830,25) then dxDrawRectangle(sx/2-830/2, sy/2+470/2, 830,25, tocolor(69, 182, 254, 200)) else dxDrawRectangle(sx/2-830/2, sy/2+470/2, 830,25, tocolor(69, 182, 254, 150)) end dxDrawText("Új barát hozzáadása", sx/2+1/2, sy/2+500/2,sx/2+1/2, sy/2+500/2, tocolor(0,0,0,200), 1, Roboto, "center", "center") Please, if you can, help me. Take out your scroll method, and test it to see it. Link to comment
mateplays Posted December 24, 2020 Author Share Posted December 24, 2020 Got it to work, thread can be closed. The problem was, that I was using a triggerServerEvent function in the "onClientRender" event, and every time the client rendered, the friend list got loaded: triggerServerEvent("loadFriends",localPlayer,localPlayer, getElementData(localPlayer, "acc:id")) Link to comment
Recommended Posts