Jump to content

Error : Loading Script Failed: Car_controlpanel03


Recommended Posts

9 minutes ago, Heshan_Shalinda_eUnlock said:

Is this Correct dude

?

I think this is good you are teaching me lot........?

function changeSeat01 ( )
    thePed = client
    theVehicle = getPedOccupiedVehicle ( thePed )
    if ( theVehicle ) then
        local sitting_ped = getVehicleOccupant( theVehicle, 0 )

        warpPedIntoVehicle ( thePed, theVehicle, 0 )

        if (sitting_ped) then
            local free_slot = findFreeVehicleSlot( theVehicle )

            if (free_slot) then
                warpPedIntoVehicle( sitting_ped, theVehicle, free_slot )
            end
        end

        outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." )
    end
end

Here is the real solution. Why did you change the function I gave you?

Edited by The_GTA
Link to comment
19 minutes ago, The_GTA said:
function changeSeat01 ( )
    thePed = client
    theVehicle = getPedOccupiedVehicle ( thePed )
    if ( theVehicle ) then
        local sitting_ped = getVehicleOccupant( theVehicle, 0 )

        warpPedIntoVehicle ( thePed, theVehicle, 0 )

        if (sitting_ped) then
            local free_slot = findFreeVehicleSlot( theVehicle )

            if (free_slot) then
                warpPedIntoVehicle( sitting_ped, theVehicle, free_slot )
            end
        end

        outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." )
    end
end

Here is the real solution.

I don't know why I was not able to make this function correctly and by the thanks.

Quote

Why did you change the function I gave you?

I thought that this is the seat numbers.

Quote

slot_off=1

Could you please tell me

Quote

sitting_ped = getVehicleOccupant( vehicle, slot_off - 1 )

What is this -1 ?

I don't understand it. I think your script will works fine because there are no errors in the console and all the button clicks works fine because I can not find a person to test it now.

 

 

 

And I have another problem why these windows are showing for only one person I don't understand???

Quote

-- Client Side --

local function open_event(wndid)
    local playerVehicle = getPedOccupiedVehicle ( source )
    if ( playerVehicle ) then
        if setVehicleWindowOpen( playerVehicle, wndid, not isVehicleWindowOpen( playerVehicle, wndid ) ) then
            outputChatBox( "Driver Window Switched" )
        else
            outputChatBox( "You don't have window!" )
        end
    end
end
local function open_request()
    triggerServerEvent("onVehicleWindowOpenRequest", root, seatWindows[0]);
end
addCommandHandler("open", open_request)
addEvent("open", true)
addEventHandler( "open", localPlayer, open_event )
addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open_request )

Quote

-- Server Side --

addEvent("onVehicleWindowOpenRequest", true);
addEventHandler("onVehicleWindowOpenRequest", root,
    function(wndid)
        triggerClientEvent("open", client, wndid);
    end
);

 

Link to comment
11 minutes ago, Heshan_Shalinda_eUnlock said:

I don't understand it. I think your script will works fine because there are no errors in the console and all the button clicks works fine because I can not find a person to test it now.

Seat number 1 is C array index 0 in the game. A technical detail that I wanted to spare you.

 

11 minutes ago, Heshan_Shalinda_eUnlock said:

And I have another problem why these windows are showing for only one person I don't understand???

I told you that I wanted to limit this to players that are joined only. Any players that join after you have opened or closed a window will not see the effect. So there are cases where the logic is not entirely synchronized. You should open a new topic if you want to have help on that.

Edited by The_GTA
Link to comment
2 hours ago, The_GTA said:

Whenever you fire an event inside of MTA it is propagated to its children and parents. This is done by design: you can reach every subscriber by triggering an event on the root element but you can limit yourself to possibly just one subscriber or the root if you trigger it on a specific element. Read up on the MTA event system here. Since there is no good illustration of the event propagation space, which you should always keep in mind, here is a mock-up made by me:

event_propagation_space.png

As you see, since you clicked on window1, the event was pushed to button1, button2 and root aswell. On each button you have told the event handler by using the implicit parameter propagate = true to the addEventHandler call of the onClientGUIClick event that you want to trigger if even the window told you about it. So how do you prevent listening to clicks on windows? You can use...

addEventHandler("onClientGUIClick", button,
  function()
    -- YOUR CODE HERE.
  end
, false)

to just listen to the click event on the button itself. You can easily adjust your previous code by adding a "false" parameter as fourth parameter to any addEventHandler call done based on your buttons. Hope this helps!

I got it and done it Correctly and It works 100% fine and thanks for it.

 

Now please tell me how to make the GUI visible to all players who uses different resolutions as same.

I mean I want to show Same GUI for all the players equally.

Quote

        GUIEditor.window[1] = guiCreateWindow(400, 500, 478, 216, "Car Control Panel", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(28, 35, 113, 37, "Engine On/Off", false, GUIEditor.window[1])
        GUIEditor.button[2] = guiCreateButton(182, 36, 113, 36, "Front Left Door", false, GUIEditor.window[1])
        GUIEditor.button[3] = guiCreateButton(182, 97, 113, 37, "Rear Left Door", false, GUIEditor.window[1])
        GUIEditor.button[4] = guiCreateButton(322, 35, 114, 37, "Front Right Door", false, GUIEditor.window[1])
        GUIEditor.button[5] = guiCreateButton(323, 97, 113, 37, "Rear Right Door", false, GUIEditor.window[1])
        GUIEditor.button[6] = guiCreateButton(182, 158, 113, 37, "Hood", false, GUIEditor.window[1])
        GUIEditor.button[7] = guiCreateButton(323, 158, 113, 37, "Dickey", false, GUIEditor.window[1])
        GUIEditor.button[8] = guiCreateButton(28, 158, 113, 37, "Lights", false, GUIEditor.window[1])
        
        
        GUIEditor.window[2] = guiCreateWindow(957, 513, 138, 138, "Change Seat", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[9] = guiCreateButton(10, 25, 55, 50, "Seat 01", false, GUIEditor.window[2])
        GUIEditor.button[10] = guiCreateButton(10, 80, 55, 48, "Seat 03", false, GUIEditor.window[2])
        GUIEditor.button[11] = guiCreateButton(73, 25, 53, 50, "Seat 02", false, GUIEditor.window[2])
        GUIEditor.button[12] = guiCreateButton(73, 80, 53, 47, "Seat 04", false, GUIEditor.window[2]) 
        
        
        GUIEditor.window[3] = guiCreateWindow(129, 311, 105, 121, "Open Shutters", false)
        guiWindowSetSizable(GUIEditor.window[3], false)

        GUIEditor.button[13] = guiCreateButton(9, 27, 41, 39, "Shutter 01", false, GUIEditor.window[3])
        GUIEditor.button[14] = guiCreateButton(54, 71, 41, 39, "Shutter 04", false, GUIEditor.window[3])
        GUIEditor.button[15] = guiCreateButton(54, 27, 41, 39, "Shutter 02", false, GUIEditor.window[3])
        GUIEditor.button[16] = guiCreateButton(10, 71, 40, 39, "Shutter 03", false, GUIEditor.window[3])    
 

This is my GUI I think this isn't in relative mode.

Is relative mode means using this

Quote

        GUIEditor.window[1] = guiCreateWindow(0.4, 0.5,0. 478, 0.216, "Car Control Panel", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

instead of using this

Quote

        GUIEditor.window[1] = guiCreateWindow(400, 500, 478, 216, "Car Control Panel", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

Am I correct ?

Link to comment
9 minutes ago, Heshan_Shalinda_eUnlock said:

Now please tell me how to make the GUI visible to all players who uses different resolutions as same.

There is no such thing. You UI will always look different because of screen DPI or different aspect ratios.

9 minutes ago, Heshan_Shalinda_eUnlock said:

This is my GUI I think this isn't in relative mode.

Relative mode is one way to stretch the UI to factored screen-space dimensions. For example, 0.5 is always the middle of the screen in each dimension if a position coordinate. 0.5 is always half the screen dimension width or height, respectively.

Please take a look at the documentation of guiCreateWindow:

guiCreateWindow - Multi Theft Auto: Wiki

There you will see that you have to set the 6th parameter relative to true if you want to use relative mode. Hence, your script excerpt should look like this:

        GUIEditor.window[1] = guiCreateWindow(0.4, 0.5, 0.478, 0.216, "Car Control Panel", true)
        guiWindowSetSizable(GUIEditor.window[1], false)

Adjust all the other GUI creation logic with the same principle.

---

Like a good teacher, there is always a time he shakes your hand and lets you free into this world. For now I wish you good luck with your scripting career. I think you have learned a lot on this. Your original problem has been solved. Have a nice time inside the MTA community! ?

Edited by The_GTA
Link to comment
10 minutes ago, The_GTA said:

There is no such thing. You UI will always look different because of screen DPI or different aspect ratios.

Relative mode is one way to stretch the UI to factored screen-space dimensions. For example, 0.5 is always the middle of the screen in each dimension if a position coordinate. 0.5 is always half the screen dimension width or height, respectively.

Please take a look at the documentation of guiCreateWindow:

guiCreateWindow - Multi Theft Auto: Wiki

There you will see that you have to set the 6th parameter relative to true if you want to use relative mode. Hence, your script excerpt should look like this:

        GUIEditor.window[1] = guiCreateWindow(0.4, 0.5, 0.478, 0.216, "Car Control Panel", true)
        guiWindowSetSizable(GUIEditor.window[1], false)

Adjust all the other GUI creation logic with the same principle.

---

Like a good teacher, there is always a time he shakes your hand and lets you free into this world. For now I wish you good luck with your scripting career. I think you have learned a lot on this. Your original problem has been solved. Have a nice time inside the MTA community! ?

I don't know how to thank you for helping me this much but as a student I will do wonderful things in the future thank you very much for helping me.

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...