Jump to content

Overkillz

Members
  • Posts

    545
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Overkillz

  1. Thats probably because server-side is running before client side, so, in this case, you should make a trigger from the client to the server and send the response back to the client again. Not sure if there is a better option for it cuz using a timer is not a good idea aswell ... So here goes my solution: -- ## CLIENT-SIDE local myCountry = "" addEvent("onPlayerCountryReceived", true) addEventHandler("onPlayerCountryReceived", root, function(country) outputChatBox(country) myCountry = country end) addEventHandler("onClientResourceStart", resourceRoot, function () triggerServerEvent("onRequestPlayerCountry", resourceRoot) end) -- ## SERVER-SIDE addEvent("onRequestPlayerCountry", true) addEventHandler("onRequestPlayerCountry", resourceRoot, function() local country = exports.admin:getPlayerCountry(client) triggerClientEvent(client, "onPlayerCountryReceived", resourceRoot, country) end)
  2. The source element of the event onResourceStart is not a player, so, you are triying to get the country of a Resource, obyously this is not going to work. What you should do ? You need to loop the whole player list by using getElementsyType("player") and inside that loop ask for player country and do the trigger aswell. Best regards.
  3. Many of the times we don't need to use MTA SDK. Otherwise, he is trying to build an api, so, it useless to use MTA SQL connector in this case aswell .. -------------------------------------------------------- Well, I have done some researches about the issue its in php file. You are not receiveing a JSON, so, the decoding function won't never work. If you directly output the content, you probably are going to get something un-parsed which is related with 'WebKitFormBoundary' or similar. There are methods made by people to parse it and try to get a json content, but, it doesn't support weird content. Regards.
  4. Overkillz

    setTimer

    Not sure if this can be even better. Try this one: addEventHandler("onVehicleExplode", root, function() setTimer(destroyElement(),3000,1,source) end)
  5. No, you are not using the right event. Checkout onClientMarkerHit event. The source parameter is the event, so, you just need to compare such element with you variable infoMarker and do whatever you want. Best regards.
  6. Well, I've just realized about few things that I wasn't aware about them. First of all, If you store your exported resource which containts your exported functions in a variable, you can't call those functions with: myVariable(dot)functionName -- This doesn't work util.isEmptyString("FIRST_PARAMETER", "SECOND_PARAMENTER") --## RESULT: SECOND_PARAMENTER -- Right way to read parameters util:isEmptyString("FIRST_PARAMETER", "SECOND_PARAMENTER") --## RESULT: FIRST_PARAMETER Thats all, thanks for reading.
  7. I'm having an issue while using exported functions with receive some parameters Im trying to read the first parameter, but it doesn't work at all, it reads the second one. What do I mean ? -- CLIENT local util = exports["SHI_Util"] function whatever() util.isEmptyString("FIRST_PARAMETER", "SECOND_PARAMENTER") end -- SHARED CLASS function isEmptyString(s) outputChatBox("Recived string: " ..s) end -- RESULT --> Recived string: SECOND_PARAMENTER -- META.XML <meta> <export function="isEmptyString" type="shared"/> </meta> Something similar happens with server side exported functions. I hope you can bring me a hand with this. Thanks in advice, best regards.
  8. Nonsense ? For other resolutions will be the default one "x1". On the other hand, there is something called elseif (Not sure if you heard about it) which allows you to set a multiplier for other resolutions ...
  9. You could use a variable that increase the size value of fonts, dx sizes ...etc local sX,sY = guiGetScreenSize() local multiplier = 1 if sY >= 2160 then multiplier = 2 end function yourOtherFunctions() dxDrawRectangle(0,0,250*multiplier, 100*multiplier) end
  10. Hello dear community, I'm back in development scene and I have some doubts about performing my current scritps that I made like 4 years ago. Well, the first question is Passing an element with multiple datas decrease is not a good way to a proper performance ? In fact, I have this doubt with a data which store players in a specific arena. Imagine that there are 32 players in that arena, well, im storing them in a table which is a data of the element. My question is, passing the whole element pass only the pointer address or pass the elements, therefore, the performance could be decreased ? I leave you a picture of the element. The other question is, what about if I trigger from a client to the server side an element which containts some datas, but before the element arrives to the server, some of the data changes his values. Which values arrives ? The updated one or the old one ? Best regards.
  11. Might you should check the following doc engineRequestModel It has an example that might could make you achieve your goal
  12. Did u add it to your meta file ? If you can, show is your meta file
  13. Are you sure that the file "states/fenyjelzo_szabad.txd" is loaded correctly ? Might you could add a condition with "fileExists" function to confirm that it exists. Regards.
  14. Not tested addEventHandler("onClientRender", root, function() local a = string.format("FPS: %d PING: %d", 51, getPlayerPing(localPlayer)) local c_version = "MTA:SA"..getVersion().mta.."*" dxDrawText(a, 0, 0, sx-dxGetTextWidth(c_version), sy, tocolor(255, 255, 255, 255), 1, "default", "right", "bottom", false, false, false, false, false) end )
  15. Whats exactly do you want to do ? It is doing what you have coded.
  16. getCursorPosition() playSound() Remember using onClientRender to catch the current position each frame. Regards.
  17. How base64 could help me ? It has not sense.
  18. Hello dear community. Is there a way to load an image that is not in the meta.xml INTO the HTML. Im currently downloading the avatar photos of x accounts, however, due to it isn't in meta.xml I can't load it. I hope you can bring me a hand. Best regards.
  19. Inside pumps table there isn't another sub-table or at least not as first array element. What does it mean ? Might you have an structure which looks like this one local pumps = { anyData = false, -- You can not get the lenght of this one subTable = {} -- However You CAN get the lenght of this one } Regards.
  20. Are u getting an array from the user ? Might there is your problem. You are using an ID instead of Name. I have not experienced with this, but as far as I could read at discord documentation, you should be getting an Array.
  21. Hello dear community, Im working with renderTargets since is a way that losing a bit of quality you can get an incredible performance. However, today I have faced an issue while drawing some text. Well, I have like 4k maps and obyously, each one has his own name. Well, while using renderTargets, I can't draw more than 1000 text I tried it while using a custom font and few stuffs more. If you think that my code is wrowng, here I left you the way Im working local sX,sY = guiGetScreenSize() local sizeX,sizeY = sX/2,sY/2 local fontHeight = dxGetFontHeight(1,"default-bold") local items = {} for n=1,4000 do table.insert(items,{text = "test"..n, path = "whatever", anim = 0, active = false}) end local rt = dxCreateRenderTarget(sizeX,fontHeight*#items,true) function drawContent() dxSetRenderTarget(rt, true) dxSetBlendMode("modulate_add") dxDrawRectangle(0,0,sizeX,fontHeight*#items,tocolor(255,0,0,100)) for i,k in ipairs(items) do dxDrawText(k.text,0,fontHeight*(i-1),sizeX,fontHeight*(i-1)+fontHeight,tocolor(255,255,255,255),1,"default-bold") end dxSetBlendMode("blend") dxSetRenderTarget() end function renderContent() if rt then dxDrawImage(0,0,sizeX,sizeY,rt,0,0,0,tocolor(255,255,255,255)) end end drawContent() addEventHandler("onClientRender",root,renderContent) I hope you can bring me a hand with this issue. Or a way to draw like 4k map names without affecting the performance. Best regards.
  22. Might you can apreciate the difference due to you are using default fonts or not thing fonts, but look As you can see, the second image is clearer. Due to the image cut, might you cant difference the quality, but, if you would see the full tab, the quality lost is appreciable. Anyways, I have done several test and ways to make it work, but nothing, texture shader doesn't work too ...etc So, maybe I will be forced to use module_add arg instead of add only. Regards.
  23. Probably you are getting the seconds. If you want to get the minutes you have to convert the seconds in minutes ...etc Regards.
  24. I already test it, but it doesn't reach the quality like using only add
  25. Hello dear community, Im having an issue with renderTargets. Well, my problem is simple. Im trying to apply a fade effect to a renderTarget. Well, I want to have a decent quality while drawing stuffs on it, so, Im forced to se the function dxSetBlendMode. However, If I use it, I can't make fade animation. Here is the wiki example with the fade animation local myRenderTarget = dxCreateRenderTarget(500, 500, true) local alpha = 0 function updateRenderTarget() dxSetRenderTarget(myRenderTarget, true) dxSetBlendMode("modulate_add") dxDrawRectangle(0,0,500,500,tocolor(255,0,0,255)) dxDrawText("Testing "..getTickCount(), 0, 0, 0, 0, tocolor(255, 255, 255, 255), 2, "clear") dxSetBlendMode("blend") dxSetRenderTarget() end addEventHandler("onClientRender", root, function() alpha = math.min(alpha+10,255) dxSetBlendMode("add") dxDrawImage(100, 200, 500, 500, myRenderTarget, 0,0,0,tocolor(255,255,255,alpha)) dxSetBlendMode("blend") end ) updateRenderTarget() Is there any way to fix it without losing the quality that brings dxSetBlendMode ? Thanks for reading, best regards.
×
×
  • Create New...