Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/03/22 in all areas

  1. Thisdp's DirectX Graphical User Interface System ( MTASA 2D+3D DxLIB ) This dxlib provide dx gui functions and events to make it easier to use and alternative to change the style more flexibly. Features: 1. Update Check(DGS will notice you if there is a higher version, and you can choose to ignore it or disable it in the config file) Update Command: "updatedgs" 2. Dx GUI Types: Basic: Window Edit Box Button Grid List Image Scroll Bar Scroll Pane Text Label Tab Panel Detect Area Radio Button Combo Box Check Box Memo 3D Interface 3D Text Browser Switch Button Selector Plugin: Media Browser Color Picker Mask Remote Image QRCode Blur Box Rounded Rectangle Nine Slice Scaling Object Preview Support Canvas Scroll Pane's 3D Effect 3. Edit/Memo rewrite ( You can no longer find the problems in dgs, the problems which exist in cegui) 4. Detect Area is efficient when checking whether your cursor is in a complicated shape. 5. Debug Mode , Command: "debugdgs" 6. You can apply shader to the dxgui ( Compatible with some resources like Objec tPreview ). 7. Include CMD, Command: "dgscmd" ( For more help, please input "help" in the CMD ) 8. Memo/Edit rewritten. 9. Object Oriented Programming Class. 10. Render Target Failure Check ( Warns when there's no enough video memory to create render target ). 11. DGS resembles cegui, you can find the similar feeling when scripting with dgs. 12. 48-hour-response service, your suggestions and bug report will be dealt with in 48 hours ( or less, like 12 hours ? ) 13. Custom Style system 14. Built-in shader plugin 15. More properties 16. Built in multi-language support 17. Simple GUI To DGS (G2D) Notice:Do not close your server or stop the script when it is updating. Wiki: https://wiki.multitheftauto.com/wiki/Dgs ( Still Working In Process ) Auto Completion For N++ (Thanks To Ahmed Ly): http://www.mediafire.com/file/m6dm7815d5dihax/Lua.zip Discord Server: https://discord.gg/QEs8q6W Download DGS : https://github.com/thisdp/dgs Notice: Need acl rights to call fetchRemote/getPlayerIP. If you want to sell your script which involves DGS, please exclude DGS from your price. HurtWorld Backpack Panel(Example) DGS Network Monitor(Built-in)
    1 point
  2. Sorry for not answer this till now, solved, thank you @IIYAMA
    1 point
  3. if player == localPlayer then return end UPS ! My bad, I meant ~= there if player ~= localPlayer then return end (replace in both) Okay yeah, here is your problem: You are creating 1 new timer per frame (x30 per sec at 30fps) so after 20 seconds of calmness you are calling triggerServerEvent every frame. Does that make sense ? What I would do is: -- on server side: listen to onVehicleEnter and when someone enters it, create the 20sec timer to update the fuel. Remember the timer (a table or a "not synced" element data and using the vehicle element as index/key to retreive it later) To update the fuel: make the necessary checks (engine state = ON etc) and use element data (element data get so much hate and I don't agree with all that hate, its perfect to sync an element data between server and clients when used correctly) local currentFuel = getElementData(vehicle, "fuel") or 0 setElementData(vehicle, "fuel", currentFuel - 5) -- updating the fuel on server Listen to onVehicleExit and get back the timer you created (and that you stored) and kill that timer -- on client side: Listen to onVehicleEnter and onVehicleExit to show or hide the speedometer (= add or remove the onClientRender) Yes you can use "onClientElementDataChange" to listen and update the fuel value updates for drawing local currentVeh = nil local currentFuel = 0 function checkDataFuel(dataName, oldValue, newValue) if dataName ~= "fuel" or source ~= currentVeh then return end -- cancel if it's not "fuel" update or if it's not for our vehicle currentFuel = newValue end addEventHandler("onClientElementDataChange", root, checkDataFuel) function enterVehicle(player, seat) if player ~= localPlayer then return end if seat == 0 or seat == 1 then currentVeh = source currentFuel = getElementData(source, "fuel") -- making sure we show the right value at 1st frame addEventHandler("onClientRender", root, drawSpeedo) -- show speedo isSpeedoVisible = true end end addEventHandler("onClientVehicleEnter", root, enterVehicle) function exitVehicle(player) if player ~= localPlayer then return end currentVeh = nil if isSpeedoVisible then removeEventHandler("onClientRender", root, drawSpeedo) -- hide speedo isSpeedoVisible = false end end addEventHandler("onClientVehicleStartExit", root, exitVehicle) function drawSpeedo() if not currentVeh then return end -- should never happen, just in case --[[ draw vehicle speed and fuel here. You have access to these variables to draw: currentVeh currentFuel ]] end I gave you a lot of client code to show you how it should look like with the new logic (your latest version was going a bit wild) For the server part, I let you try with the instructions I gave you. Note: After all that, the last optimization would be to not call getVehicleEngineState at every frame (in your getCarStateColor function) but it's a minor optimization, the biggest gain is to not spam the triggerServerEvent by implementing the new logic I'm suggesting.
    1 point
  4. function changeWeapon(player) setPedAnimation(player, "colt45", "colt45_reload", -1, false, false, true, true) ------- this part works setTimer( function (player) setPedAnimation(player) ---------got nil / doesn't exist end, 1000, 1,player) end addEvent("animCw", true) addEventHandler("animCw", root, changeWeapon)
    1 point
  5. @Burak5312There is no issue to solve, the original code is working and has no perf problems. Also your code won't work, you forgot to flip the boolean inside show and hide functions. @CronossYour code is fine. And you are right, technically it's better because "onClientRender" won't call your lua function for nothing (if the speedometer is hidden). local isSpeedoVisible = false function drawSpeedometer() if not isSpeedoVisible then return end -- cancel immediatly -- drawing end addEventHandler("onClientRender", root, drawSpeedometer) ------ function A1(player) if player == localPlayer then return end -- you forgot this btw or else other players will trigger it too vehicle = getPedOccupiedVehicle(player) if getPedOccupiedVehicleSeat(player) == 0 or getPedOccupiedVehicleSeat(player) == 1 then isSpeedoVisible = true end end addEventHandler("onClientVehicleEnter", root, A1) function A2(player) if player == localPlayer then return end -- you forgot this btw or else other players will trigger it too isSpeedoVisible = false end addEventHandler("onClientVehicleStartExit", root, A2) If you had something like this, it is fine too and the perf are so close that the difference can be ignored (but technically it's better to add and remove the event handler like in your original post). If you are having perf issues with your speedometer, make sure you don't call get/set ElementData inside the drawing function. Those methods are expensive.
    1 point
  6. The variable doesn't exist when the inner function is executed later (different scope). You have to send the player to the inner function (after the 3rd argument of setTimer): function changeWeapon(player) setPedAnimation(player, "colt45", "colt45_reload", 0, false, false, true, true) setTimer( function (timerPlayer) setPedAnimation(timerPlayer) end, 1000, 1, player) end addEvent("animCw", true) addEventHandler("animCw", root, changeWeapon) And since the argument you send through the setTimer call is exactly the one you send in setPedAnimation, you can make it shorter like so: function changeWeapon(player) setPedAnimation(player, "colt45", "colt45_reload", 0, false, false, true, true) setTimer(setPedAnimation, 1000, 1, player) end addEvent("animCw", true) addEventHandler("animCw", root, changeWeapon)
    1 point
  7. Friday the 13th: MTA Edition is a brand new horror server on MTA inspired by Friday The 13th: The Game and Dead by Daylight. The main objective is survive until dawn or escape from the camp crystal lake by car/boat/calling the cops. Unlock new characters with unique abilities, perks and much more! Watch the first teaser of the server:
    1 point
  8. Oii, Você pode utilizar alguns dos recursos de Lua para pegar uma posição aleatória dentre as definidas em uma tabela. Por exemplo:
    1 point
  9. Glad that I could help! ?
    1 point
  10. You can reduce this code btw, by disable caseSensitive. bool addCommandHandler ( string commandName, function handlerFunction [, bool caseSensitive = true ] ) addCommandHandler("buy", detectPanel, false) As for your initial question. local zones_CScns = {["Jefferson"] = true} local zones_GTcns = {["Rodeo"] = true} --- ... if zones_CScns[gps] then CScns() elseif zones_GTcns[gps] then GTcns() end or -- !Order matters local zones --- ... local theFunc = zones[gps] if theFunc then theFunc() else -- do something else... end -- ... functions CScns and GTcns here zones = {["Jefferson"] = CScns, ["Rodeo"] = GTcns}
    1 point
×
×
  • Create New...