Jump to content

Lpsd

Administrators
  • Posts

    317
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by Lpsd

  1. Version 1.0 has just been released, it's a refactor but keeps all existing API / functionality (better code design and bug fixes).

    Currently this resource only detects a fully lost connection (which only helps for "basic" lag-switches that kill the connection temporarily), however I'll soon be adding basic ping monitoring, with the ability to detect players with highly fluctuating ping / packet loss.

     

    • Thanks 1
  2. You can use https://wiki.multitheftauto.com/wiki/CreateEffect to create fire, and update the position of the effect every frame to match the player's head position, using https://wiki.multitheftauto.com/wiki/GetPedBonePosition (BONE_HEAD).

    The fire in your picture looks like a custom effect - probably part of the model itself or some kind of tricky shader... however you should still get fairly close with what I suggested.

  3. As far as I'm aware the latest XP/Vista builds use 76.1.13+gf19c584+chromium-76.0.3809.132

    The latest 1.5.8 nightly builds use 91.1.12+gcf0c26a+chromium-91.0.4472.101

    XP and Vista are blockers to many potential updates and new features, your OS is 15 years old. Consider upgrading if you want to have access to modern software and features.

  4. You are not providing a callback to your `UPDATE` query - which means dbPoll is not being called on the query handler, resulting in the query not being freed.

    You should instead use dbExec, instead of dbQuery, for your `UPDATE` query - providing you don't need to do anything once the query has completed. Otherwise, see the wiki page for dbQuery on providing a callback function with dbPoll.

    Regarding your problem with auto increment. You cannot set a text/string type column to auto increment. Auto increment is limited to INT type columns. You should have an additional column (at the start) called `id`, with INT type, which is set to UNIQUE Key and Auto Increment.

    • Like 1
  5. Try this

    addEvent("onSettingChange", true)
    addEventHandler("onSettingChange", localPlayer,
    function(variable, value)
    	if variable == "draw_distance" then
    		local state = not (value == "Off")
    		draw.setVisible(state, true)
    	end
    end)
    
    
    function draw.setVisible(visible, notifyDisplay)
    	draw.visible = visible and true or false  
    	draw.changeDistance(draw.visible)
    	if notifyDisplay then
    		triggerEvent("notification:create", localPlayer, "Draw distance", "is now "..(draw.visible and "ON" or "OFF"))
    	end
    end
    
    function draw.changeDistance(max)
        for i,object in pairs(getElementsByType("object")) do
            if isElement(object) then
                local elementID = getElementModel(object)
    			engineSetModelLODDistance(elementID, max and 325 or 100)
            end
        end
    end
    
    function initialize()
    	draw.setVisible(true, false)
    end
    addEventHandler("onClientResourceStart", resourceRoot, initialize)

    Your code had all sorts of logic errors, especially with the onClientResourceStart, which was only being added when you ran draw.setVisible, but also being attached for all resources, instead of just the current one. It would never run for the current resource that way.

     

     

    • Like 1
  6. Can you explain in more detail what you mean by object vs array? Are you referring to JSON data format?

    If you're referring to element (object) data storage, versus standard storage in Lua tables, then Lua tables are always going to perform better. However, some more understanding of what you mean / what you're trying to do would help explain it :) 

  7. @salh You are storing the password in plain text. This is NOT recommended in any circumstances! (you are breaking European law)

    I would advise you to remove this code from your server immediately and replace it with a secure login system. Please see the tutorial topic that I sent above.

  8. No, copying that code would not work because you have 2 undefined functions.

    Furthermore, as stated, this is a bad way to create a remember me functionality because you appear to be storing the password in plaintext (which is illegal if you're accepting European traffic by the way - and just bad practice in general). Instead, you should be using a token system as explained in the linked tutorial

    • Like 1
  9. The "getPedTargetStart" function will retrieve the starting point of the target range. This target range is probably linked to the camera position (I'm not entirely sure though), which would explain why your camera is "always moving forward"

    Let's say the target start range is always 1 unit in front of the camera. Your camera position is set to 0. Then you set the camera position to the start range (1), and the start range then subsequently changes to 2. This will happen forever whilst you are zoomed in.

    You should store the initial target start position, instead of getting it on each frame. This can be done quite easily.

    local targetStartPos = false
    
    function aim_test ()
        if getControlState("aim_weapon") == true and getPedWeapon(localPlayer) == 34 then
    		if not targetStartPos then
    			local startX, startY, startZ = getPedTargetStart(localPlayer)
    			targetStartPos = {x = startX, y = startY, z = startZ}
    		end
    		
    		local x, y, z = targetStartPos.x, targetStartPos.y, targetStartPos.z
    		
    		local x2,y2,z2 = getPedTargetEnd(localPlayer)
    		
    		if not x2 then
    			return false
    		end            
    		
    		local x3,y3,z3 = getPedTargetCollision(localPlayer)
    		
    		if x3 then
    			setCameraMatrix(x,y,z,x3,y3,z3)
    		else
    			setCameraMatrix(x,y,z,x2,y2,z2)
    		end
        else
            if not getCameraTarget(localPlayer) then
                targetStartPos = false
                setCameraTarget(localPlayer)
            end
        end
    end
    addEventHandler("onClientPreRender",root,aim_test)

    Haven't tested, but I'm fairly certain that should fix your issue.

    • Like 2
  10. Currently, JSON is better for something like that. You can store that information in a database (which is way more efficient than reading/writing XML files)

    I would give an example, but there really isn't much to show.

    • Like 1
  11. Yeah, your arguments are all messed up. unix_socket should be part of the second argument, the string is also formatted incorrectly.

    dbConnect("mysql", "dbname="..databaseName..";host="..databaseHost..";unix_socket=/var/run/mysqld/mysqld.sock", databaseUsername, databasePassword, "autoreconnect=1")

     

×
×
  • Create New...