Jump to content

Gallardo9944

Members
  • Posts

    442
  • Joined

  • Last visited

Everything posted by Gallardo9944

  1. nope, renderText is not an element but a function. You've gotta pause it somehow. You can either split functions like this: local x,y = guiGetScreenSize() local textPosition = 0 -- Main counter. You can do the same with anything you want to move or change per frame. local text = "This text is moving right!" function renderText() dxDrawText(text,textPosition,y/2,x,y) -- draw the text end addEventHandler("onClientRender",getRootElement(),renderText) function renderAnimation() textPosition = textPosition + 1 -- Move by one pixel each frame if textPosition > x then -- If the text is out of the screen textPosition = 0 -- Make it come back to the default position end addEventHandler("onClientPreRender",getRootElement(),renderAnimation) -- Applying the animation before rendering the text to make animation work properly addEventHandler ( "onClientGUIClick",loginButton,function() removeEventHandler("onClientPreRender",getRootElement(),renderAnimation) -- Removing the animation. You can also remove event handler for renderText if you want to remove the text completely end) Or this (use a variable to specify if it should animate more): local x,y = guiGetScreenSize() local textPosition = 0 -- Main counter. You can do the same with anything you want to move or change per frame. local text = "This text is moving right!" local animate = true function renderText() if animate == true then -- If we want to animate stuff textPosition = textPosition + 1 if textPosition > x then textPosition = 0 end end dxDrawText(text,textPosition,y/2,x,y) -- draw the text -- Add this into the "if" check if you don't want to draw it anymore end addEventHandler("onClientRender",getRootElement(),renderText) addEventHandler ( "onClientGUIClick",loginButton,function() animate = false -- Stop animating. end) Of course, the second way is nice when you have to animate the stuff often, but without a complete removal of the text.
  2. local x,y = guiGetScreenSize() local textPosition = 0 -- Main counter. You can do the same with anything you want to move or change per frame. local text = "This text is moving right!" function renderText() textPosition = textPosition + 1 -- Move by one pixel each frame if textPosition > x then -- If the text is out of the screen textPosition = 0 -- Make it come back to the default position end dxDrawText(text,textPosition,y/2,x,y) -- draw the text end addEventHandler("onClientRender",getRootElement(),renderText) Should be a good example. Unstested though.
  3. Disaster, quoting Wiki of setElementVisibleTo:
  4. Hello. I've got a little problem with the code. I want to make a player see objects of his own dimension. Actually, everything is pretty much correct, the code has no errors, the dimensions are set. But the only problem that setting a player to (for example) 3rd dimension shows the objects of the 0th dimension, though making objects be in 3rd forces objects to disappear. Did i miss something? -- SERVERSIDE setElementDimension(player,3) -- It sets the dimension, already checked local object = createObject(...) -- Creating the object. The object is visible to any player of any dimension setElementDimension(object,3) -- The object disappears though the player is in 3rd dimension. Strange Thanks in advance.
  5. What's the problem to check the value? local minLimit = 1000 local maxLimit = 5000 local val = guiGetText(edit) local numval = tonumber(val) if val and tonumber(val) then --checking if the value can be a number if val < minLimit then return false -- Lower. You can output that the lowest value is 1000 elseif val > maxLimit then return false --Higher. You can output that the max value is 5000 else return true --Suitable value. Ouput that it's fine and do your stuff end end
  6. fetchRemote isn't sending data but receiving it, so you have to use this one for that. callRemote
  7. Character limit is 128 characters.
  8. Try using onClientRender to reset the timer. getAnalogControlState Will help you with it. The code should look like this. function renderReset() local F = getAnalogControlState("accelerate") local B = getAnalogControlState("brake_reverse") local L = getAnalogControlState("vehicle_left") local R = getAnalogControlState("vehicle_right") if F > 0 or B > 0 or L > 0 or R > 0 then resetTimer() -- Reset your AFK timer here end end addEventHandler("onClientRender",getRootElement(),renderReset)
  9. dxDrawText(ColorText, theText, leftB, topB, left, top, tocolor(255,255,255,255), 3, "default-bold", "left", "top", false, true, true,true) dx functions can't be executed serverside. Won't work. Use triggerClientEvent to trigger some custom event and execute drawShout. This will work. triggerClientEvent -- send the text as an argument. Should be executed serverside addEventHandler("onShouts", root, drawShout) -- You have this one. It's okay. Trigger it.
  10. Actually, it depends on the computer power. Yes, I admit that my Core 2 Quad is kinda slow, but, as an example, FFS manages to go fast without any freeze on the same computer. So that's the point. Upgrading to i7 isn't a solution, believe me.
  11. Ok, Arezu, I missed that. Then I have to hide objects clientside. And yes, TG causes the same lags.
  12. IIYAMA, tried this too, goes really slow, even more. About 40 secs to build all the stuff if not 1-2 minutes. I solved the problem by moving the building to the server side with setElementVisibleTo.
  13. Nope, Arezu, that's not the source of the problem. I tested it client-side only and it still caused the same lags, no matter what. So that's not about table sizes as object creation parts.
  14. Some additional information: I added a tick counter before the objects building, made client trigger server after it finishes building all the objects, made server send back to client (to validate that MTA is actually responding and can receive data) and output the timing between first tick counter and last one. It shows about 0.1-0.2 seconds, however, MTA gets stuck at that point, but at the same time manages to validate all the information. What could cause the issue and how to solve it?
  15. Hello. I've created a map loader, which transfers map data (in a table) to the client side and creates all the stuff there. But a huge table of resources causes a freeze of the game (basically full MTA freeze) depending on the map size (1 sec for a little map, 12 secs fo a big one). How can I speed this up or make it run in some kind of separated thread? Here goes the code: local objnum = #objs for i=1,objnum do --for i,v in ipairs(objs) do -- This one is slower than a simple "for" from 1 to the objects amount local v = objs[i] local object = createObject(v.model,v.posX,v.posY,v.posZ,v.rotX,v.rotY,v.rotZ) if object then table.insert(objects,object) if v.doublesided == true then setElementDoubleSided(object,v.doublesided) end if v.scale and (v.scale > 1 or v.scale < 1) then setObjectScale(object,v.scale) end if v.interior and tonumber(v.interior) and tonumber(v.interior) > 0 then setElementInterior(object,v.interior) end if v.dimension and tonumber(v.dimension) and tonumber(v.dimension) > 0 then setElementDimension(object,v.dimension) end if v.alpha and not (v.alpha == 255) then setElementAlpha(object,v.alpha) end if v.collisions == false then setElementCollisionsEnabled(object,v.collisions) end end end Also tried this technique, not a huge help though: local objnum = #objs --for i,v in ipairs(objs) do -- This one is slower than a simple "for" from 1 to the objects amount for i=1,objnum do local v = objs[i] local object = createObject(v.model,v.posX,v.posY,v.posZ,v.rotX,v.rotY,v.rotZ) if object then table.insert(objects,object) if v.collisions == false then setElementCollisionsEnabled(object,v.collisions) end if v.alpha and not (v.alpha == 255) then setElementAlpha(object,v.alpha) end if not (v.alpha == 0) then if v.scale and (v.scale > 1 or v.scale < 1) then setObjectScale(object,v.scale) end if not (v.scale == 0) then if v.dimension and tonumber(v.dimension) and tonumber(v.dimension) > 0 then setElementDimension(object,v.dimension) end if not tonumber(v.dimension) or tonumber(v.dimension) == 0 then if v.interior and tonumber(v.interior) and tonumber(v.interior) > 0 then setElementInterior(object,v.interior) end if not tonumber(v.interior) or tonumber(v.interior) == 0 then if v.doublesided == true then setElementDoubleSided(object,v.doublesided) end end end end end end end Of course, those checks were done to avoid some unneccessary things like setting alpha to 0 and scale to 0 at the same time (totally unneeded here cause they both do the same in the result). Basically, the only thing I want to get rid of is that lag varying from 1 to 10-15 seconds. If that's possible, please, give me a note. There could be about 8000-9000 objects to create when the lag appears. Thanks in advance.
  16. Just like I thought. Thanks anyway, gonna replace all the GUI stuff with dx-drawn thingies.
  17. Hello. I've got a shader made with a render target and I want to attach a GUI element to that shader. Is there any ability to do that? Here goes my code: local mainTarget = dxCreateRenderTarget(sx,sy,true) local mainShader = dxCreateShader("textureReplace.fx") function updateRTarget() dxSetRenderTarget(mainTarget,true) dxDrawRectangle(0,0,sx,sy,tocolor(0,0,0,150)) -- sx and sy are the target sizes. dxSetRenderTarget() dxSetShaderValue(mainShader, "tex", mainTarget) -- Setting a shader "tex" value to the target we have end function drawInterface() updateRTarget() -- Rotating the shader to a particular angle. dxSetShaderTransform(mainShader,rot,0,0) -- I want a GUI element to rotate and move together with the shader without a need to calculate a position of the element. dxDrawImage(posX,posY,sx,sy,mainShader) end addEventHandler("onClientRender",getRootElement(),drawInterface) Thanks in advance.
  18. Perfectly ran on ArchLinux, Ubuntu, Debian 6, OpenSuSe 12.1, Fedora 15-18, Mint 13-15, and others I don't remember. Tested on all that distros on my own. But I am having problems running it on 1.6 and higher: doesn't start at all. I have to use 1.4.1 on my POL.
  19. Great thanks, Arezu. The code worked just perfectly, but you also needed to add "updateRenderTarget()" to make it actually draw the text, not a white rectangle.
  20. Hello. I've been searching for a while and still can't understand the way of drawing a text with an ability to rotate it left or right. Basically, the only thing I've found is that I have to use a shader for that. Unfortunately, I dunno anything particular about drawing stuff with shaders. Is there an ability to draw a text with an .fx shader? I've also read that I could use "DxDrawMaterialLine3D" for that, so if that's also possible, I'd really appriciate an example of drawing rotated texts with that. Thanks in advance.
  21. local diff = t2-t1 -- Time calculation local ctr = 1000/diff -- Frames calculation based on time
  22. Supposedly, you are using onClientResourceStart with getRootElement at the same time. Probably that's why it triggers some unnecessary stuff.
  23. I would also add that Kwrite is an awesome *Nix LUA (and anything else) editor, which has auto tabulations (full ones, not just "auto ident"). LInux, BSD, Solaris users can use their repositories to install Kwrite (or Kate, which is the same), Windows users should install KDE For Windows and choose KDE Workspace and Kate packages to install. The installed kwrite.exe can be found in /KDEFOLDER/bin/kwrite.exe
  24. Try editing your /etc/mysql/my.cnf file and comment out (add a # before the line) where you have something like "bind_address" and restart the server. Should be connecting after that.
  25. Why don't you just create a table, insert your "moveDxElement" function there each time and remove the handler when you need it?
×
×
  • Create New...