Jump to content

Help with a script.


Recommended Posts

addCommandHandler("speednode", 
    function() 
        if exports.global:isPlayerScripter(getLocalPlayer()) then 
            outputChatBox(findNodeClosestToPoint(vehicleNodes, getElementPosition(getLocalPlayer())).id) 
        end 
    end 
) 
  
local speedlimits90 = 
{ 
    -- node1, node2 
  
    { 786819, 1311230 }, 
    { 786747, 852334 }, 
    { 786741, 852258 }, 
    { 786817, 786715 }, 
    { 1311150, 786827 }, 
    { 786827, 786818 }, 
  
} 
  
for _, node in ipairs( speedlimits90 ) do 
    local path = calculatePathByNodeIDs( node[1], node[2] ) 
    for key, value in ipairs(path) do 
        value.speedlimit = 90 
        -- createBlip( value.x, value.y, value.z, 0, 1, 0, 255, 0 ) 
    end 
end 
  
local speedlimits120 =  
{ 
    { 786747, 721310 }, 
    { 786741, 721310 }, 
    { 983594, 983587 }, 
    { 983587, 918112 }, 
    { 918112, 1441850 }, 
  
} 
  
for _, node in ipairs( speedlimits120 ) do 
    local path = calculatePathByNodeIDs( node[1], node[2] ) 
    for key, value in ipairs(path) do 
        value.speedlimit = 120 
        -- createBlip( value.x, value.y, value.z, 0, 1 ) 
    end 
end 
  
setTimer( 
    function() 
        local x, y, z = getElementPosition(getLocalPlayer()) 
        setElementData( getLocalPlayer(), "speedo:limit", x > 50 and y < -650 and (findNodeClosestToPoint(vehicleNodes, x, y, z).speedlimit or 60), false) 
    end, 500, 0 
) 

Above is the script that outputs the speedlimit to the client, we understand that typing /speednode will display the current node, but I do not have any idea how to configure it out.

Im trying to script it for a friend of mine, and said I will ask here, as I have never worked with nodes before.

Link to comment

We got this script from someone who ustu run it in Los Santos, but now were out in the country we need to change the nodes to the roads we want to dispay the speed limits.

I just have no idea how the script works, Obviously I type /speednode where I want the road to start, then again where it ends, and by my understanding, that is the two nodes ( node1, node2) and then whatever is in between will be the speed limit area, and should display the speed limit, but it doesnt.

Link to comment

Thats the only script, there is one more that contains the simple Speedo, and the speedimit inside it but that has nothing to do with the location of the nodes, that simply draws a box containing the speed limit.

EG: If I go to the LS places where I know the speedlimits display, they will actually display, so its just a point of working out the above code, and how to change them, I just need to figure out the nodes, and weather my theroy of one node at the start of the road and one at the end is correct.

This is the only resource that contains anything about the speed limits except for the speedo.

Link to comment

Ahh, I'm seeing it now. From what I can tell, you are correct for the most part. A node is placed at every road intersection or along key points on a curve. The real question is the ordering of the nodes - N then S, E then W, stuff like that.

I'd say you should experiment with point close to 0, 0, 0 for simplicity's sake.

Link to comment

I tested this all day earlier. I got the two nodes via the command, put them in the text in the format of:

{ 10000, 20000 },

But say I was on the road, inbetween the two points that I put in the script, nothing would display, even if I sat on the first node, eg: 10000. Still the speed limit wouldnt display. Thats what I am stuck on. But I know the script is working perfectly, as I tested the roads in LS that was already pre-configured.

Link to comment

How about this:

Look at the LS nodes, and create blips at each node. Find too related nodes, and see how their definition in the script relates to their 3D representation.

If you've already done this, I'd suggest trying to contact the scripts owner.

Another thing is that maybe you should post the 'findNodeClosestToPoint' and 'calculatePathbyNodeIDs' functions here, as there *might* be some sort of small bug there.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...