Jump to content

Overkillz

Members
  • Posts

    545
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Overkillz

  1. NOT TESTED I just build my own method due to I don't feel confortable with your way. Here you have local showImage = 1 local switchTick = getTickCount() local interval = 3000 --Image duration (Including fade) local images = { {path = "image1", alpha = 0}, {path = "image2", alpha = 0}, {path = "image3", alpha = 0}, {path = "image4", alpha = 0}, } function drawImages() if getTickCount() - switchTick > interval then showImage = showImage + 1 if showImage > #images then showImage = 1 end switchTick = getTickCount() end for i,k in ipairs(images) do if i == showImage then k.alpha = math.min(k.alpha+30,255) else k.alpha = math.max(k.alpha-30,0) end if k.alpha > 0 then --This will AVOID to draw not visible images (CPU USAGE REDUCTION) dxDrawImage(0,0,500,500,k.path,0,0,0,tocolor(255,255,255,k.alpha)) end end end addEventHandler("onClientRender",root,drawImages)
  2. Alright, thats the other way I supposed to use. However, whats the efficence of using that way ? Is there another efficent way? (Not adding all the content in the same file) Thanks in advance and best regards.
  3. Hello dear community, First of all, I know that i can solve my problem with a simple trigger, but Im a bit curious and I would like to know why this is not working or which one is the best way to call it. Well, I have done a template to use it multiple times in the same resource but just changing a variable, so, some of them uses the same fucntion name but i just used local (This should prevent interaction issues) So I realized the is only executed the last one added in meta.xml I know that Im explaining very very bad, but I have done an example that it understable (I think so) --## META.XML <script src="file1.lua" type="client" cache="false" /> <script src="file2.lua" type="client" cache="false" /> <script src="file3.lua" type="client" cache="false" /> --THE LAST ONE IS ONLY EXECUTED --## MAIN FILE showContent(1) --THIS WONT WORK showContent(2) --THIS WONT WORK showContent(3) --WORKING DUE TO IS THE LAST ONE IN META.XML --## 1ST FILE local fileID = 1 local function sayHI() outputChatBox("HI WORLD FROM FILE 1") end function showContent(id) if fileID == id then sayHI() end end --## 2ND FILE local fileID = 2 local function sayHI() outputChatBox("HI WORLD FROM FILE 2") end function showContent(id) if fileID == id then sayHI() end end --## 3RD FILE local fileID = 3 local function sayHI() outputChatBox("HI WORLD FROM FILE 3") end function showContent(id) if fileID == id then sayHI() end end I hope you can bring me a hand with this simple doubt. Thanks for reading, best regards.
  4. @IIYAMA Thanks for your suggestion, but, Im not going to reach the effect that Im looking for cuz I think the effect will be notable and not fancy while reaching the corners and the effect im looking for is that a circle over draw the "Rounded rectangle" I think i have explained pretty bad so I just made a quicky image to take it as reference. As you can see, some parts of the circle already left the rectangle (It won't be visible). Otherwise, is there a way to load .svg on MTA ? Thanks in advance, best regards.
  5. Hello dear community, I would like to ask if there is a way to limit the draw size to a texture ? What do I mean, well, I have a texture (A rectangle with rounded corners) well, I want to create an animation. A circle that becomes to a rectangle with BORDER CORNERS I think I luckily did this script like 4 years ago, but no idea how I did it (I know trat it sounds absurd.) If im not wrong, I used a shader, and I think it was the HUD Mask Shader: https://nightly.multitheftauto.com/files/shaders/shader_hud_mask.zip I would like to get any tip or suggestion to start to code the animation, but Im fully stuck. All the prerequesites were made like creating the RT, restore in case of minimzeing ...etc Thanks for reading, best regards.
  6. Hello dear community, today I have a simple question. Is there a way to insert a table with dbExec ? I know I can use a loop and insert them one by one, but Im worried about the impact that it could cause. Thanks for reading, best regards.
  7. Well, you probably will need to use the following functions since you are going to connect your server to your web-server dbConnect() dbQuery() dbExec() In case that mybb uses a hash system to encrypt the account passwords (Highly posible) this method is not going to work for you unless you know which kind of encryption method uses. Best regards.
  8. Well, looks like creating renderTargets while you are minimized it fully bugs the renderTarget element. I just added some functions to avoid the creation of renderTargets while the players is minimized ...etc Also, while restoring, Im destroying the renderTarget element to create it again just to ensure that everything its ok. Just to clear one thin. I thought that using the argument (didClearRenderTargets) provided by onClientRestore would be usefull, but I really have just tested it and it didn't work for me, so, restoring wasnt working at all since this argument doesn't work properly. Take care about creating renderTarget while minimizeing (For example in a notification script that are using rts) Thanks for your help, best regards.
  9. @Bonsai First of all, thanks for answering. Well, creating renderTarget again might could cause the issue. About calling drawTopTime() iinside render function the CPU Usage fires depending of the amount inside the table. The reason why Im creating again the renderTarget is due to the size changes depending of the amount inside the table. I need to clear out that I've already tried to destroy the renderTarget element and setting the variable as nil. Any suggestions ? @IIYAMA I've just commented about what you told I had already tried to destroy the element in other scripts where Im using renderTargets with this method. Example of my scoreboard if isElement(scoreboardRT) then destroyElement(scoreboardRT) scoreboardRT = nil end scoreboardRT = dxCreateRenderTarget(sizeX,fullSizeY,true) --REST OF THE CODE Respecting the elementTree, thats took all my attention. Might using several renderTargets is causing the problem ? Im currently using like 3 or 4 renderTargets. race, scoreboard, toptimes and might another one. I need to clear out that only the scoreboard is having the destroyElement method and might the issue is caused by the rest of scripts that are NOT using the destroyElement method ? Thanks for answering, best regards.
  10. Hey there dear community, today Im having an issue with renderTargets as the title says. Well, In fact it happens me when I minimize (not all the times) I thought that using properly the function onClientRestore it would be solved and I wouldn't have any problem, but no. Well the problem is that the renderTarget is not drawn or dissapear when minimizeing and restoring. The code is too long and there are useless functions that are innecessary, so, here goes a simple version how am I using renderTargets. Im sure that it is the right way to use and restore it. NOTE: Variables are properly set. The script works perfectly, but sometimes dissapear while minimizeing and restoring local topTimelist = {} for i=1,8 do table.insert(topTimelist, {pos = i, playerName = "–– Empty", time = "", date = "", country = "", playerSerial = "" }) end function drawTopTime() sizeY = labelSize*(#topTimelist+1) toptimesRT = dxCreateRenderTarget(sizeX,sizeY,true) dxSetRenderTarget(toptimesRT, true) dxSetBlendMode("modulate_add") --DRAW CONTENT dxSetBlendMode("blend") dxSetRenderTarget() end function renderTopTime() dxDrawImageSection(x,y,sizeX,maxSizeY,0,slide,sizeX,maxSizeY,toptimesRT,0,0,0,tocolor(255,255,255,255)) end function restoreTopTimesDraw(didClearRenderTargets) if didClearRenderTargets then drawTopTime() end end addEventHandler("onClientRestore",root,restoreTopTimesDraw) drawTopTime() addEventHandler("onClientRender",root,renderTopTime)
  11. @Zango Thats it ! Well, I have the last question, how could I select the angle to start. For example, the angle starts at the red line, but I want that it starts at green line. I know that when I use the angle while drawing images or whatever i can use the angle argument, but, I just would like to know whats the right math application in this case Thanks for reading, best regards.
  12. Hello dear community, today Im having a math issue. Well, Im just trying to get the mouse angle with the center at the middle on the screen. The code is almost done, but it only works 180 degrees. It only detects the half part of the circle. top side with negatives value and top with positive values. I know I can use conditions to make it work with 360 degrees, however Im here to know if there is a way to get a perfect angle without appealing to conditions if isCursorShowing() then local px,py = getCursorPosition() local mx,my = sX*px,sY*py local distY = math.abs(my-centerY) local distX = math.abs(mx-centerX) local dist = math.sqrt((distY*distY)+(distX*distX)) local val = distY/dist local aSine = math.atan2(my-centerY,mx-centerX); local degrees = aSine*(180/piVariable) --Draw degrees ... end Missing variables are already defined. Just to clear it. Center variables are the middle of the screen. Thanks for reading, best regards.
  13. You dont need to use killTimer due to setTimer function already has an argument which allow you to execute the same function x times. myTimer = setTimer(function() outputChatBox("only one time") end, 1000, 1) --HERE IT IS, The las value '1' are the times that it is going to be executed. For future cases, if you want to use killTimer function, be aware that you have to check first if the timer exists using the function. isTimer() Regards.
  14. @IIYAMA It is something weird. Here it is the current full code. local sX,sY = guiGetScreenSize() local radarSize = sY*0.2 local posX,posY = sX*0.02, sY*0.93-radarSize local blipsize,lpsize,range = radarSize/22,radarSize/12,180 local centerleft,centertop = posX+radarSize/2,posY+radarSize/2 local lp = getLocalPlayer() local scaleValue = sY / (1080) scaleValue = math.max(scaleValue, 0.85) -- < IIYAMA's scale limit local fontList = { [9] = dxCreateFont( "files/font/globalFont.ttf", 9*scaleValue ), [10] = dxCreateFont( "files/font/globalFont.ttf", 10*scaleValue ), [11] = dxCreateFont( "files/font/globalFont.ttf", 11*scaleValue ), [12] = dxCreateFont( "files/font/globalFont.ttf", 12*scaleValue ), [16] = dxCreateFont( "files/font/globalFont.ttf", 16*scaleValue ), [18] = dxCreateFont( "files/font/globalFont.ttf", 18*scaleValue ), [20] = dxCreateFont( "files/font/globalFont.ttf", 20*scaleValue ), [22] = dxCreateFont( "files/font/globalFont.ttf", 22*scaleValue ), [24] = dxCreateFont( "files/font/globalFont.ttf", 24*scaleValue ) } local speedFontHeight = dxGetFontHeight(1,fontList[18]) local speedoSize = speedFontHeight*3 function drawRadar() --#EMPTY CIRCLE TEXTURE emptyCirclerTxt = dxCreateTexture("files/img/EmptyCircle_Thickness.png") --#GTA MAP PRE-REQUISITES gtaMapShader = dxCreateShader("files/shader/hud_mask.fx") gtaMapTexture = dxCreateTexture( "files/img/map.png") circleTxt = dxCreateTexture( "files/img/circle.png") if gtaMapShader and gtaMapTexture and circleTxt then outputDebugString("OK| creating the gtamap-prerequisites") dxSetShaderValue( gtaMapShader, "sPicTexture", gtaMapTexture ) dxSetShaderValue( gtaMapShader, "sMaskTexture", circleTxt ) end --#SPEEDOMETTER PRE-REQUISITES speedShader = dxCreateShader("files/shader/circle.fx") if emptyCirclerTxt then dxSetShaderValue(speedShader, "tex", emptyCirclerTxt) dxSetShaderTransform(speedShader,0,0,45) end addEventHandler("onClientRender",root,renderRadarContent) end function renderRadarContent() local px, py, pz = getElementPosition(lp) local pr = getPedRotation(lp) local cx, cy, _, tx, ty = getCameraMatrix() local north = findRotation(cx, cy, tx, ty) if gtaMapShader and gtaMapTexture and circleTxt then dxSetShaderValue( gtaMapShader, "gUVPosition", (px/6000),(py/-6000) ) dxSetShaderValue( gtaMapShader, "gUVScale", (1/13), (1/13) ) dxSetShaderValue( gtaMapShader, "gUVRotAngle", math.rad(-north) ) dxSetShaderValue( gtaMapShader, "gUVRotAngle", math.rad(-north) ) dxDrawImage(posX, posY, radarSize, radarSize, gtaMapShader, 0,0,0, tocolor(255,255,255,255) ) end dxDrawImage(sX/2,sY/2, speedoSize, speedoSize, speedShader,45,0,0,tocolor(0,255,0,255)) dxSetShaderValue(speedShader, "degree", (-1)*(1.5)) dxSetShaderValue( speedShader, "rgba", 0/255, 0/255, 0/255,0.5) end function findRotation(x1, y1, x2, y2) local t = -math.deg(math.atan2(x2 - x1, y2 - y1)) if t < 0 then t = t + 360 end return t end drawRadar() Look at the 64th line, The position should be near the bottom, but it is on the top due to dxSetShaderTransform. Any idea why it could be caused. ? Im not a shader knowledger but might the matrix of the shader or something like that. But it is weird, Im using 2 DIFFERENT SHADERS. Thanks and best regards.
  15. @IIYAMA Im not using renderTarget. Im just dealing with dxCreateTexture. Previously I tried it with renderTargets and I've got the same issue. Does dxSetShaderTransform use or must use renderTargets ? Thanks for answering, best regards.
  16. Hello dear community. Today I've decided to recode my Radar script using some public shaders from resource like "Hud mask". Well, the problem is that Im trying to use dxSetShaderTransform to flip the image and give it a negative increase value. But when I use this function, another shader that I've created is affected by this function. For example: I want to apply dxSetShaderTransform only to speedShader, but, gtaMapShader is affected to. Code function drawRadar() --#EMPTY CIRCLE TEXTURE emptyCirclerTxt = dxCreateTexture("files/img/EmptyCircle_Thickness.png") --#GTA MAP PRE-REQUISITES gtaMapShader = dxCreateShader("files/shader/hud_mask.fx") gtaMapTexture = dxCreateTexture( "files/img/map.png") circleTxt = dxCreateTexture( "files/img/circle.png") if gtaMapShader and gtaMapTexture and circleTxt then dxSetShaderValue( gtaMapShader, "sPicTexture", gtaMapTexture ) dxSetShaderValue( gtaMapShader, "sMaskTexture", circleTxt ) end --#SPEEDOMETTER PRE-REQUISITES speedShader = dxCreateShader("files/shader/circle.fx") if emptyCirclerTxt then dxSetShaderValue(speedShader, "tex", emptyCirclerTxt) dxSetShaderTransform(speedShader,180,0,45) end addEventHandler("onClientRender",root,renderRadarContent) end function renderRadarContent() local px, py, pz = getElementPosition(lp) local pr = getPedRotation(lp) local cx, cy, _, tx, ty = getCameraMatrix() local north = findRotation(cx, cy, tx, ty) if gtaMapShader and gtaMapTexture and circleTxt then dxSetShaderValue( gtaMapShader, "gUVPosition", (px/6000),(py/-6000) ) dxSetShaderValue( gtaMapShader, "gUVScale", (1/zoom), (1/zoom) ) dxSetShaderValue( gtaMapShader, "gUVRotAngle", math.rad(-north) ) dxSetShaderValue( gtaMapShader, "gUVRotAngle", math.rad(-north) ) dxDrawImage(posX, posY, radarSize, radarSize, gtaMapShader, 0,0,0, tocolor(255,255,255,255) ) end dxDrawImage(sX/2,sY/2, speedoSize, speedoSize, speedShader,45,0,0,tocolor(0,255,0,255)) dxSetShaderValue(speedShader, "degree", (-1)*(1.5)) dxSetShaderValue( speedShader, "rgba", 0/255, 0/255, 0/255,0.5) end I hope you can bring me a hand with this issue. Thanks in advance, regards.
  17. Looks like it is being updated many times in few seconds. Anyways. It shouldnt give you fps drops or something like that since it isnt in a render Event. Otherwise. I would update the system to be updated when a player needs it or reducing the timer that it probably has. Regards
  18. Try to use a simpler one texture ScreenTexture; technique tech { pass p0 { Texture[0] = ScreenTexture; } } Regards.
  19. As far as I read in the wiki, you have to execute again the command, without any extra argument. setPedAnimation(thePlayer) Regards.
  20. Ohh, I see. Well, currently the way im following is that when I start the resource, do a loop to store all the names from the database into a table. So, If I want to check if the table exists, instead doing a query I just do the search on the table (Im not even sure if this is more efficent) Doing this, i can avoid of using limits ...etc Thanks for your help @MrTasty & @IIYAMA
  21. Thanks for your help, it helped me a lot the first part of your comment, but, Im curious with the 2nd part. I didnt get at all the the LIMIT. Currently the way Im following the check if a table exists is to loop the sqlite_master table. Thanks and regards.
  22. Didn't youi ask the same thing some days ago ? Read it carefully and give it a try. Regards.
  23. Hello dear community, I have a simple question about SQLITE Well, I have been using the default system from race_toptime resource for several years. Nowadays, I cannot still using it due to I need to deal with an efficent way to store somethings. However, I won't lost the data recorded inside there and here comes my first question. Is there a way to check if a table exists without creating it ? Obyously you can do the query, but I won't get the debugscript error, thats why Im asking about it. I have currently tested the function executeSQLQuery (I will test later with dbQuery, might this clear out this question) And my 2nd question is: Is there a way to get all the table names from the database ? Might something like this 'SELECT * FROM *' Thanks for reading. best regards.
  24. Might this helps you. dxDrawImageOnElement() addCommandHandler() onClientRender()
  25. Well, I've got 2 new doubts about this. The first one is that if I haven't the event created in the same resource, I must use root instead resourceRoot right ? However this creates me another doubt that If can create a "Fake Empty" event in the same resource with the propagation enabled. Also, all the "extra" resources must have enabled the propagation in the "Method 2 from Right way to to use the trigger" that comes below Well, my second question is, leaving out the extra question I've got previously, In case I want to use triggerClientEvent() just for the player when he joins the room should I do it like this triggerClientEvent(source, "onPlayerJoinRoom", source, arg) or triggerClientEvent(source, "onPlayerJoinRoom", root, arg) I need to clear out that the function onPlayerJoinRoom is managed by other resources aswell Thats all for now, thanks for helping me newly @IIYAMA, best regards.
×
×
  • Create New...