Heshan_Shalinda_eUnlock Posted October 7, 2021 Share Posted October 7, 2021 I have created a script to change the player seat on clientGUIClick and I have created a window and add buttons, etc.... It works 90% good, But my problem is, when I enter a vehicle and click the seat I'm now sitting on in the GUI Button my current seat will change to some other seat. And If there will be a player on the seat I will change after clicking the GUI that player will be switched to my previous seat. I need some help fixing this. -- Client Side Part -- GUIEditor.button[9] = guiCreateButton(0.02, 0.11, 0.12, 0.22, "Seat 01", true, GUIEditor.window[1]) GUIEditor.button[10] = guiCreateButton(0.02, 0.36, 0.12, 0.22, "Seat 03", true, GUIEditor.window[1]) GUIEditor.button[11] = guiCreateButton(0.15, 0.11, 0.12, 0.22, "Seat 02", true, GUIEditor.window[1]) GUIEditor.button[12] = guiCreateButton(0.15, 0.36, 0.12, 0.22, "Seat 04", true, GUIEditor.window[1]) local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function changeSeat01() triggerServerEvent("changeSeat01", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[9], changeSeat01, false) -- Server Side Part -- function findFreeVehicleSlot(vehicle) local seat_count = 1 + getVehicleMaxPassengers( vehicle ) for slot_off=1,seat_count do local sitting_ped = getVehicleOccupant( vehicle, slot_off - 1 ) if (sitting_ped == false) then -- is no ped sitting on that slot? return slot_off - 1 -- return the free slot index end end -- There is no free slot so return false. return false end 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 end end addEvent ("changeSeat01", true) addEventHandler ("changeSeat01", root, changeSeat01) I think I have added all the details I must add to solve my problem. Need help to fix this problem. Thank you very much for helping me using your valuable time. Link to comment
Heshan_Shalinda_eUnlock Posted October 13, 2021 Author Share Posted October 13, 2021 Don't worry I have found out how to do it without any help thank you... Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now