Jump to content

Mersad

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by Mersad

  1. 58 minutes ago, Laxante101 said:

    Blocking ASI Loaders is implemented in the MTA source code file for security and stability reasons. core/ScriptCore.cpp. You will need to locate the bool function CScriptCore::IsASIAllowed(const char* szFileName) and modify its behavior, To disable blocking of ASI Loaders, you can simply return true whenever the IsASIAllowed function is called. This will allow all ASI files to be loaded without restrictions.If you want to create a whitelist for some ASI files, you can modify the IsASIAllowed function to check if the ASI file is whitelisted before allowing it to be loaded.

    I can't find such a file. It seems like this class doesn't even exist in the source code.

  2. I am working on a launcher based on the MTA source code and I want to exclusively support the fastman92 limit adjuster.
    Naturally, MTA blocks ASI Loaders, making this impossible. Which specific part of the source code should I modify to disable this block? ( I want to create a whitelist for some ASI files. )

  3. Hello!

    I'm currently developing a custom client for my server using the MTA Git source code. I need to add a new map alongside the game's original map. I have an IMG file along with some IDE and IPL files for it.

    Additionally, I want the server to run as optimally as possible. Is there a way to execute these files efficiently? For example, executing them within the main game before the launcher starts (something like adding files to gta.dat), or any other optimized method?

    Thanks!

  4. 5 minutes ago, IIYAMA said:

    I would also go for the suggestion @FernandoMTA  made, but with the syntax that works for you.

    If possible move some of the events that are triggered on the same side (client/server) to export functions.

     

    Serverside

    function customOutputChatBox  () -- export function
    	-- Add rate limit here for each player
    	-- Show message
    end

    How to create/call export functions?

     

     

    Clientside (if available)

    If you use remote access.

    function customOutputChatBox  () -- export function
    	-- Add rate limit here, protecting the server from spam
    	triggerServerEvent(...)
    end

     

     

    Well, I was considering using such an approach, but the wiki states the following about this function:
    "Note: Calls may incur a performance overhead - they are not equivalent in performance to calling functions in the same resource."
    I felt that this might cause delays on the server.

    Does this delay have any significant impact?
     

  5. 5 minutes ago, FernandoMTA said:

    If you handle the outputChatBox messages in 1 resource or script, you can simply override the outputChatBox function, redefining to do your color changes and magic.

    -- serverside
    outputChatBoxOriginal = outputChatBox
    outputChatBox = function(text, element, r, g, b, colorCoded)
      -- here you can change text variable
      return outputChatBoxOriginal(text, element, r, g, b, colorCoded)
    end

     

    No, I want to use the system I wrote instead of the regular outputChatBox in each individual source. I have already written the color change system, but my problem is that I don't know how to use it in all sources without causing delays. The event system was the only solution I could think of, but I'm not sure if this system will cause lag or delay.
     

  6. 1 hour ago, TMTMTL said:

    Hi.

    Why would you need to do that exactly? 
    A little more context is required.

    I want to send texts with specific keywords to maintain a consistent color palette for outputs. For example:
    "Hello&redWorld"
    In our handler function, we replace the &red with #ff0000 to change the color of the rest of the chat to red. I have done this for many colors and want to use constant values to make the code more stable and dynamic.

    If I were to use classic color placement (outputChatBox), it would be difficult, and editing the code would be harder. Is there a better way to achieve this? Additionally, if not, if I implement this with events, could it slow down or lag my server? What steps should I take to prevent this issue?

     

    I can put the color change code in each individual source and be sure that my code will not cause lag or delay, but this is not a proper approach. Additionally, if I later need to edit the hex code of a color, I would have to make this change in each individual source, which is hard and cumbersome.


    @TMTMTL & @IIYAMA

  7. Hello everyone!

    I'm developing a server and recently started managing all server outputs through events. For example, instead of directly calling `outputChatBox`, I've defined an event `onRequestChat` and then call `outputChatBox` within that event. My question is whether this approach can significantly impact server performance, especially when there are many players. Is it possible that extensive use of events could cause the server to slow down or lag?

    Thank you!

  8. Hello! Is it possible to include additional information in the chatbox when completing a name with the tab key?

    For example, let's say we have the following data for each player:

    getElementData(player, "inGameID");

    We want to achieve something where when a player brings up the chatbox and writes part of another player's name, after completing the name with the tab key, the ID is appended to the name. For instance, if a player's name is "Rage" and we write "Rag" and then press the tab key, the name is completed to "Rage". We would like the player's ID to appear after their name, like "Rage [1]".

    I have found several servers that have this feature and they don't use setPlayerName for it because there is a space between the name and the ID.

  9. Hello!
    Can we assign specific data for each object in a map file? For example, let's say we assign a int data named "heal" for each object, and in a Lua Script file, within a loop for all the resource objects, we assign the value of object heal to the designated data in the file.

    <object model="" posX="" posY="" posZ="" rotX="" rotY="" rotZ="" interior="" dimension="" scale="" collisions="" alpha="" frozen="" heal="" />
    --or other syntaxes
  10. Hello Everyone!

    I have the following code:

    local thePlayer = localPlayer
    local x, y, z = getElementPosition(thePlayer)
    local rot = getPedRotation(thePlayer)
    local newX, newY = getPointFromDistanceRotation(x, y, 3, rot+180)

    So, this code calculates the coordinates (x and y) 3 meters in front of the player's position. Now, I want to check if the highest point at these coordinates is water (true) or not (false). This is to ensure that the action is only performed if there is water in front of the player.

    How can I achieve this?

  11. 10 hours ago, xLive said:

    @Mersad Your thread has been moved to the Scripting section. Please use it for scripting questions in the future.


    That's because your draw functions are being executed after DGS finishes its own drawing. You can either change your onClientRender event priority to high or set DGS renderPriority to low using dgsSetRenderSetting. Both will ensure that your draw functions runs before DGS render event, which should make DGS elements render above it:

    addEventHandler("onClientRender", root, drawFunction, false, "high")

    addEventHandler:
    zmC4m8b.png

    By the way, is there any particular reason for not using dgsCreateImage?

    Thank you so much! That solved my problem. 😊

    The reason I’m not using dgsCreateImage is that I want to create smooth and fluid animations for my background images to make them more visually appealing. As far as I know, this isn’t possible using GUI or DGS elements. Is that correct?

  12. Hello everyone! 😊

    I hope you’re all doing well. I’m currently working on a panel using dxDraw and DGS. I’m using dxDraw for background images and other elements, and DGS for edit boxes and similar components.

    I’ve run into a bit of a snag, though. The DGS elements are appearing behind the dxDraw element that I’m using as a background. Since these are edit boxes, they should be appearing on top of the background.

    I’ve been scratching my head over this for a while now, and any help or guidance would be greatly appreciated. Thanks in advance for your time!

    Best regards.

  13. On 12/02/2023 at 19:18, Kidzonio said:

    Heyo Bro! You need to pass the localPlayer in the trigger, because the source does not exist on the server-side

    --Server Side
    function VoteSystem(title)
    	outputChatBox("Ghor'e Keshi Shodu Shod! Ba Dasture [/sherkat] Dar Ghore Keshi Sherkat Konid!")
    end
    addEvent("ElameShorueGhore", true)
    addEventHandler("ElameShorueGhore", resourceRoot, VoteSystem)
    
    
    function getrp( source, commandName )
    	randomP = getRandomPlayer()
    	triggerClientEvent(source, "getRandPlayer", source, randomP)
    end
    addEvent("StartRandom", true)
    addEventHandler("StartRandom", resourceRoot, getrp)
    
    -- Client Side
    function dxUI(randomP)
        ui["BG"] = dxDrawImage(x*741,0,x*619,y*487,"files/BG.png")
        ui["title"] = dxDrawText(title, 0, y*70, x*1340, 0, tocolor(255, 255, 255, 255), 1, titleFont, "right")
        ui["playerWon"] = dxDrawText(tostring(getPlayerName(randomP)), x*860, y*242,0,0, tocolor(255, 255, 255, 255), 1, playerFont)
    end
    addEvent("getRandPlayer", true)
    addEventHandler("getRandPlayer", root, dxUI)
    
    function ghore(CMD, ...)
        if (ghoreStatus == 0) then
            ghoreStatus = 1
            local EnteredTitle = table.concat ( { ... }," " )
            title = tostring(EnteredTitle)
            addEventHandler("onClientRender", getRootElement(), dxUI)
            triggerServerEvent("ElameShorueGhore", root)
            triggerServerEvent("StartRandom", root, localPlayer)
        end
    end
    addCommandHandler("ghore", ghore)


     

    I redid the code, code below

     

    --Server Side
    
    local rPlayer 
    
    function getrp( source, commandName )
    	randomP = getRandomPlayer()
    	rPlayer = randomP
    end
    addEvent("StartRandom", true)
    addEventHandler("StartRandom", root, getrp)
    
    addCommandHandler('ghore',
    	function(player, cmd, ...)
    		if ghoreStatus == 0 then
    			ghoreStatus = 1
    			local EnteredTitle = table.concat ( { ... }," " )
    			title = tostring(EnteredTitle)
    			triggerEvent("StartRandom", root, localPlayer)
    			outputChatBox("Ghor'e Keshi Shodu Shod! Ba Dasture [/sherkat] Dar Ghore Keshi Sherkat Konid!")
    			if rPlayer and title then
    				triggerClientEvent(root, 'receptRender', root, rPlayer, title)
    			end
    		end
    	end
    )
    
    -- Client Side
    
    local randomP
    local title
    
    function dxUI()
        --dxDrawImage(741,0,619,487,"files/BG.png")
        dxDrawText(title, 0, 70, 1340, 0, tocolor(255, 255, 255, 255), 1, 'default', "right")
        dxDrawText(tostring(getPlayerName(randomP)), 860, 242,0,0, tocolor(255, 255, 255, 255), 1, 'default')
    end
    
    function receptRender(rp, tt)
        randomP = rp
        title = tt
        addEventHandler('onClientRender', root, dxUI)
    end
    addEvent('receptRender', true)
    addEventHandler('receptRender', root, receptRender)

     

    Thanks Bro! It Works

  14. Hello!
    Do you know what the problem is?

    --Server Side
    function VoteSystem(title)
    	outputChatBox("Ghor'e Keshi Shodu Shod! Ba Dasture [/sherkat] Dar Ghore Keshi Sherkat Konid!")
    end
    addEvent("ElameShorueGhore", true)
    addEventHandler("ElameShorueGhore", resourceRoot, VoteSystem)
    
    
    function getrp( source, commandName )
    	randomP = getRandomPlayer()
    	triggerClientEvent(source, "getRandPlayer", source, randomP)
    end
    addEvent("StartRandom", true)
    addEventHandler("StartRandom", resourceRoot, getrp)
    --Client Side (Summarized)
    function dxUI(randomP)
        ui["BG"] = dxDrawImage(x*741,0,x*619,y*487,"files/BG.png")
        ui["title"] = dxDrawText(title, 0, y*70, x*1340, 0, tocolor(255, 255, 255, 255), 1, titleFont, "right")
        ui["playerWon"] = dxDrawText(tostring(getPlayerName(randomP)), x*860, y*242,0,0, tocolor(255, 255, 255, 255), 1, playerFont)
    end
    addEvent("getRandPlayer", true)
    addEventHandler("getRandPlayer", root, dxUI)
    
    function ghore(CMD, ...)
        if (ghoreStatus == 0) then
            ghoreStatus = 1
            local EnteredTitle = table.concat ( { ... }," " )
            title = tostring(EnteredTitle)
            addEventHandler("onClientRender", getRootElement(), dxUI)
            triggerServerEvent("ElameShorueGhore", root)
            triggerServerEvent("StartRandom", root)
        end
    end
    addCommandHandler("ghore", ghore)

    I keep getting this warning in debugscript:

    Warning: ghore\server.lua:10: Bad argument @'triggerClientEvent' [Expected string at argument 1, got nil]

    Warning: ghore\client.lua:19: Bad argument @'getPlayerName' [Expected player at argument 1, got nil]

    Warning: ghore\client.lua:19: Bad argument @'getPlayerName' [Expected player at argument 1, got nil] [DUP x214]

    Warning: ghore\client.lua:19: Bad argument @'getPlayerName' [Expected player at argument 1, got nil] [DUP x215]

  15. 2 hours ago, shishani said:

    did it help you? let me know

    It Works To Some Extent!❤️

    I made the previous code more complete and still dxDrawText placed under guiCreateStaticImage!

    Server:

    function VoteSystem(title)
    	outputChatBox ("Your Vote Title: " .. title, client)
    end
    addEvent("VoteConnection", true)
    addEventHandler("VoteConnection", resourceRoot, VoteSystem)

    Client:

    sx, sy = guiGetScreenSize()
    ClientGUI = {}
    VoteStatus = false
    
    function votepanel()
        VoteStatus = true
        ClientGUI[3] = guiCreateStaticImage(0, 0, sx, sy, "/files/BG.png", false)
        ClientGUI[4] = guiCreateStaticImage(sx*0.85, sy*0.08, sx*0.1, sy*0.1, "/files/exit.png", false)
        ClientGUI[5] = guiCreateStaticImage(sx*0.3, sy*0.3, sx*0.4, sy*0.09, "/files/yes.png", false)
        ClientGUI[6] = guiCreateStaticImage(sx*0.3, sy*0.41, sx*0.4, sy*0.09, "/files/no.png", false)
        showCursor(true)
    end
    
    addCommandHandler("ray", function()
        votepanel()
    end)
    
    function HideVotePanel()
        for i, v in pairs(ClientGUI) do
            if (v) then
                destroyElement(v)
            end
        end
        VoteStatus = false
        showCursor(false)
    end
    
    addEventHandler("onClientGUIClick", root, function()
        if (VoteStatus) then
            if (source == ClientGUI[4]) then
                HideVotePanel()
            end
        end
    end)
    
    function VoteCommand (commandName, ...)
        local title = table.concat ( { ... }," " )
        TextDraw = tostring(title)
        triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
        addEventHandler("onClientRender",root,render) 
        outputChatBox(title)
    end
    addCommandHandler ( "vote", VoteCommand )
    
    function render()
        ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)
    end

    Many Thanks!

  16. Hello!
    I ran into some problems while coding:

    Server:
    function VoteSystem(title)
    	outputChatBox ("Your Vote Title: " .. title, client)
    end
    addEvent("VoteConnection", true)
    addEventHandler("VoteConnection", resourceRoot, VoteSystem)
    Client:
    sx, sy = guiGetScreenSize()
    ClientGUI = {}
    function VoteCommand (commandName, ...)
        local title = table.concat ( { ... }," " )
        TextDraw = tostring(title)
        triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
        outputChatBox(title)
    end
    addCommandHandler ( "vote", VoteCommand )
    
    
    --ClientGUI[3] = guiCreateStaticImage( sx*0.03, sy*0.03, sx*0.5, sy*0.5, "/files/BG.png", false )
    guiMoveToBack(ClientGUI[3])
    addEventHandler("onClientRender", root, function()
        ClientGUI[2] = dxDrawRectangle(sx*0.2, sy*0.3, sx*0.6, sy*0.5, tocolor(0,0,0,150))
        ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)
    end)

    After running the code and entering /debugscript 3, the following error appears:

    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x213]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x214]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x215]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x213]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x212]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x79]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x71]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil] [DUP x87]
    WARNING: vote\votes_c.lua:17: Bad argument @'dxDrawText' [Expected string at argument 1, got nil]

    But the code works and by writing /vote [text], the text [text] is entered into dxDrawText

    How do I fix the error?

    The second problem:

    In the client file:

    sx, sy = guiGetScreenSize()
    ClientGUI = {}
    --General
    function VoteCommand (commandName, ...)
        local title = table.concat ( { ... }," " )
        TextDraw = tostring(title)
        triggerServerEvent ( "VoteConnection", resourceRoot, tostring(title) )
        outputChatBox(title)
    end
    addCommandHandler ( "vote", VoteCommand )
    
    
    ClientGUI[3] = guiCreateStaticImage( sx*0.03, sy*0.03, sx*0.5, sy*0.5, "/files/BG.png", false ) -- Image Background
    guiMoveToBack(ClientGUI[3])
    addEventHandler("onClientRender", root, function()
        ClientGUI[2] = dxDrawRectangle(sx*0.2, sy*0.3, sx*0.6, sy*0.5, tocolor(0,0,0,150))
        ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2) -- Title
    end)
    --General ENDho

    How do I put ClientGUI[3] = guiCreateStaticImage( sx*0.03, sy*0.03, sx*0.5, sy*0.5, "/files/BG.png", false )" under "ClientGUI[1] = dxDrawText(TextDraw, sx*0.21, sy*0.31, sx, sy, tocolor(255,0,0,255), 2)?

×
×
  • Create New...