Jump to content

IIYAMA

Moderators
  • Posts

    6,084
  • Joined

  • Last visited

  • Days Won

    215

Posts posted by IIYAMA

  1. 19 hours ago, eksorz said:

    No, like this:

    You have to put it at the location where you want to make your trace. If you do not put it inside of another function, it will return "in main chunk", because it is tracing function calls starting from the main chunk.

    For example:

    function test1()
      test2() -- call test2
    end
    
    function test2()
      test3() -- call test3
    end
    
    function test3()
      test4() -- call test4
    end
    
    function test4()
      -- ENDS HERE
      print(debug.traceback())
    end
    
    test1() -- STARTS HERE

    Will return:

    stack traceback:
    	Main.lua:14: in function 'test4'
    	Main.lua:10: in function 'test3'
    	Main.lua:6: in function 'test2'
    	Main.lua:2: in function 'test1'
    	Main.lua:17: in main chunk
    	[C]: in ?

    It will show all functions that have been called.

    And for your current code, it might give you the function(s) where, your onClick got lost.

     

  2. 1 hour ago, eksorz said:

    I printed the traceback method you gave me right after creating the Button object. In the line I printed, it said "in main chunk", I don't know what it means.

    Like this?

    function createButton(config)
        local self = setmetatable({}, Button)
        iprint(debug.traceback())
        self.x = config.x
        self.y = config.y
        self.width = config.width
        self.height = config.height
        self.text = config.text or "Button"
        self.color = config.color or "blue"
        self.fade = config.fade ~= false
        self.onClick = config.onClick or false -- // This always returns false, even if I added onClick function.
        self.alpha = self.fade and 0 or 255
        self.fade_step = 15
        self.visible = true
    
        self.currentColor = Theme.colors.button[self.color].background
    
        table.insert(activeButtons, self)
    
        return self
    end

     

  3. Quote

    I am sure that the problem is not in the injectModules() function. There is a prepared Window class next to the Button class, I can use it as Window({...}) by using the injectModules() function. Similarly, I can print the button and get the argument variables by using Button({...}). Only function operations return "nil" value.

    Hmm.

     

    Can you show a trackback from your button constructor?

    iprint(debug.traceback())

    Just to get an idea trough how many other functions it's constructed. Not sure what the results are, but it might give you some other places to look at and find where your value gets lost.

    Make sure to only construct one thing at the time, else it generates too much.

  4. 11 hours ago, eksorz said:

    it always returns the value as "nil".

    One of the common problems is that function values are not clone able. Functions rely on their context and can therefore not being copied to another context.

    But not sure if that is the issue.

     

    For the Button class I am missing some context. In the first file it is used as a metatable.

    And in the second file it is used as a function. (which might also be a metatable, but I am unable to verify it because it is missing)

     

    11 hours ago, eksorz said:
    loadstring(exports.ui:injectModules())()
    

    Is this export importing Button.lua?

     

    Other:

     

  5. 2 hours ago, DonnySheffield said:

    Any idea why this could happen?

    It is on the top of the code, just running once at the beginning.

    Could you explain why you put it there? Just so that I can understand the context of that variable placement, because normally you wouldn't put it there unless there is a specific reason.

  6. 21 hours ago, Bishop_G said:

    Is this an attack? How can I prevent this?

    It is indeed a kind of attack. It means that the player is able execute clientside-code on demand.

     

    The attacker is triggering 'known generic events' which might be handled by the server. The ones that are unknown are in your logs, the ones that are known and trigger able are not.

    But that does not mean that the ones that did trigger didn't cause unwanted results. You might want to consider to restart the resources, just to make sure there is no memory leak.

     

    The event which AngelAlpha mentioned can indeed help with detecting that kind of attacks. 

    As an extend you can also add a honeypot, which in this case are 'unkown' events for your server but know for other servers. When a player uses this kind of attack again, you can ban them automatic. You might want take a closer look at your logs for candidates (for example money related).

    There is also this event:
    https://wiki.multitheftauto.com/wiki/OnPlayerTriggerEventThreshold

     

    But be careful with automating things, always test these kind of stuff or you might accidentally nuke your own player base.

    • Like 1
    • Thanks 1
  7. 8 hours ago, DarkStalker30 said:

    If character will be in water while player has black screen by fadeCamera() and HUD off, will it trigger breath bar?

    It will probably be visible when the camera is fade out. So yes you need to add some more exceptions for unexpected situations.

    This condition might catch some of the problems:

    if getCameraTarget () ~= localPlayer then return end

     

  8. 22 hours ago, J4cobLIVEmain said:

    Do you guys have any suggestion, how it could be done?

    Maybe move the checkpoint very high in the air (and replace it with a dummy).

    When the rocks are cleared, move it back.

    • Like 1
  9. 3 hours ago, Bishop_G said:

    Please someone help me.I will be very appreciative of this.

    It is a permission issue.

    https://wiki.multitheftauto.com/wiki/Server_Commands#aclrequest

    First verify if the meta.xml has any acl request listed in it's meta.xml

    /aclrequest list <resourceName> all

     

    And if loadstring is listed, grand permission.

    /aclrequest allow <resourceName> all

     

    If not listed, add it to the meta.xml of the resource:

        <aclrequest>
            <right name="function.loadstring" access="true" />
        </aclrequest>

    See example: https://wiki.multitheftauto.com/wiki/Meta.xml

    Run:

    /refreshall

     

    And try the aclrequest commands again.

    • Thanks 1
  10. 40 minutes ago, King12 said:

    Failed to accept map: Missing required fields: adminName, action, mapName

    Are you sure your API is capable of accepting JSON?

    fetchRemote(url, {
    	method = "POST",
    	formFields = {
    		adminName = "",
    		action = "",
    		mapName = ""
    	},
    }, function(responseData, responseInfo)
            

     

    If JSON is expected, see also this comment on the wiki page:

    Quote

    Warning: When using toJSON for submitting data, make sure to use string.sub(data, 2, -2) to remove the initial and final brackets, as many APIs will not understand the request

    postData = string.sub(postData, 2, -2) 
  11. Thank you for your support to the community, it was an honor to have met you and I hope we meet again one day.

    I wish you the best of luck! 😘

    • Like 1
  12. 7 hours ago, MrCode said:

    Thanks IIYAMA, FindRotation3D worked for the getting rotation. 🙏


    Did not achieve the desired result with a rocket projectile (19) though. Even after rotating it directly at point_B the projectile eventually starts heading out in a different direction, not exactly sure whats up with that. I think an easy way to fix that is using createObject along with moveObject and stuff, but in this case, what should I use to properly send projectiles from point A to point B since createProjectile only has starting position arguments to work with?

    Are you using this function?

    https://wiki.multitheftauto.com/wiki/CreateProjectile
     

    Attach a dummy vehicle to the object and set the vehicle as the creator of the projectile.

    Because else your camera is used for the direction.

  13. 3 hours ago, XeroXipher said:

    But how do I render the HUD without onClientRender()?

    As Justn and me mentioned:

    On 14/02/2025 at 18:34, IIYAMA said:

    Just a thing that can lead up to a crash:

    • By putting dxCreateFont/dxCreateTexture/dxCreateScreenSource(everything with Create in it's name) inside of an onClientRender triggered function

     

    Move this line to the top of your code:

    16 hours ago, XeroXipher said:
     local Inventory = dxCreateTexture("Inventory.png")

     

    Like this:

    local sx,sy = guiGetScreenSize()
    local px,py = 1600,900
    local x,y =  (sx/px), (sy/py)		
    
    local Inventory = dxCreateTexture("Inventory.png") -- just put it here and not inside of HUDDrawing.
    
    function HUDDrawing()
    
      --[[ ... ]]

     

     

  14. 15 hours ago, XeroXipher said:

    I think that's why it is crashing.

    Is there a better way to use dxDrawRect and dxDrawText then onClientRender?

    The following functions shouldn't cause crashes:

    https://wiki.multitheftauto.com/wiki/DxDrawRectangle

    https://wiki.multitheftauto.com/wiki/DxDrawText

     

    But you most likely did crash because of a memory leak. To find the reason I will need to look at your code for that.

    Just a thing that can lead up to a crash:

    • By putting dxCreateFont/dxCreateTexture/dxCreateScreenSource(everything with Create in it's name) inside of an onClientRender triggered function

     

     

  15. On 21/01/2025 at 19:10, MrCode said:

    So perhaps fileExists being used onClientRender

    I wouldn't run that function either in combination with onClientRender.

    Since you are fetching the file from another resource, you could increase or decrease the download priority for either resource.

    https://wiki.multitheftauto.com/wiki/Meta.xml

    Or just wait a little bit longer before start rendering.
    (I also recommend to convert the image into a texture before rendering)

  16.  

    27 minutes ago, bravura said:

    Sorry, to be honest I don't know

    14 hours ago, bravura said:

    from the console I can do everything

    The Console has full access, so it might be possible that you currently have no access to begin with.

     

    Steps to add the initial admin account (later on you can add more admins ingame using the User Interface):

    1. Stop the server
       
    2. Open the ACL file: MTA San Andreas 1.6\server\mods\deathmatch\acl.xml
       
    3. Make a back up of this ACL file
       
    4. Scroll to (in the original one):
          <group name="Admin">
              <acl name="Moderator"></acl>
              <acl name="SuperModerator"></acl>
              <acl name="Admin"></acl>
              <acl name="RPC"></acl>
              <object name="resource.admin"></object>
              <object name="resource.webadmin"></object>
              <object name="resource.acpanel"></object>
          </group>

       

    5. Add an account looking like this:
              <object name="user.example"></object>
      Replace example with your username even if the account does not exist yet. (keep it simple)

      And add it like this:
          <group name="Admin">
              <acl name="Moderator"></acl>
              <acl name="SuperModerator"></acl>
              <acl name="Admin"></acl>
              <acl name="RPC"></acl>
              <object name="resource.admin"></object>
              <object name="resource.webadmin"></object>
              <object name="resource.acpanel"></object>
              <object name="user.example"></object>
          </group>
    6. Save the file
       
    7. Start the server again (if you broke the syntax of the file, the server will not start, that is why step 3 so you can start over)
       
    8. Go ingame
      1. Add the account if not exist: /register <example username> <new password>
      2. /login <example username> <current password>

     

     

     

×
×
  • Create New...