Heshan_Shalinda_eUnlock Posted October 4, 2021 Share Posted October 4, 2021 Error : Loading Script Failed: Car_controlpanel03\ccp_s.lua : 20 : '<' expected near 'open' I am making a script to 1.control vehicle doors open and close 2.Engine on/off 3.Lights on/off 4.change vehicle seats 5.open shutters of the vehicle I need help for this problem --Client Side Script -- --ccp_c.lua-- GUIEditor = { button = {}, window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() 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]) local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function OpenDoor1() triggerServerEvent("OpenDoor1", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[2], OpenDoor1) function OpenDoor2() triggerServerEvent("OpenDoor2", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[4], OpenDoor2) function OpenDoor3() triggerServerEvent("OpenDoor3", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[3], OpenDoor3) function OpenDoor4() triggerServerEvent("OpenDoor4", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[5], OpenDoor4) function OpenDoor5() triggerServerEvent("OpenDoor5", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[6], OpenDoor5) function OpenDoor6() triggerServerEvent("OpenDoor6", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[7], OpenDoor6) function switchEngine() triggerServerEvent("switchEngine", localPlayer) -- use localPlayer as a sourceElement, it is best choice, because root/resourceRoot could contain extra elements end addEventHandler("onClientGUIClick", GUIEditor.button[1], switchEngine) function changeSeat01() triggerServerEvent("changeSeat01", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[9], changeSeat01) function changeSeat02() triggerServerEvent("changeSeat02", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[11], changeSeat02) function changeSeat03() triggerServerEvent("changeSeat03", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[10], changeSeat03) function changeSeat04() triggerServerEvent("changeSeat04", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[12], changeSeat04) function consoleVehicleLights() triggerServerEvent("consoleVehicleLights", localPlayer) end addEventHandler ( "onClientGUIClick", GUIEditor.button[8], consoleVehicleLights ) function open() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 4, not isVehicleWindowOpen( playerVehicle, 4 ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open", open) addEvent("open", true) addEventHandler( "open", localPlayer, open ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open ) function open2() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 2, not isVehicleWindowOpen( playerVehicle, 2 ) ) then outputChatBox( "Front Right Window switched" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open2", open2) addEvent("open2", true) addEventHandler( "open2", localPlayer, open2 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[15], open2 ) function open3() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 5, not isVehicleWindowOpen( playerVehicle, 5 ) ) then outputChatBox( "Back Left Window switched!" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open3", open3) addEvent("open3", true) addEventHandler( "open3", localPlayer, open3 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[16], open3 ) function open4() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 3, not isVehicleWindowOpen( playerVehicle, 3 ) ) then outputChatBox( "Back Right Window switched!" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open4", open4) addEvent("open4", true) addEventHandler( "open4", localPlayer, open4 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[14], open4 ) function guiackapa () if guiGetVisible ( GUIEditor.window[1] ) and guiGetVisible ( GUIEditor.window[2] ) and guiGetVisible ( GUIEditor.window[3] ) then guiSetVisible ( GUIEditor.window[1], false ) guiSetVisible ( GUIEditor.window[2], false ) guiSetVisible ( GUIEditor.window[3], false ) showCursor(false) else guiSetVisible ( GUIEditor.window[1], true) guiSetVisible ( GUIEditor.window[2], true) guiSetVisible ( GUIEditor.window[3], true) showCursor(true) end end addEvent( "ShowGUI", false ) addEventHandler ( "ShowGUI", getRootElement(), guiackapa ) bindKey("F10","down",guiackapa) end ) --End of Client Side Script -- --ccp_c.lua-- --Server Side Script-- --ccp_s.lua-- -- Open All Doors at once -- addCommandHandler ( "carshowoff", function ( playerSource ) local vehicle = getPedOccupiedVehicle ( playerSource ) if vehicle then for i=0,5 do setVehicleDoorOpenRatio ( vehicle, i, 1 - getVehicleDoorOpenRatio ( vehicle, i ), 1000 ) end end end ) ------ trigger Client Events ------ addEventHandler("onPlayerResourceStart", root, function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end) addEventHandler("onPlayerResourceStart", root, function open2 (playerSource, commandName) triggerClientEvent (playerSource, "open2", playerSource) end addCommandHandler ("open2", open2) end) addEventHandler("onPlayerResourceStart", root, function open3 (playerSource, commandName) triggerClientEvent (playerSource, "open3", playerSource) end addCommandHandler ("open3", open3) end) addEventHandler("onPlayerResourceStart", root, function open4 (playerSource, commandName) triggerClientEvent (playerSource, "open4", playerSource) end addCommandHandler ("open4", open4) end) -- Open Doors one by one -- function OpenDoor1( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) if vehicle then setVehicleDoorOpenRatio ( vehicle, 2, 1 - getVehicleDoorOpenRatio ( vehicle, 2 ), 1000 ) end end addEvent("OpenDoor1", true) addEventHandler("OpenDoor1", root, OpenDoor1) function OpenDoor2( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) if vehicle then setVehicleDoorOpenRatio ( vehicle, 3, 1 - getVehicleDoorOpenRatio ( vehicle, 3 ), 1000 ) end end addEvent("OpenDoor2", true) addEventHandler("OpenDoor2", root, OpenDoor2) function OpenDoor3( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) if vehicle then setVehicleDoorOpenRatio ( vehicle, 4, 1 - getVehicleDoorOpenRatio ( vehicle, 4 ), 1000 ) end end addEvent("OpenDoor3", true) addEventHandler("OpenDoor3", root, OpenDoor3) function OpenDoor4( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) if vehicle then setVehicleDoorOpenRatio ( vehicle, 5, 1 - getVehicleDoorOpenRatio ( vehicle, 5 ), 1000 ) end end addEvent("OpenDoor4", true) addEventHandler("OpenDoor4", root, OpenDoor4) function OpenDoor5( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) if vehicle then setVehicleDoorOpenRatio ( vehicle, 0, 1 - getVehicleDoorOpenRatio ( vehicle, 0 ), 1000 ) end end addEvent("OpenDoor5", true) addEventHandler("OpenDoor5", root, OpenDoor5) function OpenDoor6( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) if vehicle then setVehicleDoorOpenRatio ( vehicle, 1, 1 - getVehicleDoorOpenRatio ( vehicle, 1 ), 1000 ) end end addEvent("OpenDoor6", true) addEventHandler("OpenDoor6", root, OpenDoor6) -- Switch Engine -- function switchEngine ( playerSource ) local vehicle = getPedOccupiedVehicle ( client ) -- Check if the player is in any vehicle and if he is the driver if vehicle and getVehicleController ( vehicle ) == client then local state = getVehicleEngineState ( vehicle ) setVehicleEngineState ( vehicle, not state ) end end addCommandHandler ( "switchengine", switchEngine ) addEvent("switchEngine", true) addEventHandler("switchEngine", root, switchEngine) --------- Should Ask From Eranda Aiyya -------- function consoleVehicleLights () if isPedInVehicle(getRandomPlayer()) then -- checks is the player in vehicle if yes, then: playerVehicle = getPedOccupiedVehicle ( getRandomPlayer() ) -- get the local player's vehicle if ( playerVehicle ) then -- if he was in one if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then -- if the current state isn't 'force on' setVehicleOverrideLights ( playerVehicle, 2 ) -- force the lights on else setVehicleOverrideLights ( playerVehicle, 1 ) -- otherwise, force the lights off end end end end addEvent("consoleVehicleLights", true) addEventHandler("consoleVehicleLights", root, consoleVehicleLights) --------- Should Ask From Eranda Aiyya -------- -- To be Fixed -- function changeSeat01 ( ) thePed = getRandomPlayer() theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 0 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat01", true) addEventHandler ("changeSeat01", root, changeSeat01) function changeSeat02 ( ) thePed = getRandomPlayer() theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 1 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat02", true) addEventHandler ("changeSeat02", root, changeSeat02) function changeSeat03 ( ) thePed = getRandomPlayer() theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 2 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat03", true) addEventHandler ("changeSeat03", root, changeSeat03) function changeSeat04 ( ) thePed = getRandomPlayer() theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 3 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat04", true) addEventHandler ("changeSeat04", root, changeSeat04) --End of Server Side Script-- --ccp_s.lua-- I need help for this script please help me to build this script for our server. Link to comment
Heshan_Shalinda_eUnlock Posted October 4, 2021 Author Share Posted October 4, 2021 Error is exactly showing in this lines ------ trigger Client Events ------ addEventHandler("onPlayerResourceStart", root, function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end) why is it? tell me please Link to comment
Moderators Vinyard Posted October 4, 2021 Moderators Share Posted October 4, 2021 Hi, Your thread has been moved to a more appropriate section so you can get better assistance. Link to comment
The_GTA Posted October 4, 2021 Share Posted October 4, 2021 (edited) On 04/10/2021 at 07:01, Heshan_Shalinda_eUnlock said: why is it? tell me please Hello Heshan_Shalinda_eUnlock! This is actually quite easy to tell. You forgot to tell Lua that you are trying to define an anonymous closure! An anonymous closure is a function without a name that is returned as value by the syntax operation. Every Lua code that should form an anonymous closure has to be enclosed by an anonymous function signature and an end tag, for example: function (p1, p2, p3) outputDebugString("anonymous closure!") end You can fix your code excerpt this way: ------ trigger Client Events ------ function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) I hope this helps you! Come back to me if you have any further problems related to your script. EDIT: fixed some stuff I was caught off-guard. Edited October 6, 2021 by The_GTA Link to comment
Heshan_Shalinda_eUnlock Posted October 4, 2021 Author Share Posted October 4, 2021 3 hours ago, The_GTA said: Hello Heshan_Shalinda_eUnlock! This is actually quite easy to tell. You forgot to tell Lua that you are trying to define an anonymous closure! An anonymous closure is a function without a name that is returned as value by the syntax operation. Every Lua code that should form an anonymous closure has to be enclosed by an anonymous function signature and an end tag, for example: function (p1, p2, p3) outputDebugString("anonymous closure!") end You can fix your code excerpt this way: 3 hours ago, The_GTA said: Hello Heshan_Shalinda_eUnlock! This is actually quite easy to tell. You forgot to tell Lua that you are trying to define an anonymous closure! An anonymous closure is a function without a name that is returned as value by the syntax operation. Every Lua code that should form an anonymous closure has to be enclosed by an anonymous function signature and an end tag, for example: function (p1, p2, p3) outputDebugString("anonymous closure!") end You can fix your code excerpt this way: ------ trigger Client Events ------ addEventHandler("onPlayerResourceStart", root, function() function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end ) I hope this helps you! Come back to me if you have any further problems related to your script. I hope this helps you! Come back to me if you have any further problems related to your script. Thank you for your help could you please tell me how to make showGUI only when we enter a vehicle because my panel is showing using bindkey when we are not in the vehicle. And I when I use seat change it applies for all the players in the server, I want to make it for one player but show to other players in the server thank you for your help Link to comment
Heshan_Shalinda_eUnlock Posted October 4, 2021 Author Share Posted October 4, 2021 3 hours ago, The_GTA said: Hello Heshan_Shalinda_eUnlock! This is actually quite easy to tell. You forgot to tell Lua that you are trying to define an anonymous closure! An anonymous closure is a function without a name that is returned as value by the syntax operation. Every Lua code that should form an anonymous closure has to be enclosed by an anonymous function signature and an end tag, for example: function (p1, p2, p3) outputDebugString("anonymous closure!") end You can fix your code excerpt this way: ------ trigger Client Events ------ addEventHandler("onPlayerResourceStart", root, function() function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end ) I hope this helps you! Come back to me if you have any further problems related to your script. When I open/close shutter it will only show to a single player but I want to show it to all players nearby. Quote -- Part of Client Side Script -- --ccp_c.lua-- local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function open() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 4, not isVehicleWindowOpen( playerVehicle, 4 ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open", open) addEvent("open", true) addEventHandler( "open", localPlayer, open ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open ) function open2() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 2, not isVehicleWindowOpen( playerVehicle, 2 ) ) then outputChatBox( "Front Right Window switched" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open2", open2) addEvent("open2", true) addEventHandler( "open2", localPlayer, open2 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[15], open2 ) function open3() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 5, not isVehicleWindowOpen( playerVehicle, 5 ) ) then outputChatBox( "Back Left Window switched!" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open3", open3) addEvent("open3", true) addEventHandler( "open3", localPlayer, open3 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[16], open3 ) function open4() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 3, not isVehicleWindowOpen( playerVehicle, 3 ) ) then outputChatBox( "Back Right Window switched!" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open4", open4) addEvent("open4", true) addEventHandler( "open4", localPlayer, open4 ) addEventHandler ( "onClientGUIClick", GUIEditor.button[14], open4 ) -- Part of Server Side Script -- --ccp_s.lua-- ------ trigger Client Events ------ addEventHandler("onPlayerResourceStart", root, function () function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end) addEventHandler("onPlayerResourceStart", root, function () function open2 (playerSource, commandName) triggerClientEvent (playerSource, "open2", playerSource) end addCommandHandler ("open2", open2) end) addEventHandler("onPlayerResourceStart", root, function () function open3 (playerSource, commandName) triggerClientEvent (playerSource, "open3", playerSource) end addCommandHandler ("open3", open3) end) addEventHandler("onPlayerResourceStart", root, function () function open4 (playerSource, commandName) triggerClientEvent (playerSource, "open4", playerSource) end addCommandHandler ("open4", open4) end) Tell me how to show changing shutter state to all players when one players switch his vehicles window state. thank you for your help Link to comment
The_GTA Posted October 4, 2021 Share Posted October 4, 2021 (edited) On 04/10/2021 at 15:51, Heshan_Shalinda_eUnlock said: Thank you for your help could you please tell me how to make showGUI only when we enter a vehicle because my panel is showing using bindkey when we are not in the vehicle. local gui_is_visible = false; function guiackapa (set_vis) if gui_is_visible and not set_vis then guiSetVisible ( GUIEditor.window[1], false ) guiSetVisible ( GUIEditor.window[2], false ) guiSetVisible ( GUIEditor.window[3], false ) showCursor(false) elseif not gui_is_visible and set_vis then guiSetVisible ( GUIEditor.window[1], true) guiSetVisible ( GUIEditor.window[2], true) guiSetVisible ( GUIEditor.window[3], true) showCursor(true) end gui_is_visible = set_vis; end bindKey("F10","down", function() -- Only allow switching GUI visibility if the local player is inside any vehicle. if (getPedOccupiedVehicle(localPlayer)) then guiackapa( not gui_is_visible ) end end ) addEventHandler("onClientVehicleExit", root, function(exitor) -- Turn of the GUI if the player has left a vehicle. if (exitor == localPlayer) then guiackapa(false); end end ); Quote And I when I use seat change it applies for all the players in the server, I want to make it for one player but show to other players in the server -- CLIENT function changeSeat01() triggerServerEvent("changeSeat01", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[9], changeSeat01) -- SERVER function changeSeat01 ( ) thePed = client -- client is the player who triggered the serverside event/did the request theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 0 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat01", true) addEventHandler ("changeSeat01", root, changeSeat01) Please take a look at how to combine code that is redundant efficiently into shared functions. It could help minimize your code and reduce the risks of bugs. Quote thank you for your help You're welcome! Besides not knowing how to format your posts properly, you are a friendly person. I like that. Friendliness does go a long way, you know? On 04/10/2021 at 16:23, Heshan_Shalinda_eUnlock said: When I open/close shutter it will only show to a single player but I want to show it to all players nearby. Tell me how to show changing shutter state to all players when one players switch his vehicles window state. thank you for your help For exposition purposes I will leave out synchronization of data for players that join the server after setting windows open or closed. That will be an exercise for yourself. I will also leave out any serverside protective checks (is the player really inside a vehicle, known by the server?). But to get a quick idea let's change it for all players that currently play on the server. Clientside: -- OLD function open() if isPedInVehicle(getLocalPlayer()) then playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() ) if ( playerVehicle ) then if seatWindows[0] and setVehicleWindowOpen( playerVehicle, 4, not isVehicleWindowOpen( playerVehicle, 4 ) ) then outputChatBox( "Driver Window Switched" ) else outputChatBox( "You don't have window!" ) end end end end addCommandHandler("open", open) addEvent("open", true) addEventHandler( "open", localPlayer, open ) addEventHandler ( "onClientGUIClick", GUIEditor.button[13], open ) -- NEW 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 ) Serverside: -- OLD addEventHandler("onPlayerResourceStart", root, function () function open (playerSource, commandName) triggerClientEvent (playerSource, "open", playerSource) end addCommandHandler ("open", open) end) -- NEW addEvent("onVehicleWindowOpenRequest", true); addEventHandler("onVehicleWindowOpenRequest", root, function(wndid) triggerClientEvent("open", client, wndid); end ); You should adjust the code templates that you have already made with the code I have given you. Edited October 6, 2021 by The_GTA 1 Link to comment
Heshan_Shalinda_eUnlock Posted October 4, 2021 Author Share Posted October 4, 2021 33 minutes ago, The_GTA said: local gui_is_visible = false; function guiackapa (set_vis) if gui_is_visible and not set_vis then guiSetVisible ( GUIEditor.window[1], false ) guiSetVisible ( GUIEditor.window[2], false ) guiSetVisible ( GUIEditor.window[3], false ) showCursor(false) elseif not gui_is_visible and set_vis then guiSetVisible ( GUIEditor.window[1], true) guiSetVisible ( GUIEditor.window[2], true) guiSetVisible ( GUIEditor.window[3], true) showCursor(true) end gui_is_visible = set_vis; end bindKey("F10","down", function() -- Only allow switching GUI visibility if the local player is inside any vehicle. if (getPedOccupiedVehicle(localPlayer)) then guiackapa( not gui_is_visible ) end end ) addEventHandler("onClientVehicleExit", root, function(exitor) -- Turn of the GUI if the player has left a vehicle. if (exitor == localPlayer) then guiackapa(false); end end ); -- CLIENT function changeSeat01() triggerServerEvent("changeSeat01", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[9], changeSeat01) -- SERVER function changeSeat01 ( ) thePed = client -- client is the player who triggered the serverside event/did the request theVehicle = getPedOccupiedVehicle ( thePed ) if ( theVehicle ) then warpPedIntoVehicle ( thePed, theVehicle, 0 ) outputChatBox ( getPlayerName(thePed).." is in a vehicle in seat number " .. getPedOccupiedVehicleSeat ( thePed ) .. "." ) else outputChatBox ( getPlayerName(thePed).." is not in a vehicle." ) end end addEvent ("changeSeat01", true) addEventHandler ("changeSeat01", root, changeSeat01) Please take a look at how to combine code that is redundant efficiently into shared functions. It could help minimize your code and reduce the risks of bugs. You're welcome! Besides not knowing how to format your posts properly, you are a friendly person. I like that. Friendliness does go a long way, you know? The ShowGUI on vehicle enter is not working because after pasting your code I have restarted the resource. Then the GUI is visible on always and the bind key is not working please help me to fix this We will take a look on the seatChange later but would you help me to fix this thanks. Quote You're welcome! Besides not knowing how to format your posts properly, you are a friendly person. I like that. Friendliness does go a long way, you know? Thank you for your appreciation. My father once said you must thank for any person who help you for any kind of work. 1 Link to comment
The_GTA Posted October 4, 2021 Share Posted October 4, 2021 (edited) 22 minutes ago, Heshan_Shalinda_eUnlock said: The ShowGUI on vehicle enter is not working because after pasting your code I have restarted the resource. Then the GUI is visible on always and the bind key is not working please help me to fix this We will take a look on the seatChange later but would you help me to fix this thanks. I don't know what error you are talking about. The script is working fine. I have even quickly tested it on my server because you doubted it. It could be that there is a mistake in how you "pasted" the code into your own code. Have you replaced the old code with the new code? Have you removed the old code? Please post your entire script with my script inserted into it (HINT: use the <> forum editor button to paste Lua formatted code). I am looking into some issues related to onClientVehicleExit event handler and it may be unreliable in connection with scripted vehicle ejections. Here is patch for the F10 keybind to at least hide the GUI if it is visible for too long: bindKey("F10","down", function() -- Only allow switching GUI visibility if the local player is inside any vehicle. if (getPedOccupiedVehicle(localPlayer)) and not (gui_is_visible) then guiackapa( true ) elseif (gui_is_visible) then guiackapa( false ) end end ) Sorry about this inconvenience. Edited October 4, 2021 by The_GTA 1 Link to comment
Heshan_Shalinda_eUnlock Posted October 4, 2021 Author Share Posted October 4, 2021 3 minutes ago, The_GTA said: I don't know what error you are talking about. The script is working fine. I have even quickly tested it on my server because you doubted it. It could be that there is a mistake in how you "pasted" the code into your own code. Have you replaced the old code with the new code? Have you removed the old code? Please post your entire script with my script inserted into it (HINT: use the <> forum editor button to paste Lua formatted code). A sorry dude it was my bad of pasting your code in my script after your reply has received I have quickly tested it in my local server again then it works fine. Sorry for bothering you I'm still working on Show window open for all players but it's very hard for me. I'm still working on it. I have further many questions I will ask all of them one by one after completing window open part. Thank you very much for your corporation on making this script dude. 1 Link to comment
The_GTA Posted October 4, 2021 Share Posted October 4, 2021 1 minute ago, Heshan_Shalinda_eUnlock said: Thank you very much for your corporation on making this script dude. Glad to be of help to you, my friend! MTA can be a complicated mess because of hidden pitfalls like events not triggering even though they should have. That is why it is important to come ask for support inside our forums. You are doing the right thing. Also nice to hear about some family work being done inside MTA 1 Link to comment
Heshan_Shalinda_eUnlock Posted October 4, 2021 Author Share Posted October 4, 2021 39 minutes ago, The_GTA said: 40 minutes ago, The_GTA said: Glad to be of help to you, my friend! MTA can be a complicated mess because of hidden pitfalls like events not triggering even though they should have. That is why it is important to come ask for support inside our forums. You are doing the right thing. Also nice to hear about some family work being done inside MTA Thank you of your Advice dude 40 minutes ago, The_GTA said: Also nice to hear about some family work being done inside MTA Oh dude it stole my heart much and thanks you so much. I used your window open script on my local server it works fine but when I used it in a server hosted by lemehost it shows that server's version is lower to use the script. Why is that ? And also Engine on/off didn't work. Do you need to post my script again? Thanks for your help...... Link to comment
The_GTA Posted October 4, 2021 Share Posted October 4, 2021 4 minutes ago, Heshan_Shalinda_eUnlock said: I used your window open script on my local server it works fine but when I used it in a server hosted by lemehost it shows that server's version is lower to use the script. Why is that ? Go into your MTA server console and type in "ver". I don't know how lemehost exposes the server to you so please give me your feedback. Inside the MTA server console you should see the MTA version of the running server. Quote [18:47:10] MTA:SA Server v1.5.9-release-21005 Copy that text and post it here so I can check about scripting incompatibility. Quote And also Engine on/off didn't work. Here is the fixed script excerpt. You wrongfully used the client event variable in a command handler. Please do not mix functions as both command and event handlers. Use shims for interop, like this: -- Switch Engine -- function switchEngine ( player ) local vehicle = getPedOccupiedVehicle ( player ) -- Check if the player is in any vehicle and if he is the driver if vehicle and getVehicleController ( vehicle ) == player then local state = getVehicleEngineState ( vehicle ) setVehicleEngineState ( vehicle, not state ) end end addCommandHandler ( "switchengine", function( player ) switchEngine(player) end ) addEvent("switchEngine", true) addEventHandler("switchEngine", root, function() switchEngine(client); end ) 1 Link to comment
Heshan_Shalinda_eUnlock Posted October 5, 2021 Author Share Posted October 5, 2021 11 hours ago, The_GTA said: Go into your MTA server console and type in "ver". I don't know how lemehost exposes the server to you so please give me your feedback. Inside the MTA server console you should see the MTA version of the running server. Copy that text and post it here so I can check about scripting incompatibility. Here is the fixed script excerpt. You wrongfully used the client event variable in a command handler. Please do not mix functions as both command and event handlers. Use shims for interop, like this: -- Switch Engine -- function switchEngine ( player ) local vehicle = getPedOccupiedVehicle ( player ) -- Check if the player is in any vehicle and if he is the driver if vehicle and getVehicleController ( vehicle ) == player then local state = getVehicleEngineState ( vehicle ) setVehicleEngineState ( vehicle, not state ) end end addCommandHandler ( "switchengine", function( player ) switchEngine(player) end ) addEvent("switchEngine", true) addEventHandler("switchEngine", root, function() switchEngine(client); end ) I have used this and this is working in my local server but engine on/off does not working in lemehost server. Quote Multi Theft Auto v1.5.9-release-21002 Copyright (C) 2003 - 2021 Multi Theft Auto This is the version of my lemehost server and please tell me what is the error my script is not starting on that server and how to fix it. And there is another bug which is when we log into the server our car_control panel is visible and we should enter a vehicle and press F10 bindkey to make it non-visible. And when we do that is works fine but I want to fix it showing on login to the server and resource start when on foot. Thank you dude. Link to comment
The_GTA Posted October 5, 2021 Share Posted October 5, 2021 (edited) 1 hour ago, Heshan_Shalinda_eUnlock said: This is the version of my lemehost server and please tell me what is the error my script is not starting on that server and how to fix it. I am confused. You are using a very recent MTA server. Could you show me the exact message that the server is giving you? You've not told me all the details because I know what type of message you are referring to. Also, you should show me the contents of your meta.xml file. Quote And there is another bug which is when we log into the server our car_control panel is visible and we should enter a vehicle and press F10 bindkey to make it non-visible. And when we do that is works fine but I want to fix it showing on login to the server and resource start when on foot. Look at this post for a fix to make the GUI non-visible using F10 if you are outside a vehicle. To force it into non-visible state, you have to call the guiackapa function with false as first argument, like this: guiackapa( false ) Use the function inside your login panel script to make any GUI non-visible that should not be visible while your login panel is. For example, force the vehicle UI non-visible each time you set the login UI as visible. Quote Thank you dude. Glad to be of help! Edited October 5, 2021 by The_GTA 1 Link to comment
Heshan_Shalinda_eUnlock Posted October 5, 2021 Author Share Posted October 5, 2021 1 hour ago, The_GTA said: Look at this post for a fix to make the GUI non-visible using F10 if you are outside a vehicle. To force it into non-visible state, you have to call the guiackapa function with false as first argument, like this: guiackapa( false ) Use the function inside your login panel script to make any GUI non-visible that should not be visible while your login panel is. For example, force the vehicle UI non-visible each time you set the login UI as visible. Glad to be of help! I don't understand this please explain more Quote I am confused. You are using a very recent MTA server. Could you show me the exact message that the server is giving you? You've not told me all the details because I know what type of message you are referring to. Also, you should show me the contents of your meta.xml file. Quote <meta> <info author="Heshan_Shalinda" version="1.0" type="script" /> <min_mta_version server="1.5.8-9.20957"></min_mta_version> <script src="ccp_s.lua" type="server" /> <script src="ccp_c.lua" type="client" /> </meta> This is my Meta File. When I copy this resource to resources and refresh console and I have upgraded it but I can not start the resource after upgrading. I'll check Quote start: Resource 'car_controlpanel03' start was requested (Not starting resource car_controlpanel03 as this server version is too low (1.5.8-9.20957 required)) This is the exact message i'll receive after starting the resource Please help me to fix this. Link to comment
The_GTA Posted October 5, 2021 Share Posted October 5, 2021 (edited) 5 minutes ago, Heshan_Shalinda_eUnlock said: When I copy this resource to resources and refresh console and I have upgraded it but I can not start the resource after upgrading. I'll check This is the exact message i'll receive after starting the resource Please help me to fix this. Thank you. If the server version that you sent me is correct, then the error message is contradicting the version string of the server. This is very odd and could be a MTA issue. I want to perform local tests on the resource myself. Can you send me the resource in a .ZIP archive so I can run it on my computer? I will be able to further help you after local testing. Please include meta.xml and all script files. Edited October 5, 2021 by The_GTA 1 Link to comment
Heshan_Shalinda_eUnlock Posted October 5, 2021 Author Share Posted October 5, 2021 3 hours ago, The_GTA said: Thank you. If the server version that you sent me is correct, then the error message is contradicting the version string of the server. This is very odd and could be a MTA issue. I want to perform local tests on the resource myself. Can you send me the resource in a .ZIP archive so I can run it on my computer? I will be able to further help you after local testing. Please include meta.xml and all script files. How to send zip files in mta forum I don't know how to do it Link to comment
The_GTA Posted October 5, 2021 Share Posted October 5, 2021 Just now, Heshan_Shalinda_eUnlock said: How to send zip files in mta forum I don't know how to do it For maintainability reasons related to DRM you cannot do that. But since the resource belongs 100% to you, please upload the .ZIP file somewhere and give me the URL to it. You need to find an upload location outside of the MTA forums. Link to comment
Heshan_Shalinda_eUnlock Posted October 5, 2021 Author Share Posted October 5, 2021 Just now, The_GTA said: For maintainability reasons related to DRM you cannot do that. But since the resource belongs 100% to you, please upload the .ZIP file somewhere and give me the URL to it. You need to find an upload location outside of the MTA forums. Ok I have uploaded it in my google Drive You can get it from this link https://drive.google.com/drive/folders/1caWIA8wt_1BvJfyNeBUh5kVKNf69gXB4?usp=sharing And again thanks dude. Link to comment
The_GTA Posted October 5, 2021 Share Posted October 5, 2021 Google Drive has made me request access permissions for your file. You need to accept my request. Look into your Google Drive account/your E-Mail box. Link to comment
Heshan_Shalinda_eUnlock Posted October 5, 2021 Author Share Posted October 5, 2021 13 minutes ago, The_GTA said: Google Drive has made me request access permissions for your file. You need to accept my request. Look into your Google Drive account/your E-Mail box. I think you can download from this link https://drive.google.com/file/d/1RlBWAoc_1Iv0ObU3aG_5oMMkCpvWhio8/view?usp=sharing 1 Link to comment
The_GTA Posted October 5, 2021 Share Posted October 5, 2021 I have started the resource on my local 21002 server and it has started fine. Are you sure that you have given me the correct server version number? Either lemehost is not being honest to you or you have mixed up some information. Link to comment
Heshan_Shalinda_eUnlock Posted October 5, 2021 Author Share Posted October 5, 2021 2 hours ago, The_GTA said: I have started the resource on my local 21002 server and it has started fine. Are you sure that you have given me the correct server version number? Either lemehost is not being honest to you or you have mixed up some information. Thanks dude you have done much for me. I have tested it by creating my own lemehost server and now it works fine but I haven't still tested the window open/close state showing to other players or not. I want to fix change seat problem now, when click that on gui it will apply to all the players in the server. I need help fixing it. Link to comment
The_GTA Posted October 5, 2021 Share Posted October 5, 2021 2 minutes ago, Heshan_Shalinda_eUnlock said: I want to fix change seat problem now, when click that on gui it will apply to all the players in the server. I need help fixing it. Look at this post above: https://forum.multitheftauto.com/topic/132730-error-loading-script-failed-car_controlpanel03/?do=findComment&comment=1002018 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